Jump to content
IGNORED

What is the best way to tell when the score reaches the next thousand?


Random Terrain

Recommended Posts

I need to go back through my program to see if I can free up any variables, but I've done that as I went along, so there is a good chance that I'm down to my last variable and I'll probably need it later. Is there a good way, without wasting a variable, to tell if the score has reached the next thousand so the player can get a bonus? Once the thousands spot hits nine, it will go back to zero the next time the player earns another thousand, so that could mess things up if not done right.

 

I reread the section about the score on the bB page, but I'm not sure how to convert the examples to what I need. Is there an easy, big brain way to give the player a bonus every time he or she earns another thousand points? I'm just not smart enough to figure it out.

 

 

Thanks.

 

 

Update:

 

I finally got around to making an example for this on the bB page based what on what RevEng posted below:

 

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

Link to comment
Share on other sites

I don't see a way to do it without using memory, but you might be able to get away with using a temp variable if your score addition happens in a fairly compact chunk of the code...

 

dim sc1=score+1

rem ** save the thousands digit without the hundreds digit.
rem ** do this right before your score additions routines...
temp6=sc1&$f0


rem ** score addition routines happen here. nothing that overwrites
rem ** temp5 or temp6 can happen here. That includes "drawscreen".


rem ** now check if the thousands digit changed...
temp5=sc1&$f0
if temp5<>temp6 then gosub bonuslife

 

...this assumes that your score addition routine won't ever add more than 1000. If that's not true, you could expand the above routine to also track the ten thousands digit.

Edited by RevEng
  • Like 1
Link to comment
Share on other sites

I don't see a way to do it without using memory, but you might be able to get away with using a temp variable if your score addition happens in a fairly compact chunk of the code...

 

dim sc1=score+1

rem ** save the thousands digit without the hundreds digit.
rem ** do this right before your score additions routines...
temp6=sc1&$f0


rem ** score addition routines happen here. nothing that overwrites
rem ** temp5 or temp6 can happen here. That includes "drawscreen".


rem ** now check if the thousands digit changed...
temp5=sc1&$f0
if temp5<>temp6 then gosub bonuslife

 

...this assumes that your score addition routine won't ever add more than 1999. If that's not true, you could fix the above routine by tracking the ten thousands digit also.

I use the following, so I changed sc1 to sc2 in your example so it would work:

 

   dim sc1=score
  dim sc2=score+1
  dim sc3=score+2

 

Seems to be working great so far. I tried different values for the score and everything I tried worked perfectly. It's also nice that I don't have to waste a variable.

 

Thanks for the help. There's no way I would have figured that out on my own.

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...