Jump to content
  • Advertisement
Sign in to follow this  

Help with speed to platform distance scaling?

This topic is 753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm in the process of creating an endless runner, and one of the features that I've been trying to implement effectively is a distance between platforms that scales with the speed you're running (-hspeed of the platforms). Essentially, the faster you run, the further you can jump. The problem is that I really don't know how to go about doing it. Here is my code for alarm[0] in the controller object that generates the platforms:

var len =irandom_range(global.playerspeed*10,global.playerspeed*16);
var rany = irandom_range(-20,20);
var floor_number = 0;
xx = 16
repeat (len){    
    new_floor = instance_create(room_width+xx,160+rany,obj_floor)
    var yy2 = 0; 
        yy2 += 16
        instance_create(new_floor.x, new_floor.y + yy2, obj_floor);
    floor_number ++
    if (floor_number < len - 4 and floor_number > 4 ){
        //if irandom(100) < 10 instance_create(room_width+xx,new_floor.y - 1, obj_enemy);
    xx += 16;
alarm[0] = ????

I'm essentially trying to get the alarm to set to a scaling value at the end. Does anyone have any ideas? Am I going about the platform generation the wrong way? Any help or advice would be much appreciated!








Oh, and I also found that if the len == 1 global.playerspeed == 3 and alarm[0] == 10, the floors are seemingly spaced apart by their own width like this:


I've been playing around with those ratios but they don't seem to scale up properly. Maybe I'm missing something, though...

Share this post

Link to post
Share on other sites

In a similar project I used this:

float gap_limit = SLOW_GAP_LIMIT * speedRatio;
std::uniform_real_distribution<float> gapRand(0.0f, gap_limit);

Where speedRatio = speed / startingSpeed and SLOW_GAP_LIMIT was a tuned value.


You'll probably have to play with it a bit. That worked for the project it was in because the maximum speed kept it in a sane range. If we had uncapped the speed and somehow a player was able to continue accelerating for long enough it may have stopped working at some point.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!