Jump to content
IGNORED

The timer won't work


atari2600land

Recommended Posts

Why won't variable i keep adding by 1 until it gets to 60 and then go to line 110 in this example?

230 if collision(player0,playfield) then goto 232
231 goto 240
232 byte2=$00
 score=score-10000
 byte2=$AA
233 i=i+1
 if i>1 then AUDV0=6 : AUDC0=6 : AUDF0=12
 if i=60 then AUDV0=0 : i=0 : goto 234
 goto 233
234 goto 110

I tried it without the line "goto 233" and I tried "if i<60" and it still won't work. It must be something simple and I'm missing it. The timer (i) indicates whether the sound is playing or not (it's a temporary lose-life sound.)

Edited by atari2600land
Link to comment
Share on other sites

Why won't variable i keep adding by 1 until it gets to 60 and then go to line 110 in this example?

230 if collision(player0,playfield) then goto 232
231 goto 240
232 byte2=$00
 score=score-10000
 byte2=$AA
233 i=i+1
 if i>1 then AUDV0=6 : AUDC0=6 : AUDF0=12
 if i=60 then AUDV0=0 : i=0 : goto 234
 goto 233
234 goto 110

I tried it without the line "goto 233" and I tried "if i<60" and it still won't work. It must be something simple and I'm missing it. The timer (i) indicates whether the sound is playing or not (it's a temporary lose-life sound.)

 

Seems to me, you have tied the playing of the sound to the collision between the player and the playfield.

 

Does this remain the case the entire time your sound is supposed to play?

 

It's a whole second, probably not.

 

You probably should seperate the two, so that the sound can be playing no matter what happens to the player object. That way, if you animate it, or move it in response to the collision, then the sound can run it's course.

Link to comment
Share on other sites

Why won't variable i keep adding by 1 until it gets to 60 and then go to line 110 in this example?

I don't know, on first glance it looks like it should work. But I don't see where you ever initialize i, so you could start by setting "i = 0" right after you "goto 232". And where you say "if i = 60" you might want to change it to say "if i > 59" (just in case i has somehow gotten to be more than 60).

 

MR

Link to comment
Share on other sites

I played around with this a little, and it seems like it cuts the sound off because I hear a tiny "blip" before it goes to 235.

 

230 if collision(player0,playfield) then goto 232
 if collision(player0,player1) then goto 269
231 goto 170

232 i=0
233 i=i+1
 if i<59 then AUDV0=6 : AUDC0=6 : AUDF0=12
 if i>59 then AUDV0=0 : i=0 : goto 235
234 goto 233

235 byte2=$00
 score=score-10000
 byte2=$AA
236 goto 110

Link to comment
Share on other sites

Here's the whole code. What I'm trying to do here is create a Tapeworm-like game called Apples & Oranges in which the apple is going after the orange squares and the round Orange is the "shark". If the apple runs into either the orange or the playfield, I want the screen to freeze for a second ("60") and a sound to play. If the apple gets missile1, I want a short sound (half a second, or "30") to play while the apple and orange are still moving around.

apple.bas.bin

apple.bas

Link to comment
Share on other sites

If the apple runs into either the orange or the playfield, I want the screen to freeze for a second ("60") and a sound to play. If the apple gets missile1, I want a short sound (half a second, or "30") to play while the apple and orange are still moving around.

I think s0c7 hit the nail on the head when he observed that you aren't doing a drawscreen in the loops where the sounds are supposed to be playing. I think those two lines should look like this:

 

233 if i<60 then i=i+1 : AUDV0=6 : AUDC0=12 : AUDF0=12 : drawscreen : goto 233

 

270 if h<29 then h=h+1 : AUDV0=6 : AUDC0=12 : AUDF0=24 : drawscreen : goto 270

MR

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