Jump to content
IGNORED

Timer question


atari2600land

Recommended Posts

I'll try to be as specific as I can with this next question.

How do you activate a timer or time counter thingee?

In this game I'm working on, I want a sprite (player1) to pop up on the screen for a certain amount of time and then disappear. While it's on the screen, I want player0 to touch it. So how do I make the sprite stay on the screen for a certain amount of time using a timer-like thing?

Link to comment
Share on other sites

Having a variable increase by 1 each time the screen is drawn gives you a counter that ticks once per frame.

 

While this is a good idea, I'd like to throw in that you'll want to use a 16 bit value for your timer. (After you add 1 to the low byte, add the carry flag to the high byte.) The reason for this is that an 8 bit value has a maximum value of 255. At 60 frames per second, the counter will roll over in a mere 4.25 seconds! With a 16 bit value, the timer can be extended to 1092 seconds (about 18 minutes). :)

Link to comment
Share on other sites

What is wrong with this program:

1 rem Ants!
2 set smartbranching on
3 rem l = lives counter
4 rem t = timer counter

220 x=60 : y=60 : score=0 : scorecolor = 62 : l=4
221 a = rand : t=0 
222 if a>150 || a<20 then 221 
223 b = rand
224 if b>80 || b<10 then 223
225 if l=0 then goto 359
230 COLUP0 = 198 : COLUBK = 246 : COLUP1 = 0
240 player0x=x : player0y=y : player1x= a : player1y = b
260 player0:
 %01100110
 %00100100
 %00111100
 %11111111
 %00111100
 %00111100
 %00100100
 %01000010
end
270 player1:
 %10111101
 %01111110
 %00011000
 %10111101
 %01111110
 %00011000
 %10111101
 %01111110
end
280 drawscreen
281 t=t+1
282 if t=255 then l=l-1 : goto 221
290 if joy0up then y=y-1
 if y<10 then y=10
 if y>80 then y=80
300 if joy0down then y=y+1
 if y<10 then y=10
 if y>80 then y=80
310 if joy0left then x=x-1
 if x<20 then x=20
 if x>150 then x=150
320 if joy0right then x=x+1
 if x<20 then x=20
 if x>150 then x=150
330 if collision(player0,player1) score=score+1 : goto 221
340 goto 230

359 rem death
360 COLUBK = 0
380 if switchreset then goto 1
385 goto 360

When I compile this, it gives me a bunch of errors, many of them saying "(1121): Syntax Error ". ']' error, no arg on stack

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