'This sets up the view rect, where the maps and sprites are actually drawn
Public Sub SetUpMapView(mLeft As Single, mTop As Single, mRight As Single, mBottom As Single, mClip As Single)
'place Values into mapview rect
With MapView
.Left = mLeft
.Right = mRight
.Top = mTop
.Bottom = mBottom
End With
MapClip = mClip
End Sub
'Sub to copy rect from one texture to another
Public Sub TextureCopyRects(SourceIndex As Variant, DestIndex As Variant, GetX As Variant, GetY As Variant, PutX As Variant, PutY As Variant, Width As Variant, Height As Variant)
'temp surfaces and Textures
Dim DestTexture As Direct3DTexture8
Dim DestSurface As Direct3DSurface8
Dim SourceTexture As Direct3DTexture8
Dim SourceSurface As Direct3DSurface8
'Set textures to temps
Set DestTexture = Texture(DestIndex).GetTexture
Set DestSurface = DestTexture.GetSurfaceLevel(0)
Set SourceTexture = Texture(SourceIndex).GetTexture
Set SourceSurface = SourceTexture.GetSurfaceLevel(0)
'It takes a pixel value for texture and returns it into a value
'from 0 to 1
Private Function TextureValue(Total As Single, Current As Single) As Single
Dim PixelTex As Single
PixelTex = 1 / (Total)
TextureValue = PixelTex * (Current)
End Function
'This Function Makes the Strips
Private Function MakeStrip(x As Single, y As Single, z As Single, rhw As Single, Color As Long, specular As Long, tu As Single, tv As Single) As TLVertex
MakeStrip.x = x
MakeStrip.y = y
MakeStrip.z = z
MakeStrip.rhw = rhw
MakeStrip.Color = Color
MakeStrip.specular = specular
MakeStrip.tu = tu
MakeStrip.tv = tv
End Function
'Rotation Functions
Public Function RotateX(x As Single, y As Single, angle As Single) As Single
Dim TX As Single, TAngle As Single
'turns the angle degrees into radians
TAngle = angle * (3.141592654 / 180)
'Rotate on axis
TX = x * Cos(TAngle) - y * Sin(TAngle)
RotateX = TX
End Function
Public Function RotateY(x As Single, y As Single, angle As Single) As Single
Dim TY As Single, TAngle As Single
'turns the angle degrees into radians
TAngle = angle * (3.141592654 / 180)
'Rotate on axis
TY = y * Cos(TAngle) + x * Sin(TAngle)
RotateY = TY
End Function
'This Sub is Perhaps my neatest invention...it sets a sprites angle according to another
'this is good for tracking
Public Sub SetAutoAngle(FromSprite As Variant, ToSprite As Variant)
Dim X1 As Single, Y1 As Single
Dim X2 As Single, Y2 As Single
Dim FSprite As DaBoodaSprite, tSprite As DaBoodaSprite
D3DX.DrawText ScreenFont, TText.GetColor, TText.GetText, TextRect, DT_TOP Or DT_LEFT
End Sub
Public Sub CreateFont(Name As String, Size As Single, Optional Bold As Boolean, Optional Italic As Boolean, Optional Underline As Boolean, Optional StrikeThru As Boolean)
With StandardFont
.Name = Name
.Size = Size
.Bold = Bold
.Italic = Italic
.Underline = Underline
.Strikethrough = StrikeThru
End With
Set ScreenFontDesc = StandardFont
Set ScreenFont = D3DX.CreateFont(Direct3DDevice, ScreenFontDesc.hFont)
End Sub
Public Sub SetScreenToAutoMoveSprite(Optional Speed As Single)
Dim tWidth As Single, tHeight As Single
Dim tXIncrement As Single, tYIncrement As Single
Dim tmXincrement As Single, tmYIncrement As Single