Space invaders

BlitzMax Forums/BlitzMax Beginners Area/Space invaders

Buckley(Posted 2012) [#1]
This is my first attempt at coding anything really and I did alright up until the bullets. I keep getting this Expecting EndIf error when i run the code, but im not seeing where its needed.

;set graphics
Graphics 640, 480, 16, 2

;creat timer
timer=CreateTimer(30)

;loading player images
img_object = LoadImage("object.png")
img_bullet = LoadImage("bullet.png")

; bullet type
Type bullet
Field x
Field y
End Type


;setting start coords
x = 320
y = 340

;set drawing buffer to back buffer
SetBuffer BackBuffer()

;Start main loop
While Not KeyDown(1)

;Clear screen
Cls

;Draw player
DrawImage img_object,x,y

;Update player positioin
If KeyDown(203) Then x = x - 3
If KeyDown(205) Then x = x + 3

; firing bullets
If KeyHit(57) Then
b, bullet = New bullet
b\x = x
b\y = - 5
EndIf


;update bullets and draw them
For b, bullet = Each bullet
b\y = b\y - 5
DrawImage img_bullet, b\x, b\y
If b\y < 0 Then Delete bullet
Next

;waite timer
WaitTimer(timer)

;Flip drawing screen to monitor
Flip



;end main loop
Wend

End


GfK(Posted 2012) [#2]
Well, you have "b, bullet" twice, which should both be "b.bullet" - that might be the problem. It's probably confusing the compiler.

[edit] this is the blitzmax forum but you seem to be using blitzplus or blitz3d.

Last edited 2012


Buckley(Posted 2012) [#3]
ah sorry. but thanks for the help i finally got it... kind of.


andy_mc(Posted 2012) [#4]
Hmm, this looks familiar!

You can download the complete code for this here:

https://dl.dropbox.com/u/8673694/You%20Tube%20Files/Blitz3D/Tutorial10.zip

Of the closest to where you are with your game right now is here:
https://dl.dropbox.com/u/8673694/You%20Tube%20Files/Blitz3D/Tutorial4.zip

Good luck and let us know if you need any more help! :-)