Level creation using types
Blitz3D Forums/Blitz3D Beginners Area/Level creation using types
| ||
Hello, could anyone please help me with this code. Basically i'm trying to draw my levels for my breakout-type game. however, when i run my code, the level is briefly displayed then the screen turns black. Thanks for any help. DeViL PS:Heres my code: Graphics 800,600 SetBuffer BackBuffer() Type brick Field x Field y Field colour End Type r_brick=LoadImage("gfx/red_brick.bmp") b_brick=LoadImage("gfx/red_brick.bmp") g_brick=LoadImage("gfx/red_brick.bmp") y_brick=LoadImage("gfx/red_brick.bmp") Restore level1 For count=0 To 130 b.brick=New brick Read b\colour Next b.brick=First brick While Not KeyHit(1) Cls For y=0 To 9 For x=0 To 12 If b\colour=1 Then DrawImage r_brick,x*ImageWidth(r_brick),y*ImageHeight(r_brick) If b\colour<2 Then b=After b Next Next Flip Wend End .level1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 1,1,1,1,1,1,1,1,1,1,1,1,1 Data 2 |
| ||
After displaying the tiles in the first iteration of the While loop, you then end up pointing to a null in b.brick. To verify that this is happening, run your code in "debug" mode and look at b.brick. Place "b.brick=First brick" after the Flip statement to point to the beginning of your type variable in your loop. |
| ||
Excellent! it works!!! thankyou Andy, i really appriciate your help! ^-^ DeViL |
| ||
No worries. I'm new to types too, and it looked like something I could learn from. Keep plugging away you'll have your game done straight away. |