Hello All,
I am playing around with BlitzBasic, I have a guy that walk around on the screen and shoot a bullet. However he only shoots the bullet once, no matter how much I press the spacebar, it only shoots one bullet. How do I get it so that he fires bullets repeadly?
Here is my code
AppTitle("Shoot")
Graphics 1080,720,0,2
Global bull_img
SetBuffer BackBuffer()
Flip
guy_img = LoadImage("guy.bmp")
bull_img = LoadImage("bullet.bmp")
Global guy_x = 10
Global guy_y = 10
Global bull_x = guy_x
Global bull_y = guy_y
Global bull_spd = 0
Global bull_vis = False
MaskImage guy_img,255,255,255
MaskImage bull_img,255,255,255
While Not KeyHit(1)
Cls
Text 1,1,"X:" + bull_x
Text 1,12,"Y:" + bull_y
;Text 1,20,"Time:" + CurrentTime$()
bull_x = bull_x + bull_spd
DrawImage guy_img,guy_x,guy_y
If KeyHit(57) Then
bull_vis = True
bull_spd = 10
EndIf
If KeyHit(203) Then
guy_x = guy_x - 2
EndIf
If KeyHit(205) Then
guy_x = guy_x + 2
EndIf
If guy_x <= 0 Then
guy_x = 0
EndIf
If guy_x >= 1000 Then
guy_x = 0
EndIf
If bull_x >= 1000 Then
bull_spd = 0
bull_vis = False
EndIf
If bull_vis = True Then
DrawImage bull_img,bull_x,bull_y
EndIf
Flip
Wend
I know the code may not be the greatest, but I am trying to get more familiar with BlitzBasic.
|