Page 1 of 1

Oh no, not another silly bug in my code!

Posted: Thu Jul 08, 2004 2:58 pm
by MadMax
:(

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. :oops:

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

Posted: Thu Jul 08, 2004 4:09 pm
by Saboteur
Have you tried another keys? Perhaps it's a bad mixing keycode...

Posted: Thu Jul 08, 2004 4:27 pm
by GedB
I can't find anything in the code posted.

Posted: Thu Jul 08, 2004 6:14 pm
by MadMax
Have you tried another keys? Perhaps it's a bad mixing keycode...
Just made a small routine, and you are right, space key is not detected if up and left keys are pressed. :?

Well thanks for your suggestion, at least I can now stop pulling my hair out.

Posted: Fri Jul 09, 2004 1:48 pm
by blueznl
that's why all those games use ctrl and alt :-)

had once a game that i remapped using the space bar for jump, got the same problem :-)