Jump to content

Photo

Saving highscore problems


3 replies to this topic

#1 Coolcrab OFFLINE  

Coolcrab

    Moonsweeper

  • 325 posts
  • Location:Stockholm

Posted Sun Aug 26, 2018 10:41 AM

I am trying to save the highscore in my game and for some reason it refuses. I am not sure why this is happening, but I suspect that it has to do with the fact that I use score instead of _sc1, _Sc2, _sc3 or the temp variables.

 

When the game is over I send the code to a goto that compares the score to the HS (0 in the beginning) and save it if its higher.


   temp1 = score
   temp2 = score+1
   temp3 = score+2
  

   if temp1 > _a then goto __New_High_Score
   if temp1 < _a then goto __Skip_High_Score

   if temp2 > _b then goto __New_High_Score
   if temp2 < _b then goto __Skip_High_Score

   if temp3 > _c then goto __New_High_Score
   if temp3 < _c then goto __Skip_High_Score
   goto __Skip_High_Score

__New_High_Score

   _a = temp1 : _b = temp2 : _c = temp3


__Skip_High_Score

_a,_b,_c are all set to 0 at the beginning of the game and are not touched outside of this operation. 

 

Then I try to flip back and forth between the current score and the old one by reusing a variable that doesn't get triggered during pause/Game over

__scorehs
 if !_startgame then goto __main
 ;reuse invisible var to flip HS back & forth
 _invisible0 = _invisible0 + 1
 if _invisible0 > 200 then _invisible0 = 0
 
   temp4 = score
   temp5 = score+1
   temp6 = score+2

 if _invisible0 < 100  then scorecolor = $44 
 if _invisible0 = 100  then _rand1=temp4 : _invisible1=temp5 : _speed=temp6 : temp4 = _a : temp5 = _b : temp6 = _c
 if _invisible0 > 100 && _invisible0 < 199  then scorecolor = $66
 if _invisible0 = 200 then temp4 = _rand1 : temp5 = _invisible1 : temp6 = _speed

 return

It seems to work because the color of the score flips back and forth, but both scores are always the current number and all past HS's are gone. 

 

Could anyone take a look at what is going wrong?

Attached Files



#2 Lillapojkenpćön OFFLINE  

Lillapojkenpćön

    Star Raider

  • 85 posts

Posted Sun Aug 26, 2018 2:35 PM

Here's a start, you where not writing anything to the score anywhere so no wonder it doesn't change  :)

Attached File  MonkeyKing0.13.bas   12.69KB   4 downloads



#3 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

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

Posted Sun Aug 26, 2018 3:03 PM

Why not just use what is on the bB page? Those guys worked on it until it was perfect. Screwing with perfection is guaranteed to cause problems.

 

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



#4 Coolcrab OFFLINE  

Coolcrab

    Moonsweeper

  • Topic Starter
  • 325 posts
  • Location:Stockholm

Posted Sun Aug 26, 2018 3:13 PM

Here's a start, you where not writing anything to the score anywhere so no wonder it doesn't change  :)

attachicon.gifMonkeyKing0.13.bas

Ah so you don't have to assign 3 variables to score, its its own variable. That makes everything a lot easier! 

Thanks a lot for the fix. :)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users