home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 3195
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 3195
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '---------------------------------------------------------------
- ' Visual Basic Game Programming for Teens
- ' PrintText Program
- '---------------------------------------------------------------
- Option Explicit
- Option Base 0
- Const SCREENWIDTH As Long = 800
- Const SCREENHEIGHT As Long = 600
- Const C_PURPLE As Long = &HFFFF00FF
- Const C_RED As Long = &HFFFF0000
- Const C_GREEN As Long = &HFF00FF00
- Const C_BLUE As Long = &HFF0000FF
- Const C_WHITE As Long = &HFFFFFFFF
- Const C_BLACK As Long = &H0
- Const C_GRAY As Long = &HFFAAAAAA
- Dim fontImg As Direct3DTexture8
- Dim fontSpr As TSPRITE
- Private Sub Form_Load()
- 'set up the main form
- Me.Caption = "PrintText"
- Me.ScaleMode = 3
- Me.width = Screen.TwipsPerPixelX * (SCREENWIDTH + 12)
- Me.height = Screen.TwipsPerPixelY * (SCREENHEIGHT + 30)
- Me.Show
- 'initialize Direct3D
- InitDirect3D Me.hWnd
- 'get reference to the back buffer
- Set backbuffer = d3ddev.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
- 'load the bitmap file
- Set fontImg = LoadTexture(d3ddev, App.Path & "\font.bmp")
- InitSprite d3ddev, fontSpr
- fontSpr.FramesPerRow = 20
- fontSpr.width = 16
- fontSpr.height = 24
- fontSpr.ScaleFactor = 2
- 'clear the screen to black
- d3ddev.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
- d3ddev.BeginScene
- PrintText fontImg, fontSpr, 10, 10, C_BLUE, "W e l c o m e T o V i s u a l B a s i c"
- fontSpr.ScaleFactor = 1
- PrintText fontImg, fontSpr, 10, 70, C_WHITE, "abcdefghijklmnopqrstuvwxyz"
- PrintText fontImg, fontSpr, 10, 100, C_GRAY, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- PrintText fontImg, fontSpr, 10, 130, C_GREEN, "!""#$%&()*+,-./0123456789:;<=>?@[\]^_{|}~"
- fontSpr.ScaleFactor = 3
- PrintText fontImg, fontSpr, 10, 180, C_RED, "B I G H U G E F O N T !"
- fontSpr.ScaleFactor = 0.6
- PrintText fontImg, fontSpr, 10, 260, C_PURPLE, "This Is A Smaller Font"
- d3ddev.EndScene
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- If KeyCode = 27 Then Shutdown
- End Sub
- Private Sub Form_Paint()
- d3ddev.Present ByVal 0, ByVal 0, 0, ByVal 0
- End Sub
- Private Sub PrintText( _
- ByRef fontImg As Direct3DTexture8, _
- ByRef fontSpr As TSPRITE, _
- ByVal X As Long, _
- ByVal Y As Long, _
- ByVal color As Long, _
- ByVal sText As String)
- Dim n As Long
- For n = 1 To Len(sText)
- PrintChar fontImg, fontSpr, X + (n - 1) * fontSpr.width, Y, color, Asc(Mid$(sText, n, 1))
- Next n
- End Sub
- Private Sub PrintChar( _
- ByRef fontImg As Direct3DTexture8, _
- ByRef fontSpr As TSPRITE, _
- ByVal X As Long, _
- ByVal Y As Long, _
- ByVal color As Long, _
- c As Byte)
- fontSpr.X = X
- fontSpr.Y = Y
- fontSpr.CurrentFrame = c - 32
- DrawSprite fontImg, fontSpr, color
- End Sub
-