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

📄 modfloor.bas

📁 一个游戏的原代码
💻 BAS
字号:
Attribute VB_Name = "modFloor"
Option Explicit
'This module genarates and render a simple floor
'It will generate two floors, because our floor should be visible from both sides :)

'The Vertices
Private Type FVert
    pos As D3DVECTOR
    col As Long
    tex1 As D3DVECTOR2
End Type
Public Const FLOORVERT_SIZE As Long = 24
Public Const FLOORVERT_FVF As Long = (D3DFVF_XYZ Or D3DFVF_DIFFUSE Or D3DFVF_TEX1)
Public FVertex(3) As FVert

Public FloorTex As Direct3DTexture8
Public FloorMat As D3DMATERIAL8
Public FloorBuffer As Direct3DVertexBuffer8
Private tempDesc As D3DSURFACE_DESC

Public Sub CreateFloor(fY As Single, Optional TexPath As String)
'Load the textures
If TexPath <> "" Then
Set FloorTex = D3DX.CreateTextureFromFileEx(D3Ddevice, TexPath, 0, 0, D3DX_DEFAULT, 0, D3DFMT_R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR, 0, ByVal 0, ByVal 0)
End If

FVertex(0) = CreateVertex(-100, fY, 100, 1, 1)
FVertex(1) = CreateVertex(-100, fY, -100, 1, 0)
FVertex(2) = CreateVertex(100, fY, 100, 0, 1)
FVertex(3) = CreateVertex(100, fY, -100, 0, 0)

Set FloorBuffer = D3Ddevice.CreateVertexBuffer(4 * FLOORVERT_SIZE, D3DUSAGE_WRITEONLY, FLOORVERT_FVF, D3DPOOL_MANAGED)
D3DVertexBuffer8SetData FloorBuffer, 0, 4 * FLOORVERT_SIZE, 0, FVertex(0)
End Sub

Public Sub RenderFloor(tex As Direct3DTexture8)
D3Ddevice.SetRenderState D3DRS_LIGHTING, 0
D3Ddevice.SetRenderState D3DRS_ALPHABLENDENABLE, 1
D3Ddevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
D3Ddevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA

'Wichtig, damit D3D wei

⌨️ 快捷键说明

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