• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Noob needing help

M

Motivating

Guest
Hello all, I've spent most time trying to figure this problem out with my first game I'm making. It's a simple vertical scroller game where the objective is to avoid the branches. Once you hit a branch the game is over. The piece of code i'm struggling with is when 10 branches go off the screen I want the vspeed of the background and branches (Left_Branch and Right_Branch) to increase to +1. Then after the speed increases after 10 branches I want the Vspeed to increase +1 after 15 branches etc. Here is a picture of the concept and how I'm setting up the code
 
Last edited by a moderator:
M

Motivating

Guest
Here is a video of what I have so far, haven't added collision detection with branches in yet but I will do that once I figure out how to fix the increasing speed issue
 
Last edited by a moderator:
I'm assuming you already know how to detect when a branch leaves the screen, so I wont go into that. So when a branch goes off the screen, it needs to this:

Code:
//all of these variables should be given initial values in a create event
//"counter" is number of branches that have reached bottom
//"target" is how many branches must pass before the speed increases again
if (++counter >= target)
{
  target_add += 5;
  target += target_add;
  branch_speed += 1;
}
All you have to do is set each new branch's vspeed to be equal to branch_speed.

Because the ammount added to target increases every time the condition is met, it wont be long before it takes a very long time for the speed to increase again.
 
M

Motivating

Guest
Only way I know how to detect if a branch leaves the screen if it hits an object. Is there an more efficient way? I feel like I'm setting the gotsagofast variable incorrectly
 
Last edited by a moderator:
M

Motivating

Guest
Would it be bbox_bottom since I want it to detect when it hits the bottom/leaves through the bottom?
 

FrostyCat

Redemption Seeker
bbox_bottom >= room_height is for "hitting the bottom", but bbox_top > room_height is for "having left through the bottom".

Draw a diagram and see for yourself what the difference is.
 
Top