variable type mismatch????

BlitzPlus Forums/BlitzPlus Beginners Area/variable type mismatch????

Paul A. B.(Posted 2005) [#1]
Graphics 800,600
SetBuffer BackBuffer()


;;;;;make types;;;;;
Type player
Field x
Field y 
Field on
Field image
End Type

Type bullet
Field x
Field y
End Type
;;;;/make types;;;;;

;;;;;initialize types;;;;;;
Global player.player = New player 
player\x = 400
player\y = 300
player\on = 1
player\image = LoadImage("guy.bmp")
;;;;/initialize types;;;;;;




While Not KeyDown(1)
Cls

;;;;;background;;;;;
b = LoadImage("b.bmp")
TileImage b
;;;;/background;;;;;
bullet = LoadImage("bullet.bmp")

;;;;;;draw the player;;;;;;
DrawImage player\image, player\x, player\y
;;;;;;draw the player;;;;;;


If KeyDown(200)
player\y = player\y - 10
ElseIf KeyDown(208)
player\y = player\y + 10
ElseIf KeyDown(203)
player\x = player\x - 10
ElseIf KeyDown(205)
player\x = player\x + 10
ElseIf KeyHit(57)
bulleton = 1
bullet.bullet = New bullet
bullet\x = player\x - 10
bullet\y = player\y - 10

EndIf

If bulleton
bullet\x = bullet\x + 10

DrawImage bullet, bullet\x, bullet\y
EndIf

If player\y = 0 
player\y = 590
ElseIf player\y = 600
player\y = 10
ElseIf player\x = 800
player\x = 10
ElseIf player\x = 0
player\x = 800
EndIf 

Flip
Wend

how can i make it so that if you press space bar twice, you see two bullets instead of the other just dissapearing?? thanks


ozak(Posted 2005) [#2]
You always draw the last bullet created. Go through each of them in a for each loop instead.
For b.bullet = Each bullet
DrawImage bullet, b\x, b\y
Next 

Also you don't need this
If bulleton

Maybe you should change
bullet.bullet = New bullet
bullet\x = player\x - 10
bullet\y = player\y - 10

to
b.bullet = New bullet
b\x = player\x - 10
b\y = player\y - 10

As it could confuse the compiler


Ross C(Posted 2005) [#3]
And your reloading the same image again and again. Never load anything during a game. Its slow :o) You only need to load that resource once.