Oh no, not another silly bug in my code!
Posted: Thu Jul 08, 2004 2:58 pm
I'm making this remake of JetPac, a game I realy enjoyed back in the good old Speccy days.
It was all going well, but I've come along the most dreaded bug of all. The infamous Ever_So_Silly_Bug. The bug in question is: I can shoot my laser in all directions, except when the astronaut is going UP and to the LEFT.
I've read the code over and over again, but no joy. It all seems OK. It is realy driving me mad. I'm sure in the end it will be something absolutely stupid and evident once you see it; a typical conflict between the human brain and the "sillycon" one.
I'll just post a bit of my code here, who knows I might be lucky and someone might quickly see what I can't. My apologies for the not very standard way of coding and the lack of coments.
Code: Select all
ForEach bala()
;ClipSprite(laser,0,0,bala()\ancho,4)
If bala()\dirsp=1
ClipSprite(bala()\laser,250-bala()\ancho,0,bala()\ancho,4)
DisplaySprite(bala()\laser,bala()\x-bala()\ancho,bala()\y)
bala()\x+(12*rfps)
EndIf
If bala()\dirsp=-1
ClipSprite(bala()\laser,0,0,bala()\ancho,4)
DisplaySprite(bala()\laser,bala()\x,bala()\y)
bala()\x-(12*rfps)
EndIf
If bala()\x<0
DisplaySprite(bala()\laser,bala()\x+1024,bala()\y)
EndIf
If bala()\x>1024
DisplaySprite(bala()\laser,bala()\x-1024-bala()\ancho,bala()\y)
EndIf
bala()\ancho+(8*bala()\dir*rfps)
If bala()\ancho>250
bala()\dir=bala()\dir*-1
EndIf
If bala()\ancho<2
DeleteElement(bala())
EndIf
Next
pinta(jman,jugx,jugy)
;=========================================================================================
; PRINT TEXT
;=========================================================================================
If infoon=1
print_fps(fps,rfps)
EndIf
;=========================================================================================
;=========================================================================================
FlipBuffers(1)
;=========================================================================================
; KEYBOARD INPUT
;=========================================================================================
ExamineKeyboard()
If KeyboardReleased(#PB_Key_space)
Select jman
Case astror
AddElement(bala())
bala()\x=jugx+86
bala()\y=jugy+35
bala()\ancho=3
bala()\dir=1
bala()\dirsp=1
bala()\laser=laserr
Case astroru
AddElement(bala())
bala()\x=jugx+86
bala()\y=jugy+35
bala()\ancho=3
bala()\dir=1
bala()\dirsp=1
bala()\laser=laserr
Case astrol
AddElement(bala())
bala()\x=jugx-2
bala()\y=jugy+35
bala()\ancho=3
bala()\dir=1
bala()\dirsp=-1
bala()\laser=laserl
Case astrolu
AddElement(bala())
bala()\x=jugx-2
bala()\y=jugy+35
bala()\ancho=3
bala()\dir=1
bala()\dirsp=-1
bala()\laser=laserl
EndSelect
PlaySound(son)
EndIf
If KeyboardPushed(#PB_Key_right)
jugx+1
jman=astror
EndIf
If KeyboardPushed(#PB_Key_left)
jugx-1
jman=astrol
EndIf
If KeyboardPushed(#PB_Key_up)
jugy-1
Select jman
Case astror
jman=astroru
Case astrol
jman=astrolu
EndSelect
Else
jugy+1
If jugy>640
jugy=640
EndIf
Select jman
Case astroru
jman=astror
Case astrolu
jman=astrol
EndSelect
EndIf