Jump to content
IGNORED

Number menu question


atari2600land

Recommended Posts

I'm trying to make a menu with numbers like the Sudoku 2600 games where if you press fire, the number changes. When I put in this code, whenever I press fire, it goes through all 9 numbers in succession rapidly (I only put 3 here in this code to give a sample of what I have so far) until I let go of fire. What do I change from this code to make it once I press fire the number changes only once regardless of how long I keep holding down fire?

 

20 COLUBK=70 : COLUP0=128
25 x=20 : y=20
28 drawscreen
30 player0x=x : player0y=y
40 player0:
 %00100
 %00100
 %00100
 %00100
 %00100
end
51 if joy0fire then goto 53
52 goto 20
53 COLUBK=70 : COLUP0=128
54 x=20 : y=20
55 drawscreen
56 player0x=x : player0y=y
57 player0:
 %11111
 %01000
 %00100
 %10010
 %01100
end
58 if joy0fire then goto 60
59 goto 53
60 COLUBK=70 : COLUP0=128
61 x=20 : y=20
62 drawscreen
63 player0x=x : player0y=y
64 player0:
 %01110
 %10001
 %00110
 %10001
 %01110
end
65 if joy0fire then goto 20
66 goto 60

Link to comment
Share on other sites

Here's one way to do it. I used z as a flag to tell the program when it's okay to advance the number counter. In this case, if z=0, then it's okay to advance. If z=1, then we're waiting for the player to release the fire button before we advance the counter again. Every time you check the fire button, you also check z. Set it to 1 if the fire button's held, set it to 0 if it's not. Depending on how tight you are for variables in your game, you'll probably want to look into implementing the flag with bitwise operators.

 

z = 0
20 COLUBK=70 : COLUP0=128
25 x=20 : y=20
28 drawscreen
30 player0x=x : player0y=y
40 player0:
%00100
%00100
%00100
%00100
%00100
end
51 if joy0fire && z=0 then z=1: goto 53
if !joy0fire && z=1 then z=0
52 goto 20
53 COLUBK=70 : COLUP0=128
54 x=20 : y=20
55 drawscreen
56 player0x=x : player0y=y
57 player0:
%11111
%01000
%00100
%10010
%01100
end
58 if joy0fire && z=0 then z=1: goto 60
if !joy0fire && z=1 then z=0
59 goto 53
60 COLUBK=70 : COLUP0=128
61 x=20 : y=20
62 drawscreen
63 player0x=x : player0y=y
64 player0:
%01110
%10001
%00110
%10001
%01110
end
65 if joy0fire && z=0 then z=1: goto 20
if !joy0fire && z=1 then z=0
66 goto 60

Link to comment
Share on other sites

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