GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 9:51 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Jun 25, 2010 3:21 pm 
Prolific Poster

Joined: Tue Jul 22, 2008 7:26 pm
Posts: 22
Hi,

It's been a while, even since I browsed these forums...

I've been looking for Tutorials, Samples, Code, Explanations, etc... on Sprites, how to create them, load from a file etc...

My Application for a game I'm making FINALLY runs with no errors...at least none that I'm aware of. BUT!!! Here's what it's supposed to do:

Create a D3DTexture8FromFileEx with the Font1.bmp in App.Path + "Graphics\Fonts\Font1.bmp" and later grab each 64 X 64 letter or symbol from the D3DTexutre8 I just SUCCESSFULLY Loaded, and display it as a sprite on the specified position on the screen, "left" justified, and at the specified size x and size y...

What it's REALLY doing:

Just Displaying a black screen with no error!

I am still considering myself a newbie at this because even though I've used TGC's DBPro amongst other plugins for it and VB and DX7/DX8 for a few years now, I'm self taught, I'm a LOT slower of a learner, though I'm creative and can SOMETIMES show a smart gene from my body, and I have other responsibilities that prohibit me from doing this hard core...

I work, I have other SOCIAL activities, I'm going back to Louisiana Tech College for Computer Networking Specialist, and etc...

Everything you need to run the program, and the program itself, is in a .zip file on my Computer...I HAVE NOT UPLOADED IT YET, BECAUSE I DON'T KNOW HOW ON THIS FORUM, FORGOT HOW, OR WORSE YET, THERE ISN'T A FILE UPLOADER ON HERE...If I have to use a URL for uploading files here, please tell me, and tell me HOW...

I hope the code is commented well enough for nit-picking around in, just to make the viewers' lives easier... :D

I work at 11:00 AM CentralTimeZone. Look it up if you don't know on google, I'm in Louisiana...I don't know when I get off though. I will reply when I get back.

And this is NOT a "GIVE ME THE CODE!" request, I'd rather get ACTUALL HELP with this with SOME Code Snippets! I've seen too much "Give me the code!" posts on not just THIS forum, but EVERY Programming/GameProgramming Forum I've been to, and I'm NOT ASKING for an ENTIRE Tutorial, although if every one who posts help for me will SORT OF be contributing to a SMALL TUTORIAL... 8)

I might actually, once I get help and understand it and get it working, even MAKE a little tutorial on Custom Sprite Fonts in ONE CENTRAL POST for everybody to easily access...on my spare time of course!

Thanks,

MickeyIII

Edit:

download: http://www.filefactory.com/file/b23hace/n/Super_Charge_rar

There it is...the entire thing...and just to let y'all know, this is supposed to eventually become a 2D Sprite Based Fighting Game, although this is more long term where as right now I'm just learning...

Oh, and one more thing, I forgot to take out the Cruddy Stick Figure Sprite Sheet Animation, because, well...it stinks! Just ignore it, sense it's not being loaded in the code...
[/b]


Last edited by MickeyIII on Sat Jun 26, 2010 4:06 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2010 3:38 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
There are any number of file sharing sites - RapidShare, DepositFiles, etc. If you have a Windows Live account I believe you get a ton of space on their site.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2010 10:40 pm 
Prolific Poster

Joined: Tue Jul 22, 2008 7:26 pm
Posts: 22
Doh! :O

I totaly forgot those sites existed and that NOT ALL torrents are ILLEGAL...

I think I'll go to Rapidshare and do it sense it's the ONLY one I know about that doesn't have a lot of popups on this TEMPORARY 15 year old PENTIUM II Class Computer with Win98 SE, and that doesn't slow it down and/or crash it...

I will edit the first post with the .rar File once I have it uploaded...even with OLD Wireless B Usb Adapter Networking with a Wireless G Router in my Dad's Computer Room, this could take a while.......A LONG WHILE....

Then again, I don't think it's that big of a file either...

Thanks for the quick reply...

MickeyIII

Edit: Here's a somewhat better version with some mathematical and a few d3ddev fixes...

Zip file download location: http://www.filefactory.com/file/b24432e/n/Super_Charge_2_zip

When I changed the D3DDev.Clear Color to blue instead of black, it rendered the background blue so I know I've come this far at least...

I don't know how to properly use the Debug features when coupled with a DirectX8 App in VB6, but just from being able to clear the screen properly and then the next few bits of code doesn't seem to work, that's how I know I'm doing something wrong in the way I either setup and draw the sprites, or just draw the sprites...The code I'm talking about is in the Form_Load Sub in Main.frm inside the do...loop until... code like so:

Code:

'//This is to control whether or not we show the mouse cursor...
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Form_Load()

On Local Error GoTo Error_Handler

'//Call our DirectX8 Object Initialization Routine
Dx8_Init

'//Call our Direct3D8 Initialization Routine
D3D8_Init

'//Call our Direct Input8 Object Initialization Routine
DI_Object_Init

'//Call our Direct Input8 Keyboard Initialization Routine
DI_Keyboard_Init

'//Set the variable that controls whether or not our program
'//is running to TRUE...
bRunning = True

'//Hide the mouse cursor
ShowCursor False

Dim tc_Start As Long
tc_Start = GetTickCount()

'//Load Game Font1...
GameFont_Load_Font1

'//Begin our main loop...
Do

'//Check for input from the keyboard...
DIKeyboardDev.GetDeviceStateKeyboard DIKeyState

'//If the Escape Key (Esc) is pressed, set
'//bRunning = false so that the program can
'//get out of the main loop, clean up, and end the program.
If DIKeyState.Key(1) > 0 Then

    bRunning = False

End If

D3DDev.Clear 0, ByVal 0, D3DCLEAR_TARGET, RGB(0, 0, 0), 1#, 0

'//********THIS IS THE PROBLEM AREA********
'//********IT BEGINS HERE...***************

'//Start the D3DDevice Scnene...
D3DDev.BeginScene

'//Sprite Scene Begin...
Sprite.Begin

GameFont_Display_Font1 "Hello World!", 64, 160, 64, 64, "left"

Sprite.End

D3DDev.EndScene

'//********...AND ENDS HERE****************
'//********END OF PROBLEM AREA*************

If GetTickCount() - tc_Start > 16 Then
    '//Update the Direct3D Backbuffer and display its
    '//contents to the screen.
    D3DDev.Present ByVal 0, ByVal 0, 0, ByVal 0
   
    '//Reset TickCounter Start Position...
    tc_Start = GetTickCount()

End If

DoEvents

'//...loop until bRunning = false
Loop Until bRunning = False

'//Clean up and end the program...
Shutdown
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub




Any help would be appreciated!

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 3:00 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Would you be able to post the code from your "GameFont_Display_Font1" sub?

Also, it's been a while since I've look at VB6+DirectX ... but I think you're missing a "Present" method in there somewhere.

I thought I remember it going ... BeginScene >> Draw everything >> EndScene >> Present ... or something similar.

-Matt

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 4:52 pm 
Prolific Poster

Joined: Tue Jul 22, 2008 7:26 pm
Posts: 22
It's in there...

It's after the D3DDev.Begin Screen in side the:

If GetTickCount() - start > 16 then

.....

D3DDev.Present ByVal 0, ByVal 0, 0, ByVal 0

....

endif

Plus...if you download the Super Charge_2.zip file in my last post, you will HAVE ALL THE CODE in order to RUN the program...

Thanks,

MickeyIII


Edit:

Oh yeah, and you not only have to have D3DDev.BeginScene...EndScene, you also have to have a D3DX8 Sprite object with Sprite.Begin and Sprite.Draw and Sprite.End in between the D3DDev.BeginScene...EndScene. I know that much, because the DirectX8 SDK for VB6 Documentation from a CD in a Book I have says so...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 5:10 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Ah -- thanks for pointing out your present ... I missed it mixed in amongst that if-then block.

I don't have VB6 installed any more -- so downloading your code wouldn't help me as much ... is it possible for you to post the sub that's doing the work for your font drawing?

-Matt

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 5:41 pm 
Prolific Poster

Joined: Tue Jul 22, 2008 7:26 pm
Posts: 22
sure...

My Main.frm code:

Code:
Private Sub Form_Load()

On Local Error GoTo Error_Handler

'//Call our DirectX8 Object Initialization Routine
Dx8_Init

'//Call our Direct3D8 Initialization Routine
D3D8_Init

'//Call our Direct Input8 Object Initialization Routine
DI_Object_Init

'//Call our Direct Input8 Keyboard Initialization Routine
DI_Keyboard_Init

'//Set the variable that controls whether or not our program
'//is running to TRUE...
bRunning = True

'//Hide the mouse cursor
ShowCursor False

Dim tc_Start As Long
tc_Start = GetTickCount()

'//Load Game Font1...
GameFont_Load_Font1

'//Begin our main loop...
Do

'//Check for input from the keyboard...
DIKeyboardDev.GetDeviceStateKeyboard DIKeyState

'//If the Escape Key (Esc) is pressed, set
'//bRunning = false so that the program can
'//get out of the main loop, clean up, and end the program.
If DIKeyState.Key(1) > 0 Then

    bRunning = False

End If

D3DDev.Clear 0, ByVal 0, D3DCLEAR_TARGET, RGB(0, 0, 0), 1#, 0

'//********THIS IS THE PROBLEM AREA********
'//********IT BEGINS HERE...***************

'//Start the D3DDevice Scnene...
D3DDev.BeginScene

GameFont_Display_Font1 "Hello World!", 64, 160, 64, 64, "left"

D3DDev.EndScene

'//********...AND ENDS HERE****************
'//********END OF PROBLEM AREA*************

If GetTickCount() - tc_Start > 16 Then
    '//Update the Direct3D Backbuffer and display its
    '//contents to the screen.
    D3DDev.Present ByVal 0, ByVal 0, 0, ByVal 0
   
    '//Reset TickCounter Start Position...
    tc_Start = GetTickCount()

End If

DoEvents

'//...loop until bRunning = false
Loop Until bRunning = False

'//Clean up and end the program...
Shutdown
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub


Clean_Up.bas...

Code:
'//Mouse cursor show and hide commands
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Public Sub Shutdown()

    On Local Error GoTo Error_Handler

    '//Unacquire the Keyboard Device...\
    If DIKeyboardDevAcquired = True Then
   
        DIKeyboardDev.Unacquire
        DIKeyboardDevAcquired = False
        Set DIKeyboardDev = Nothing
   
    End If
   
    '//Check to see if Controler 0 has been Acquired...
    '//If so, then Unacquire it...
    If DIControlerDevAcquired(0) = True Then
   
        DIControlerDev(0).Unacquire
        DIControlerDevAcquired(0) = False
        Set DIControlerDev(0) = Nothing
   
    End If

    '//...Then do the same for Controler 1.
    If DIControlerDevAcquired(1) = True Then
   
        DIControlerDev(1).Unacquire
        DIControlerDevAcquired(1) = False
        Set DIControlerDev(1) = Nothing
       
    End If
   
    '//Destroy the Direct Input8 Object...
    Set DInput = Nothing
    '//Destroy the d3d device8 object...
    Set D3DDev = Nothing
    '//Destroy the d3d8 object...
    Set D3D = Nothing
    '//Last, but not least, destroy the directx8 object...
    Set Dx = Nothing
   
    '//Unhide the cursor...
    ShowCursor True
   
    '//Finaly, the program ends...
    End

Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    End

End Sub


DI_Init.bas...
Code:
Public Sub DI_Object_Init()

    On Local Error GoTo Error_Handler

    '//Set DInput as the DirectInputObject and Create it...
    Set DInput = Dx.DirectInputCreate()

    Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub

Public Sub DI_Keyboard_Init()

    On Local Error GoTo Error_Handler
   
    '//Create Direct Input Interface for the Keyboard to the Program.
    Set DIKeyboardDev = DInput.CreateDevice("GUID_SysKeyboard")
    DIKeyboardDev.SetCommonDataFormat DIFORMAT_KEYBOARD
    DIKeyboardDev.SetCooperativeLevel Main.hWnd, _
        DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
    DIKeyboardDev.Acquire
   
    Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub


DIKey_Codes.bas...

Code:
Public Const DIK_ESC As Byte = 1
Public Const DIK_1 As Byte = 2
Public Const DIK_2 As Byte = 3
Public Const DIK_3 As Byte = 4
Public Const DIK_4 As Byte = 5
Public Const DIK_5 As Byte = 6
Public Const DIK_6 As Byte = 7
Public Const DIK_7 As Byte = 8
Public Const DIK_8 As Byte = 9
Public Const DIK_9 As Byte = 10
Public Const DIK_0 As Byte = 11
Public Const DIK_MINUS As Byte = 12
Public Const DIK_EQUAL As Byte = 13
Public Const DIK_BACKSPACE As Byte = 14
Public Const DIK_TAB As Byte = 15
Public Const DIK_Q As Byte = 16
Public Const DIK_W As Byte = 17
Public Const DIK_E As Byte = 18
Public Const DIK_R As Byte = 19
Public Const DIK_T As Byte = 20
Public Const DIK_Y As Byte = 21
Public Const DIK_U As Byte = 22
Public Const DIK_I As Byte = 23
Public Const DIK_O As Byte = 24
Public Const DIK_P As Byte = 25
Public Const DIK_LBRACKET As Byte = 26
Public Const DIK_RBRACKET As Byte = 27
Public Const DIK_ENTER As Byte = 28
Public Const DIK_LCTRL As Byte = 29
Public Const DIK_A As Byte = 30
Public Const DIK_S As Byte = 31
Public Const DIK_D As Byte = 32
Public Const DIK_F As Byte = 33
Public Const DIK_G As Byte = 34
Public Const DIK_H As Byte = 35
Public Const DIK_J As Byte = 36
Public Const DIK_K As Byte = 37
Public Const DIK_L As Byte = 38
Public Const DIK_SEMICOLON As Byte = 39
Public Const DIK_APOSTROPHY As Byte = 40
Public Const DIK_TILD As Byte = 41
Public Const DIK_LSHIFT As Byte = 42
Public Const DIK_BACKSLASH As Byte = 43
Public Const DIK_Z As Byte = 44
Public Const DIK_X As Byte = 45
Public Const DIK_C As Byte = 46
Public Const DIK_V As Byte = 47
Public Const DIK_B As Byte = 48
Public Const DIK_N As Byte = 49
Public Const DIK_M As Byte = 50
Public Const DIK_COMMA As Byte = 51
Public Const DIK_PERIOD As Byte = 52
Public Const DIK_FOWARDSLASH As Byte = 53
Public Const DIK_RSHIFT As Byte = 54
Public Const DIK_NUMASTRICKS As Byte = 55
Public Const DIK_LALT As Byte = 56
Public Const DIK_SPACE As Byte = 57
Public Const DIK_CAPS As Byte = 58
Public Const DIK_F1 As Byte = 59
Public Const DIK_F2 As Byte = 60
Public Const DIK_F3 As Byte = 61
Public Const DIK_F4 As Byte = 62
Public Const DIK_F5 As Byte = 63
Public Const DIK_F6 As Byte = 64
Public Const DIK_F7 As Byte = 65
Public Const DIK_F8 As Byte = 66
Public Const DIK_F9 As Byte = 67
Public Const DIK_F10 As Byte = 68
Public Const DIK_NUMLOCK As Byte = 69
Public Const DIK_SCRLLOCK As Byte = 70
Public Const DIK_NUM7 As Byte = 71
Public Const DIK_NUM8 As Byte = 72
Public Const DIK_NUM9 As Byte = 73
Public Const DIK_NUMMINUS As Byte = 74
Public Const DIK_NUM4 As Byte = 75
Public Const DIK_NUM5 As Byte = 76
Public Const DIK_NUM6 As Byte = 77
Public Const DIK_NUMPLUS As Byte = 78
Public Const DIK_NUM1 As Byte = 79
Public Const DIK_NUM2 As Byte = 80
Public Const DIK_NUM3 As Byte = 81
Public Const DIK_NUM0 As Byte = 82
Public Const DIK_NUMPERIOD As Byte = 83
Public Const DIK_F11 As Byte = 87
Public Const DIK_F12 As Byte = 88
Public Const DIK_F13 As Byte = 86
Public Const DIK_F14 As Byte = 84
Public Const DIK_F15 As Byte = 85
Public Const DIK_NUMCOMMA As Byte = 91
Public Const DIK_PAUSE As Byte = 116
Public Const DIK_NUMENTER As Byte = 156
Public Const DIK_RCONTROL As Byte = 157
Public Const DIK_NUMFOWARDSLASH As Byte = 181
Public Const DIK_SYSRQ As Byte = 183
Public Const DIK_RALT As Byte = 184
Public Const DIK_HOME As Byte = 199
Public Const DIK_UP As Byte = 200
Public Const DIK_PAGEUP As Byte = 201
Public Const DIK_LEFT As Byte = 203
Public Const DIK_RIGHT As Byte = 205
Public Const DIK_END As Byte = 207
Public Const DIK_DOWN As Byte = 208
Public Const DIK_PAGEDOWN As Byte = 209
Public Const DIK_INSERT As Byte = 210
Public Const DIK_DELETE As Byte = 211
Public Const DIK_LWIN As Byte = 219
Public Const DIK_RWIN As Byte = 220
Public Const DIK_APPS As Byte = 221


Game_Font_Codes.bas...

Code:
'//Game Font Table...
Public GameFontTable(69) As RECT
'//Game Font Codes...
Public Const GFC_A As Byte = 1
Public Const GFC_B As Byte = 2
Public Const GFC_C As Byte = 3
Public Const GFC_D As Byte = 4
Public Const GFC_E As Byte = 5
Public Const GFC_F As Byte = 6
Public Const GFC_G As Byte = 7
Public Const GFC_H As Byte = 8
Public Const GFC_I As Byte = 9
Public Const GFC_J As Byte = 10
Public Const GFC_K As Byte = 11
Public Const GFC_L As Byte = 12
Public Const GFC_M As Byte = 13
Public Const GFC_N As Byte = 14
Public Const GFC_O As Byte = 15
Public Const GFC_P As Byte = 16
Public Const GFC_Q As Byte = 17
Public Const GFC_R As Byte = 18
Public Const GFC_S As Byte = 19
Public Const GFC_T As Byte = 20
Public Const GFC_U As Byte = 21
Public Const GFC_V As Byte = 22
Public Const GFC_W As Byte = 23
Public Const GFC_X As Byte = 24
Public Const GFC_Y As Byte = 25
Public Const GFC_Z As Byte = 26
Public Const GFC_SPACE As Byte = 27
Public Const GFC_0 As Byte = 28
Public Const GFC_1 As Byte = 29
Public Const GFC_2 As Byte = 30
Public Const GFC_3 As Byte = 31
Public Const GFC_4 As Byte = 32
Public Const GFC_5 As Byte = 33
Public Const GFC_6 As Byte = 34
Public Const GFC_7 As Byte = 35
Public Const GFC_8 As Byte = 36
Public Const GFC_9 As Byte = 37
Public Const GFC_ACCENT As Byte = 38
Public Const GFC_TILD As Byte = 39
Public Const GFC_EXCLAIM As Byte = 40
Public Const GFC_AT As Byte = 41
Public Const GFC_POUND As Byte = 42
Public Const GFC_STRING As Byte = 43
Public Const GFC_PERCENT As Byte = 44
Public Const GFC_CAROT As Byte = 45
Public Const GFC_AND As Byte = 46
Public Const GFC_ASTERICKS = 47
Public Const GFC_LPARENTHESES As Byte = 48
Public Const GFC_RPARENTHESES As Byte = 49
Public Const GFC_MINUS As Byte = 50
Public Const GFC_UNDERSCORE As Byte = 51
Public Const GFC_EQUAL As Byte = 52
Public Const GFC_PLUS As Byte = 53
Public Const GFC_COMMA As Byte = 54
Public Const GFC_PERIOD As Byte = 55
Public Const GFC_FSLASH As Byte = 56
Public Const GFC_BSLASH As Byte = 57
Public Const GFC_OR As Byte = 58
Public Const GFC_COLON As Byte = 59
Public Const GFC_QUOTE As Byte = 60
Public Const GFC_SEMICOLON As Byte = 61
Public Const GFC_APOSTROPHY As Byte = 62
Public Const GFC_LCAROT As Byte = 63
Public Const GFC_RCAROT As Byte = 64
Public Const GFC_QUESTION As Byte = 65
Public Const GFC_LBRACKET As Byte = 66
Public Const GFC_RBRACKET As Byte = 67
Public Const GFC_LBRACE As Byte = 68
Public Const GFC_RBRACE As Byte = 69
Public Const GFC_A2 As Byte = 70
Public Const GFC_B2 As Byte = 71
Public Const GFC_C2 As Byte = 72
Public Const GFC_D2 As Byte = 73
Public Const GFC_E2 As Byte = 74
Public Const GFC_F2 As Byte = 75
Public Const GFC_G2 As Byte = 76
Public Const GFC_H2 As Byte = 77
Public Const GFC_I2 As Byte = 78
Public Const GFC_J2 As Byte = 79
Public Const GFC_K2 As Byte = 80
Public Const GFC_L2 As Byte = 81
Public Const GFC_M2 As Byte = 82
Public Const GFC_N2 As Byte = 83
Public Const GFC_O2 As Byte = 84
Public Const GFC_P2 As Byte = 85
Public Const GFC_Q2 As Byte = 86
Public Const GFC_R2 As Byte = 87
Public Const GFC_S2 As Byte = 88
Public Const GFC_T2 As Byte = 89
Public Const GFC_U2 As Byte = 90
Public Const GFC_V2 As Byte = 91
Public Const GFC_W2 As Byte = 92
Public Const GFC_X2 As Byte = 93
Public Const GFC_Y2 As Byte = 94
Public Const GFC_Z2 As Byte = 95


Game_Font_Processes.bas...
Code:
'//Load the image for font1.bmp
Public Sub GameFont_Load_Font1()

    On Local Error GoTo Error_Handler:

    Dim x As Long
    Dim y As Long
    Dim c As Byte

    Set tex_Font1 = GFX_Load_Texture(App.Path + "\Graphics\Fonts\Font1.bmp", _
        1024, 320)
       
    For y = 0 To 320 - 64 Step 64
       
        For x = 0 To 1024 - 64 Step 64
           
            c = c + 1
           
            GameFontTable(c).Left = x
            GameFontTable(c).Top = y
            GameFontTable(c).Right = x + 64
            GameFontTable(c).bottom = y + 64
           
            If c > 68 Then GoTo GFLoad_Finnish
       
        Next x
       
    Next y
       
GFLoad_Finnish:
   
    Set Sprite = D3Dx.CreateSprite(D3DDev)

Exit Sub

Error_Handler:

    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)

    Shutdown

End Sub

'//Display the characters of Font1 using the string Text on the screen...
Public Sub GameFont_Display_Font1(ByVal Text As String, _
    ByVal x As Long, ByVal y As Long, _
    ByVal Sizex As Long, ByVal Sizey As Long, _
    ByVal Center As String)
   
    On Local Error GoTo Error_Handler
   
    Dim i As Long
    Dim GFC As Byte
    Dim s As D3DVECTOR2
    Dim RotCenter As D3DVECTOR2
    Dim Rot As Single
    Dim Offset As D3DVECTOR2
   
    For i = 0 To Len(Text) - 1
   
        GFC = GameFont_TextToCode(Mid(Text, i + 1))
       
        If Center = "left" Then
           
            If GFC < 70 Then
               
                s.x = (Sizex / 64) * 1
                s.y = (Sizey / 64) * 1
                RotCenter.x = Sizex / 2
                RotCenter.y = Sizey / 2
                Rot = 0
                Offset.x = (i * 64) + (x + (Sizex / 2))
                Offset.y = (i * 64) + (y + (Sizey / 2))
               
                Sprite.Draw tex_Font1, GameFontTable(GFC), s, RotCenter, Rot, Offset, dxvbliba.D3DColorRGBA(0, 0, 0, 255)
               
            End If
           
            If GFC >= 70 Then
               
                s.x = (Sizex / 64) * 1
                s.y = ((Sizey / 2) / 64) * 1
                RotCenter.x = Sizex / 2
                RotCenter.y = Sizey / 2
                Rot = 0
                Offset.x = (i * 64) + (x + (Sizex / 2))
                Offset.y = (i * 64) + (y + Sizey)
               
                Sprite.Draw tex_Font1, GameFontTable(GFC - 70), s, RotCenter, Rot, Offset, dxvbliba.D3DColorRGBA(0, 0, 0, 255)
           
            End If
           
        End If
   
    Next i
   
    Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub

'//Convert Text Input to GameFontCode...
Public Function GameFont_TextToCode(ByVal t As String) As Byte

    On Local Error GoTo Error_Handler

    Dim Code As Byte

    If t = "A" Then Code = GFC_A
    If t = "B" Then Code = GFC_B
    If t = "C" Then Code = GFC_C
    If t = "D" Then Code = GFC_D
    If t = "E" Then Code = GFC_E
    If t = "F" Then Code = GFC_F
    If t = "G" Then Code = GFC_G
    If t = "H" Then Code = GFC_H
    If t = "I" Then Code = GFC_I
    If t = "J" Then Code = GFC_J
    If t = "K" Then Code = GFC_K
    If t = "L" Then Code = GFC_L
    If t = "M" Then Code = GFC_M
    If t = "N" Then Code = GFC_N
    If t = "O" Then Code = GFC_O
    If t = "P" Then Code = GFC_P
    If t = "Q" Then Code = GFC_Q
    If t = "R" Then Code = GFC_R
    If t = "S" Then Code = GFC_S
    If t = "T" Then Code = GFC_T
    If t = "U" Then Code = GFC_U
    If t = "V" Then Code = GFC_V
    If t = "W" Then Code = GFC_W
    If t = "X" Then Code = GFC_X
    If t = "Y" Then Code = GFC_Y
    If t = "Z" Then Code = GFC_Z
    If t = " " Then Code = GFC_SPACE
    If t = "0" Then Code = GFC_0
    If t = "1" Then Code = GFC_1
    If t = "2" Then Code = GFC_2
    If t = "3" Then Code = GFC_3
    If t = "4" Then Code = GFC_4
    If t = "5" Then Code = GFC_5
    If t = "6" Then Code = GFC_6
    If t = "7" Then Code = GFC_7
    If t = "8" Then Code = GFC_8
    If t = "9" Then Code = GFC_9
    If t = "`" Then Code = GFC_ACCENT
    If t = "~" Then Code = GFC_TILD
    If t = "!" Then Code = GFC_EXCLAIM
    If t = "@" Then Code = GFC_AT
    If t = "#" Then Code = GFC_POUND
    If t = "$" Then Code = GFC_STRING
    If t = "%" Then Code = GFC_PERCENT
    If t = "^" Then Code = GFC_CAROT
    If t = "&" Then Code = GFC_AND
    If t = "*" Then Code = GFC_ASTERICKS
    If t = "(" Then Code = GFC_LPARENTHESES
    If t = ")" Then Code = GFC_RPARENTHESES
    If t = "-" Then Code = GFC_MINUS
    If t = "_" Then Code = GFC_UNDERSCORE
    If t = "=" Then Code = GFC_EQUAL
    If t = "+" Then Code = GFC_PLUS
    If t = "," Then Code = GFC_COMMA
    If t = "." Then Code = GFC_PERIOD
    If t = "/" Then Code = GFC_FSLASH
    If t = "\" Then Code = GFC_BSLASH
    If t = "|" Then Code = GFC_OR
    If t = ":" Then Code = GFC_COLON
    If t = Chr(34) Then Code = GFC_QUOTE
    If t = ";" Then Code = GFC_SEMICOLON
    If t = "'" Then Code = GFC_APOSTROPHY
    If t = "<" Then Code = GFC_LCAROT
    If t = ">" Then Code = GFC_RCAROT
    If t = "?" Then Code = GFC_QUESTION
    If t = "[" Then Code = GFC_LBRACKET
    If t = "]" Then Code = GFC_RBRACKET
    If t = "{" Then Code = GFC_LBRACE
    If t = "}" Then Code = GFC_RBRACE
    If t = "a" Then Code = GFC_A2
    If t = "b" Then Code = GFC_B2
    If t = "c" Then Code = GFC_C2
    If t = "d" Then Code = GFC_D2
    If t = "e" Then Code = GFC_E2
    If t = "f" Then Code = GFC_F2
    If t = "g" Then Code = GFC_G2
    If t = "h" Then Code = GFC_H2
    If t = "i" Then Code = GFC_I2
    If t = "j" Then Code = GFC_J2
    If t = "k" Then Code = GFC_K2
    If t = "l" Then Code = GFC_L2
    If t = "m" Then Code = GFC_M2
    If t = "n" Then Code = GFC_N2
    If t = "o" Then Code = GFC_O2
    If t = "p" Then Code = GFC_P2
    If t = "q" Then Code = GFC_Q2
    If t = "r" Then Code = GFC_R2
    If t = "s" Then Code = GFC_S2
    If t = "t" Then Code = GFC_T2
    If t = "u" Then Code = GFC_U2
    If t = "v" Then Code = GFC_V2
    If t = "w" Then Code = GFC_W2
    If t = "x" Then Code = GFC_X2
    If t = "y" Then Code = GFC_Y2
    If t = "z" Then Code = GFC_Z2
   
    GameFont_TextToCode = Code
   
    Exit Function
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown
   
End Function


GFX_Init.bas...

Code:
'//Basic Dx8_Initialization
Public Sub Dx8_Init()

    On Local Error GoTo Error_Handler

    '//Set the DirectX8 Object to Dx
    Set Dx = New DirectX8

Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub

Public Sub D3D8_Init()

    On Local Error GoTo Error_Handler

    '//Set D3D8 to create the Direct3D Object using Dx
    Set D3D = Dx.Direct3DCreate()

    '//Use whatever display mode is set at the time of program execution...
    D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
   
    '//Set up the screen.
    D3DPP.hDeviceWindow = Main.hWnd
    D3DPP.BackBufferCount = 1
    D3DPP.BackBufferWidth = 640
    D3DPP.BackBufferHeight = 480
    D3DPP.BackBufferFormat = DispMode.Format
    D3DPP.SwapEffect = D3DSWAPEFFECT_FLIP
    D3DPP.Windowed = 0
    D3DPP.MultiSampleType = D3DMULTISAMPLE_NONE
   
    '//Now set the Direct3D Device with the above information...
    Set D3DDev = D3D.CreateDevice(D3DADAPTER_DEFAULT, _
        D3DDEVTYPE_HAL, _
        Main.hWnd, _
        D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
        D3DPP)

    Set D3DBackbuffer = D3DDev.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)

Exit Sub
   
Error_Handler:
   
    MsgBox D3Dx.GetErrorString(Err.Number) + " in D3D8_Init() under module GFX_Init.bas.", vbOKOnly, Conversion.Error(Err.Number)
   
    Shutdown

End Sub


GFX_Load.bas...

Code:
Public Function GFX_Load_Texture(ByVal filename As String, _
    ByVal width As Long, _
    ByVal height As Long) As Direct3DTexture8

    On Local Error GoTo Error_Handler

    '//Place holder texture for the return of the function's texture
    Dim Texture As Direct3DTexture8
   
    '//Now load it from the file...
    Set Texture = D3Dx.CreateTextureFromFileEx(D3DDev, filename, width, height, _
        D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, _
        D3DX_FILTER_POINT, D3DX_FILTER_POINT, RGB(255, 0, 255), ByVal 0, ByVal 0)
       
    Set GFX_Load_Texture = Texture

    Exit Function

Error_Handler:

    MsgBox D3Dx.GetErrorString(Err.Number), vbOKOnly, Conversion.Error(Err.Number)

Shutdown

End Function


Globals.bas...

Code:
'//Determins whether or not the game is running...
Public bRunning As Boolean
'//DirectX8 Graphics
Public Dx As DirectX8
Public D3D As Direct3D8
Public D3Dx As New D3DX8
Public D3DDev As Direct3DDevice8
Public D3DPP As D3DPRESENT_PARAMETERS
Public DispMode As D3DDISPLAYMODE
Public D3DDevBackbuffer As Direct3DSurface8
Public Sprite As D3DXSprite
'//End of DirectX8 Vertex Variables
'//GFX Textures
'//Font 1
Public tex_Font1 As Direct3DTexture8
'//Direct Input
Public DInput As DirectInput8
Public DIKeyboardDev As DirectInputDevice8
Public DIKeyboardDevAcquired As Boolean
Public DIKeyState As DIKEYBOARDSTATE
Public DIControlerDev(1) As DirectInputDevice8
Public DIControlerDevAcquired(1) As Boolean
Public DIControlerState(1) As DIJOYSTATE


And that's acutally the entire program!

The code you're probably looking for is in GFX_Load.bas and Game_Font_Processes.bas.

I really apreciate all of this help...

I am, however, thinking of just using D3D8 for making flat plains using two triangles put together, texture it with the image, and just go from there because I've been doing some extra searching on other sites and it seems so much easier that way...AND directx4vb.vbgamer.com has tutorials on this stuff that I've always found easiest to read. So for I've seen nothing on sprites and directx8 and those who are stuck with similar issues like me, keep getting told to use D3DVertices and just make plains on the screen without depth...except I think I'll even add depth kind of like Super Smash Bros...Only, it's stick figures and it's completely original from scratch...

But then I would still have to figure out what to do with my custom fonts.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 7:27 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Everything reads fine ... I can see why you're having a hard time finding the problem -- nothing is sticking out as obviously wrong.

Back when I was doing VB6+DirectX, I used to always use a public log-writing sub (WriteToLog "here is the text to write in the log") that would append to a text file that I could review afterward to see where things might be causing trouble.

I would insert a lot of write-to-logs all over my code to write the important values and any loading results.

A couple of things that always seemed to cause me problems ... did everything initialize without problems, especially your font texture -- did it get loaded. Can you draw any portion of it to the screen (eliminate the character-parsing stuff and just draw it like a normal sprite sheet)?

Is the color-setting call to the DXVBLibA working probably and returning a good value? Are all of your variables (including that GameFontTable array) in-scope and giving proper values?

Right before you do the "Sprite.Draw tex_Font1 ..." call, I would write all of the values of the parameters you are feeding to it to a log file or at least to the immediate window.

It's going to be a little over-looked thing that is throwing the whole thing off.

(This is after a quick read-through of your program flow.)

-Matt

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2010 7:41 pm 
Prolific Poster

Joined: Tue Jul 22, 2008 7:26 pm
Posts: 22
Thanx Brykovian...

I will see what I can do to write the log...

Will update as necessary...

MickeyIII



Edit:

Everything seems to be checking out O.K.!

I edited the program to write text to a log file every time I ran the program, generating notes on what was going on with my Objects, Including Dx, D3D, D3DDev, the Local Texture object from GFX_Load, AND tex_Font1!

EVERYTHING IN THE LOG FILE CHECKS OUT!

Even the tex_Font1 seems to contain data OTHER THAN Nothing...

So I must be rendering the sprites incorrectly or something.

Also, I'm NO GOOD at creating log files so there has still got to be some things I'm missing!

I'M SO FRUSTRATED!!!!!!

I've been at this for 2 1/2 weeks now!!!

Please help!

MickeyIII



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group