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

2017/4/21

Falling Meteors

ChrisD ChrisD

2017/4/21

#
I am making a game that requires meteors to fall down from the top through the bottom while a space ship is dodging them but i don't know how to get the meteors to fall from out of view from the top and fall past the bottom without getting stuck at the bottom
danpost danpost

2017/4/21

#
ChrisD wrote...
I am making a game that requires meteors to fall down from the top through the bottom while a space ship is dodging them but i don't know how to get the meteors to fall from out of view from the top and fall past the bottom without getting stuck at the bottom
You need an unbounded world for actors to be located outside the viewport. Refer to the World class API documentations and look at the possible constructors to create a world. With an unbounded world, make sure that any object that leave the viewport and are not needed anymore are removed from the world or you might find lagging that increases while the scenario is running
ChrisD ChrisD

2017/4/21

#
By unbounding the world how do i make the space ship unable to go off the screen because that would make my game much easier to complete if the user is able to go off the screen and easily dodge the meteors
danpost danpost

2017/4/21

#
ChrisD wrote...
By unbounding the world how do i make the space ship unable to go off the screen because that would make my game much easier to complete if the user is able to go off the screen and easily dodge the meteors
With the spaceship, after moving, check all four directions. If out of bounds in any, move back in bounds.
ChrisD ChrisD

2017/4/21

#
What do you mean by that?
danpost danpost

2017/4/21

#
ChrisD wrote...
What do you mean by that?
Check the position of the spaceship after it moves. If the x-coordinate and/or y-coordinate values are not within the bounds you set for it, move the spaceship back so that they are within the range of values you set for it.
ChrisD ChrisD

2017/4/21

#
Also i was wondering how do i get multiple meteors to fall increasing in amount for the varying difficulty it increases in
ChrisD ChrisD

2017/4/21

#
ChrisD wrote...
Also i was wondering how do i get multiple meteors to fall increasing in amount for the varying difficulty it increases in
e.g. Level 1 has 20 meteors, level 2 has 30, level 3 has 40, level 4 has 50 and level 5 has 60 and these meteors need to come from the top randomly
You need to login to post a reply.