⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 livelli.bas

📁 用VB编写一个非常好的赛车游戏,源程序来自网络,这里是转载~谢谢合作~
💻 BAS
字号:
Attribute VB_Name = "Livelli"
Global luce As D3DLIGHT8

'per gli impatti
Global angoloRect  As RECT

Sub caricaLivelli()
    caricaPezzi
    caricaAutoLow
    
    'varie
    Set tachiTex = creaTex(App.Path & "\photo\tachimetro.bmp", D3DColorMake(1, 1, 1, 1), True)
    Set discoTex = creaTex(App.Path & "\photo\disco.bmp", D3DColorMake(0, 0, 0, 0), True)
    freccia = creaMesh(App.Path & "\piste\freccia.x", False, True)
    For relV = 0 To freccia.numX
            freccia.mateX(relV).emissive.r = freccia.mateX(relV).diffuse.r / 2
            freccia.mateX(relV).emissive.g = freccia.mateX(relV).diffuse.g / 2
            freccia.mateX(relV).emissive.b = freccia.mateX(relV).diffuse.b / 2
            freccia.mateX(relV).diffuse.r = 0
            freccia.mateX(relV).diffuse.b = 0
            freccia.mateX(relV).diffuse.g = 0
    Next relV
    'carica mesh per la fiamma volumetrica
    fiammata = creaMesh(App.Path & "\oggetti\auto\flame.x", True, True, App.Path & "\oggetti\auto")
    fiammata.mateX(0).diffuse.r = 0
    fiammata.mateX(0).diffuse.b = 0
    fiammata.mateX(0).diffuse.g = 0
    fiammata.mateX(0).diffuse.a = 0
    
    'alpha
    device.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
    device.SetRenderState D3DRS_DESTBLEND, D3DBLEND_DESTALPHA
    
    
    'carica la texture per i numeri
    Set numeriTex = creaTex(App.Path & "\photo\caratteri.bmp", D3DColorMake(1, 1, 1, 1), True)

'resetta dalle precedenti
device.SetRenderState D3DRS_FOGENABLE, False
disegnaCielo = True
'numPista = 2

Select Case numPista

Case 1
    'first track
    Open App.Path & "\piste\pista01" For Binary As #1
    Get #1, , pista
    Get #1, , mappa
    Get #1, , resi
    Close #1
    'texture del pavimento
    Set verticiTex1 = creaTex(App.Path & "\piste\tex01.bmp", 0)
    Set textureArray(1) = creaTex(App.Path & "\piste\tex02.bmp", 0)
    
    'texture della mappa
    Set mappaTex = creaTex(App.Path & "\piste\mappe\pista01.bmp", D3DColorMake(0, 0, 0, 1), True)

    'luce della pista
    device.SetRenderState D3DRS_LIGHTING, 1
    luce.Direction.x = 0
    luce.Direction.y = -5
    luce.Direction.z = -3
    luce.Type = D3DLIGHT_DIRECTIONAL
    luce.diffuse.r = 1
    luce.diffuse.g = 1
    luce.diffuse.b = 1
    luce.diffuse.a = 1
    luce.specular = luce.diffuse
    device.SetLight 0, luce
    device.LightEnable 0, 1
    device.SetRenderState D3DRS_AMBIENT, D3DColorMake(1, 1, 1, 1)
    'texture del cielo
    Set cieloTex = creaTex(App.Path & "\piste\cielo.bmp", 0)
        
    D3DXPlaneFromPoints piano, MakeVector(1, 0.1, 0), MakeVector(0, 0.1, 0), MakeVector(0, 0.1, 1)
                vettoreLuce.x = 0
                vettoreLuce.y = 5
                vettoreLuce.z = 3
                vettoreLuce.w = 0
    'carica i nodi
    
    relW = 0
    Open App.Path & "\piste\pista01.txt" For Input As #1
        While Not EOF(1)
            ReDim Preserve nodoX(relW)
            ReDim Preserve nodoY(relW)
            Input #1, nodoX(relW)
            Input #1, nodoY(relW)
            relW = relW + 1
        Wend
    Close #1
    
Case 2
    'second track
    Open App.Path & "\piste\pista02" For Binary As #1
    Get #1, , pista
    Get #1, , mappa
    Get #1, , resi
    Close #1
    'texture del pavimento
    Set verticiTex1 = creaTex(App.Path & "\piste\tex11.bmp", 0)
    Set textureArray(1) = creaTex(App.Path & "\piste\tex03.bmp", 0)
    'texture della mappa
    Set mappaTex = creaTex(App.Path & "\piste\mappe\pista02.bmp", D3DColorMake(0, 0, 0, 1), True)

    'luce della pista
    device.SetRenderState D3DRS_LIGHTING, 1
    luce.Direction.x = 0
    luce.Direction.y = -3
    luce.Direction.z = -3
    luce.Type = D3DLIGHT_DIRECTIONAL
    luce.diffuse.r = 1
    luce.diffuse.g = 0.5
    luce.diffuse.b = 0.3
    luce.diffuse.a = 1
    luce.specular = luce.diffuse
    device.SetLight 0, luce
    device.LightEnable 0, 1
    device.SetRenderState D3DRS_AMBIENT, D3DColorMake(1, 1, 1, 1)
    'texture del cielo
    Set cieloTex = creaTex(App.Path & "\piste\cielo6.bmp", 0)
        
    D3DXPlaneFromPoints piano, MakeVector(1, 0.1, 0), MakeVector(0, 0.1, 0), MakeVector(0, 0.1, 1)
                vettoreLuce.x = 0
                vettoreLuce.y = 3
                vettoreLuce.z = 3
                vettoreLuce.w = 0
    'carica i nodi
    'modifica
    For relV = 0 To 40
        Select Case relV
        Case 2 To 6, 9 To 16
            Set meshePez(relV).texX(0) = creaTex(App.Path & "\piste\tex11.bmp", 0)
        End Select
    Next relV

    relW = 0
    Open App.Path & "\piste\pista02.txt" For Input As #1
        While Not EOF(1)
            ReDim Preserve nodoX(relW)
            ReDim Preserve nodoY(relW)
            Input #1, nodoX(relW)
            Input #1, nodoY(relW)
            relW = relW + 1
        Wend
    Close #1
    
    
     'aggiungi
    ReDim meshAusX(0)
    meshAusX(0) = creaMesh(App.Path & "\piste\portale.x", True, True, App.Path & "\piste")
    Set meshAusX(0).texX(0) = creaTex(App.Path & "\piste\slime.bmp", D3DColorMake(1, 1, 1, 1), True)
    'nebbia
    nebbia D3DFOG_LINEAR, D3DColorMake(1, 0.5, 0, 0), 800, 1400

    
Case 3
    'third track
    Open App.Path & "\piste\pista03" For Binary As #1
    Get #1, , pista
    Get #1, , mappa
    Get #1, , resi
    Close #1
    'texture del pavimento
    Set verticiTex1 = creaTex(App.Path & "\piste\tex01.bmp", 0)
    Set verticiTex2 = creaTex(App.Path & "\piste\tex03.bmp", 0)
    Set textureArray(1) = creaTex(App.Path & "\piste\tex06.bmp", 0)
    'texture della mappa
    Set mappaTex = creaTex(App.Path & "\piste\mappe\pista03.bmp", D3DColorMake(0, 0, 0, 1), True)

    'luce della pista
    device.SetRenderState D3DRS_LIGHTING, 1
    luce.Direction.x = 0
    luce.Direction.y = -5
    luce.Direction.z = -3
    luce.Type = D3DLIGHT_DIRECTIONAL
    luce.diffuse.r = 1
    luce.diffuse.g = 1
    luce.diffuse.b = 1
    luce.diffuse.a = 1
    luce.specular = luce.diffuse
    device.SetLight 0, luce
    device.LightEnable 0, 1
    device.SetRenderState D3DRS_AMBIENT, D3DColorMake(1, 1, 1, 1)
    'texture del cielo
    Set cieloTex = creaTex(App.Path & "\piste\cielo5.bmp", 0)
    disegnaCielo = False
    D3DXPlaneFromPoints piano, MakeVector(1, 0.1, 0), MakeVector(0, 0.1, 0), MakeVector(0, 0.1, 1)
                vettoreLuce.x = 0
                vettoreLuce.y = 5
                vettoreLuce.z = 3
                vettoreLuce.w = 0
    'carica i nodi
    relW = 0
    Open App.Path & "\piste\pista03.txt" For Input As #1
        While Not EOF(1)
            ReDim Preserve nodoX(relW)
            ReDim Preserve nodoY(relW)
            Input #1, nodoX(relW)
            Input #1, nodoY(relW)
            relW = relW + 1
        Wend
    Close #1
    
    
    nebbia D3DFOG_LINEAR, 0, 1000, 1400
Case 4
    'forth track
    Open App.Path & "\piste\pista04" For Binary As #1
    Get #1, , pista
    Get #1, , mappa
    Get #1, , resi
    Close #1
    'texture del pavimento
    Set verticiTex1 = creaTex(App.Path & "\piste\tex05.bmp", 0)
    Set verticiTex2 = creaTex(App.Path & "\piste\tex03.bmp", 0)
    Set textureArray(1) = creaTex(App.Path & "\piste\tex04.bmp", 0)
    'texture della mappa
    Set mappaTex = creaTex(App.Path & "\piste\mappe\pista04.bmp", D3DColorMake(0, 0, 0, 1), True)

    'luce della pista
    device.SetRenderState D3DRS_LIGHTING, 1
    luce.Direction.x = 0
    luce.Direction.y = -5
    luce.Direction.z = -3
    luce.Type = D3DLIGHT_DIRECTIONAL
    luce.diffuse.r = 0.5
    luce.diffuse.g = 0.5
    luce.diffuse.b = 0.5
    luce.diffuse.a = 1
    luce.specular = luce.diffuse
    device.SetLight 0, luce
    device.LightEnable 0, 1
    device.SetRenderState D3DRS_AMBIENT, D3DColorMake(0.5, 0.5, 0.5, 1)
    'texture del cielo
    Set cieloTex = creaTex(App.Path & "\piste\cielo3.bmp", 0)
        
    D3DXPlaneFromPoints piano, MakeVector(1, 0.1, 0), MakeVector(0, 0.1, 0), MakeVector(0, 0.1, 1)
                vettoreLuce.x = 0
                vettoreLuce.y = 5
                vettoreLuce.z = 3
                vettoreLuce.w = 0
    'carica i nodi
    
    relW = 0
    Open App.Path & "\piste\pista04.txt" For Input As #1
        While Not EOF(1)
            ReDim Preserve nodoX(relW)
            ReDim Preserve nodoY(relW)
            Input #1, nodoX(relW)
            Input #1, nodoY(relW)
            relW = relW + 1
        Wend
    Close #1
    'aggiungi
    ReDim meshAusX(0)
    meshAusX(0) = creaMesh(App.Path & "\piste\portale.x", True, True, App.Path & "\piste")
    Set meshAusX(0).texX(0) = creaTex(App.Path & "\piste\slime.bmp", D3DColorMake(1, 1, 1, 1), True)
    
End Select

'parte comune a tutte le cose
   'quadrato
    vertici(0) = CreaD3Dv(-100, -1, -100, 1, 1, 1, 0, 1)
    vertici(1) = CreaD3Dv(-100, -1, 100, 1, 1, 1, 0, 0)
    vertici(2) = CreaD3Dv(100, -1, 100, 1, 1, 1, 1, 0)
    vertici(3) = CreaD3Dv(100, -1, 100, 1, 1, 1, 1, 0)
    vertici(4) = CreaD3Dv(100, -1, -100, 1, 1, 1, 1, 1)
    vertici(5) = CreaD3Dv(-100, -1, -100, 1, 1, 1, 0, 1)
    
    verticiMate.diffuse.r = 1
    verticiMate.diffuse.b = 1
    verticiMate.diffuse.g = 1
' a seconda della modalit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -