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

2017/4/20

How to make a loop

BrianOK BrianOK

2017/4/20

#
I'm making a run and jump game so I need the floor to be constantly moving one direction. I have made my floor width 2000 pixels so it can last about 1 second. I need to be able to loop the codes so that it will be moving until my character hits an object.
1
2
3
4
public void act()
    {
        setLocation(getX() -8 , getY());
    }
very new to coding
danpost danpost

2017/4/20

#
Are you saying that it is like a scrolling world where the character is constantly moving, but stays in the same position on the screen, until it is blocked by some object, at which point the "scrolling" stops? or, is it like "The Impossible Game" where "scrolling" is continuous until the player dies due to contacting an obstacle? BTW: 2000 pixels in about 1 second seems quite fast.
BrianOK BrianOK

2017/4/21

#
danpost wrote...
Are you saying that it is like a scrolling world where the character is constantly moving, but stays in the same position on the screen, until it is blocked by some object, at which point the "scrolling" stops? or, is it like "The Impossible Game" where "scrolling" is continuous until the player dies due to contacting an obstacle? BTW: 2000 pixels in about 1 second seems quite fast.
Like the impossible game
danpost danpost

2017/4/21

#
BrianOK wrote...
I'm making a run and jump game so I need the floor to be constantly moving one direction. I have made my floor width 2000 pixels so it can last about 1 second. I need to be able to loop the codes so that it will be moving until my character hits an object.
What you need to do is create two floor objects and have them leap-frog each other. The world will need to be unbounded to allow actors to be placed outside the main window area. When removing other objects from the world, make sure to use '<' instead of '==' (as chances are they will not land exactly at any particular x-coordinate value).
You need to login to post a reply.