IGNORED

What's wrong here..

Recommended Posts

I'm working on my adult game. I have the following in the beginning:

``` dim gobble = n

n = 5```

That is supposed to control speed.

Later on in the game I have the following in my loop to slow down or speed up the game:

``` x = x + 1
if x < gobble then goto waitloop```

When I do that my game FLIES.. really fast. The following DOES work and game runs at nice speed to start off:

``` x = x + 1
if x < 5 then goto waitloop```

What I need is when you "gobble" something in my game it speeds up the game for about 10 seconds and does some other stuff. I have all that working except the speed. It awards you extra points for gobbling, does some stuff for about 10 seconds, then goes back to normal, but I can't get the speed thing to work because right off the bat it's at super fast speed.

Should "if x < gobble then goto waitloop" work even?

What about something like "if x < 5 ( - gobble ) then goto waitloop"? <--- Not sure exactly how that works.. I just made it up.

Edited by yuppicide
Share on other sites

I'm working on my adult game. I have the following in the beginning:

``` dim gobble = n

n = 5```

That is supposed to control speed.

Later on in the game I have the following in my loop to slow down or speed up the game:

``` x = x + 1
if x < gobble then goto waitloop```

When I do that my game FLIES.. really fast. The following DOES work and game runs at nice speed to start off:

``` x = x + 1
if x < 5 then goto waitloop```

What I need is when you "gobble" something in my game it speeds up the game for about 10 seconds and does some other stuff. I have all that working except the speed. It awards you extra points for gobbling, does some stuff for about 10 seconds, then goes back to normal, but I can't get the speed thing to work because right off the bat it's at super fast speed.

Should "if x < gobble then goto waitloop" work even?

What about something like "if x < 5 ( - gobble ) then goto waitloop"? <--- Not sure exactly how that works.. I just made it up.

"if x < gobble then goto waitloop" should do what it says, but whether it will do what you're trying to accomplish is another matter, because that will depend on the rest of your code. It's hard to say what a single line of code will do without being able to see it in the context of the whole program-- unless the line of code is doing something simple, like "x = x + 1," and the question is equally simple, like "will this line of code cause x to be incremented by 1?"

Here's a short example of a playfield that scrolls at a somewhat slow speed, but speeds up while the fire button of joystick0 is held down, and reverts back to the slower speed several seconds after you release the fire button

```   dim frame = a
dim speed = b
dim boost = c

frame = 0 : boost = 0 : COLUBK = \$00 : scorecolor = \$00
COLUPF = \$06

playfield:
................................
................................
................................
................................
................................
........XX................XX....
........XX............XX..XX....
XX......XXXX..........XX..XXXX..
XX..XX..XXXX..XX....XXXX..XXXX..
XXXXXXXXXXXX..XXXX..XXXXXXXXXX..
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

loop

drawscreen

if boost <> 0 then boost = boost - 1
if joy0fire then boost = 255
rem * boost is decremented first (if it isn't already 0)
rem * so it won't decrement as soon as it's triggered--
rem * i.e., if the two ifs were swapped around, then
rem * boost would decrement to 254 as soon as it was set to 255

if boost = 0 then speed = 9 else speed = 3
rem * this sets the scrolling speed based on the boost setting

frame = frame + 1
if frame < speed then goto loop
rem * this keeps drawing the screen without scrolling any further
rem * as long as the frame counter is less than the speed setting

frame = 0
rem * once the frame counter has reached the speed setting,
rem * we need to reset the frame counter back to 0

pfscroll left
goto loop```

That's just one way you could do it, and you could change the triggering (boosting) event to something else, such as a collision between player0 and player1. In this example, the maximum length of time that the speed boost will remain in effect (after the triggering event has stopped occurring) will be a little longer than 4 seconds, since 1 second equals about 60 frames, and 255 divided by 60 is 4.25. So this example wouldn't work for a 10 second speed boost.

Michael

scrolling_speed.bas

scrolling_speed.bas.bin

Share on other sites

It's the "tube" code for my adult game you helped me with.

If I do "if x < 5 then goto waitloop" it works fine, slower.. if I change that to 3, it moves the playfield faster. I should be able to change that number to gobble. In the beginning I've dimmed gobble = n, I've set n to 5. At some point in the game it does a "gobble = gobble - 2" for a short period of time to speed up a bit, then after so many seconds it does "gobble = gobble + 2" to set it back to normal.

What happens, though is, when I start the program it's treating x as if it was 1 and it's going super fast. I'll look for an error somewhere when I get home.

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.