Jump to content

Photo

Pfscore going haywire


9 replies to this topic

#1 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • 80 posts

Posted Wed Dec 14, 2016 3:07 PM

Having a small bit of trouble with my pfscores, I'm doing a silly sumo game where player 1 & 2 mash buttons and try to push each other out of the sumo ring and when a sumo is pushed outside the game pauses for 1 second, removes a pfscore block from the losing player and resets for the next round, but the pfscore just scrolls like mad when a sumo goes outside the ring, any thoughts on what I did wrong?

 

This is the code that handles the sumo positions. When a sumo goes outside q goes from 0 to 1, locking the controls and reduces a pfscore, then goes to q=2 to stop it from the mad pfscore scrolling but it dosn't quite work.

 if player0x=54 then q=1 : pfscore1=pfscore1-1 : q=2
 if player1x=91 then q=1: pfscore2=pfscore2-1 : q=2
 if q>0 then k=k+1
 if q>0 && k=60 then goto begin

 EDIT

Silly me, I forgot it's pfscore1 = pfscore1/4....Works fine now.

On a sidenote, I can't figure out how to limit the firebutton properly so the players can't hold them down?


Edited by Captain Spazer, Wed Dec 14, 2016 3:15 PM.


#2 bogax OFFLINE  

bogax

    Dragonstomper

  • 717 posts

Posted Wed Dec 14, 2016 5:28 PM

On a sidenote, I can't figure out how to limit the firebutton properly so the players can't hold them down?

 

Assuming you mean you want something to happen once when the fire button is pressed and not

happen again until the fire but is (released and) pressed again

check the state of the fire button and if it wasn't pressed last time and is pressed this time

do whatever

save the current state for the next check

 

something like

if joy0fire && previous_state = 0 then do_something = 1
previous_state = 0
if joy0fire then previous_state = 1
 
if do_something then go_do_it
 
; or
 
temp1  = previous_state
previous_state = 0
if joy0fire then previous_state = 1
if temp1 = 0 && previous_state = 1 then go_do_something
 
 

#3 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,231 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Wed Dec 14, 2016 11:09 PM

On a sidenote, I can't figure out how to limit the firebutton properly so the players can't hold them down?


The bB page has a section on that:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#repetition_restrainer_for_fire_button



#4 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • Topic Starter
  • 80 posts

Posted Fri Dec 16, 2016 10:50 AM

Hm, I must be doing something wrong, I can't really get the code to take effect.

 

   ;***************************************************************
   ;
   ;  Fire button check.
   ;
   ;```````````````````````````````````````````````````````````````
   ;  Turns off restrainer bit and skips this section if button is
   ;  not pressed.
   ;
   if !joy0fire then _Bit0_FireB_Restrainer{1} = 0 : goto __Skip_Fire

   ;```````````````````````````````````````````````````````````````
   ;  Skips this section if button hasn't been released after
   ;  being pressed.
   ;
   if _Bit0_FireB_Restrainer{1} then goto __Skip_Fire

   ;```````````````````````````````````````````````````````````````
   ;  Turns on restrainer bit for fire button and turns on
   ;  missile movement bit.
   ;

 if q=0 && joy0fire then a=a+1
 if a=20 then c=c+1
 if c=1 then player0x=player0x+1 : player1x=player1x+1
 if c=1 then c=0

__Skip_Fire

Did I place my code wrong?

 a is for sprite animation

 q is for checking if the sumo is in or outside of the ring
 c is a limit so the sumo takes 1 step when at the last frame of the animation.
 


Edited by Captain Spazer, Fri Dec 16, 2016 11:12 AM.


#5 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • Topic Starter
  • 80 posts

Posted Sat Dec 17, 2016 6:48 AM

How silly of me, I got it working, I did a slight misscalculation on my code. Thanks guys =)


Edited by Captain Spazer, Sat Dec 17, 2016 7:03 AM.


#6 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • Topic Starter
  • 80 posts

Posted Sat Dec 17, 2016 9:38 AM

On a related note to pfscores. I have an issue with this piece of coding.

Basically it checks the positions of the sumos, if one steps out of the ring, the other player wins that round and the next round starts, all fine and dandy. When player 2 wins and player1 has lost 3 rounds, as in pfscore1=0 the game jumps to a victory screen for player2, also works fine and dandy, I did the same so that player1 would have a victory screen too, but it never initializes when pfscore2=0, how come?

 

 q= whether the game is paused or not. If q=0 the game runs, if q>0 then the game pauses.

a=player0's animation.

b=player1's animation.

k= timer for duration of a sound effect.

 

Any insights?

 if player0x<=52 then q=1 : a=30 : pfscore1 = pfscore1/4 : q=2 : player0x=53
 if player1x>=92 then q=1: b=30 : pfscore2 = pfscore2/4 : q=2 : player1x=91
 if q>0 then k=k+1
 if q>0 && k=60 && pfscore1>0 then goto begin
 if q>0 && k=60 && pfscore1=0 then goto P2WINS

 if q>0 && k=60 && pfscore2>0 then goto begin
 if q>0 && k=60 && pfscore2=0 then goto P1WINS

Source: Attached File  Sumosource.bas   4.15KB   22 downloads


Edited by Captain Spazer, Sat Dec 17, 2016 11:14 AM.


#7 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 618 posts
  • Location:Philadelphia, PA

Posted Sat Dec 17, 2016 1:06 PM

It looks like player0 and player1 are using the same q variable.

If you assign a different variable to  player0 and add another If statement it seems to work

 

 

 if player0x<=52 then z=1 : a=30 : pfscore1 = pfscore1/4 : z=2 : player0x=53
 if player1x>=92 then q=1: b=30 : pfscore2 = pfscore2/4 : q=2 : player1x=91
 if q>0 then k=k+1
 if z>0 then k=k+1
 if z>0 && k=60 && pfscore1>0 then goto begin
 if z>0 && k=60 && pfscore1=0 then goto P2WINS
 
 if q>0 && k=60 && pfscore2>0 then goto begin

 if q>0 && k=60 && pfscore2=0 then goto P1WINS 

 

oops it goes to the victory screen, but screws up player2 score.

 


Edited by Mountain King, Sat Dec 17, 2016 1:08 PM.


#8 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • Topic Starter
  • 80 posts

Posted Sat Dec 17, 2016 3:53 PM

Good finding, Mountain King! Everything works perfectly now =)



#9 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,231 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Dec 17, 2016 5:30 PM

You might also want to use bits to keep track of certain off/on conditions.



#10 Captain Spazer OFFLINE  

Captain Spazer

    Star Raider

  • Topic Starter
  • 80 posts

Posted Mon Dec 19, 2016 9:43 AM

Yeah, you'r right RandomTerrain, from now on I'll definetly be using bits more, it's really practical =)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users