This site requires JavaScript, please enable it in your browser!
Greenfoot back
Çðæyœn
Çðæyœn wrote ...

2019/5/26

Scrolling Screen

Çðæyœn Çðæyœn

2019/5/26

#
I am making a space game where a spaceship can be moved around the screen to dodge asteroids while the background of the screen is scrolling. My issue is I have no idea how to make a scrolling screen that scrolls indefinitely at a constant rate, meaning that the movement of actors will not affect scrolling. On an unrelated note, I am also trying to figure out how to make an array list for asteroids, since the screen will scroll infinitely and asteroids will be randomly generated to be in random locations for the spaceship to avoid (asteroids cannot overlap and cannot be closer than a certain distance from one another). Any help is appreciated.
danpost danpost

2019/5/26

#
Çðæyœn wrote...
My issue is I have no idea how to make a scrolling screen that scrolls indefinitely at a constant rate, meaning that the movement of actors will not affect scrolling.
Please see my Scrolling Tutorial scenario.
On an unrelated note, I am also trying to figure out how to make an array list for asteroids, since the screen will scroll infinitely and asteroids will be randomly generated to be in random locations for the spaceship to avoid (asteroids cannot overlap and cannot be closer than a certain distance from one another). Any help is appreciated.
You do not need to keep a list (you can easily generate one when needed using the getObjects method). Best is probably to make use of the addedToWorld method provided in the Actor class. You can use a while loop to randomly move the object until none are in range (using the getObjectsInRange(...).isEmpty() test).
You need to login to post a reply.