Oh no, not another silly bug in my code!

Advanced game related topics
MadMax
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Oct 06, 2003 11:56 am

Oh no, not another silly bug in my code!

Post 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
Saboteur
Enthusiast
Enthusiast
Posts: 273
Joined: Fri Apr 25, 2003 7:09 pm
Location: (Madrid) Spain
Contact:

Post by Saboteur »

Have you tried another keys? Perhaps it's a bad mixing keycode...
[:: PB Registered ::]

Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

I can't find anything in the code posted.
MadMax
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Oct 06, 2003 11:56 am

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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 :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply