help with types needed
BlitzPlus Forums/BlitzPlus Programming/help with types needed
| ||
OK i need some help with this code, it wont work for some reason. Const g_ScreenWidth=800, g_ScreenHeight=600 ; Call the BB "Graphics" routine to initialize DirectX Graphics g_ScreenWidth, g_ScreenHeight,32,1 ; Set up BB to support page-flipping SetBuffer BackBuffer() TFormFilter Enable Global bg_image1 bg_image1=LoadImage("bg.bmp") Type player Field shipframes Field shipframe Field shipx Field shipy Field shipdirection End Type player1.player=New player player1\shipx=50 player1\shipy=50 player1\shipframes=LoadImage("ship1.bmp") While Not KeyHit(1) drawbg() updateplayers() drawplayers() Flip Cls Wend Function drawbg() DrawImage bg_image1,0,0 End Function Function updateplayers() If KeyDown(17) Then ;W End If If KeyDown(30) Then ;a End If If KeyDown(31) Then ;s End If If KeyDown(32) Then ;d End If End Function Function drawplayers() ; get a error here about it needing to be a type ?o.0? DrawImage player1\shipframes,0,0 End Function Delete player1 As the comment says "DrawImage player1\shipframes,0,0 " gives me an error about needing to be a type? |
| ||
player1 needs to be global, as you can only use variables made in the function and global variables in a function. And why is "Delete player1" at the end? |
| ||
It would make more sense for readability to put the Delete Player 1 after the Wend and then add an End command just to show where the program stops running. Even though Delete Player1 is on the end at the moment, it will still run because the functions don't run unless they are called. Finally I don't think you need to call Delete player1 as Blitz does it for you, although it is good practice. I prefer a CleanUp function that I call last, and in it I put all my Deletes. |