This site requires JavaScript, please enable it in your browser!
Greenfoot back
ChrisD
ChrisD wrote ...

2017/4/27

acceleration

ChrisD ChrisD

2017/4/27

#
public void act()
    {
        if(Greenfoot.getRandomNumber(200)<2)
        {
            addObject(new Meteor(),Greenfoot.getRandomNumber(600)+20,0);
        }
        if(Greenfoot.getRandomNumber(300)<2)
        {
            addObject(new Crystal(),Greenfoot.getRandomNumber(600)+20,0);
        }
      
        {
            timer++;
            if (timer == 1200)
            {
                timer = 0;
                speed++;
                Greenfoot.setSpeed(speed);
            }
        }
        if(Greenfoot.isKeyDown("r"))
        {
            Greenfoot.setWorld(new Level1());
        }
    }
this is the code i currently have for my spawning of Crystals and Meteors as well as the progressive speed the level will be gaining after a while but i was wondering is their a way to place a limit to how fast it can go instead of it going to fast to an extent in which it is hard to play when further in my game?
danpost danpost

2017/4/27

#
Change line 17 to:
if (speed < maxSpeed) speed++;
where maxSpeed is the fastest value you want the speed to be.
ChrisD ChrisD

2017/4/27

#
would you care to recommend a possible speed that would be good
ChrisD ChrisD

2017/4/28

#
anyone care to give any recommendations of a moderate max speed of a game that wouldnt make it impossible for a player to play on later in the game?
danpost danpost

2017/4/28

#
ChrisD wrote...
would you care to recommend a possible speed that would be good
Just play the game to a speed that you feel would be a fair limit (still playable, but difficult). Then pause the scenario and check the value of speed. Then use that value, or something near it, as your limit.
ChrisD ChrisD

2017/5/2

#
calm
You need to login to post a reply.