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

Comments for Infinite Scrolling World

Return to Infinite Scrolling World

A new version of this scenario was uploaded on Tue May 07 07:18:03 UTC 2013 Added a superclass for fixed objects that aren't moved by the scrolling system.
A new version of this scenario was uploaded on Tue May 07 07:21:53 UTC 2013 Added discriptions for the fixed objects.
RudiRudi

2013/5/27

how can i see the source code???
Click "Open in Greenfoot" download and open the program in Greenfoot, then you can look at the code from inside greenfoot. If you can't figure out how to go from documentation to code, go to the top right corner of the window, and click on the dropdown button that says "Documentation", then click on "Source Code". Or you could press CTR+J
RudiRudi

2013/5/27

ok, thanks...
KartoffelbrotKartoffelbrot

2013/8/13

So hab das ganze jetzt auf mein Szenario umgemünzt. War dann auch gar nicht mal so schwer.
sanoysanoy

2014/1/11

how could make it that if you limite the scrolling width the actor isnt stoping before reaching the end of the world
You mean that the actor moves on so that he's not in the middle of the world anymore when he reaches the edge of the scrolling world? Well this is not provided in this scrolling system. But if you use my Multi Scrolling Engine (http://www.greenfoot.org/scenarios/10595) it should work. Using the Multi Scrolling Engine you can change the scrolling system while playing. So you could change it so that the actor is no longer the center of the scrolling system.
sanoysanoy

2014/1/11

thanks Gevater_Tod4711
sanoysanoy

2014/1/11

i thought the actor should remain in the middle, until he reaches the end of the world. Then he shoul move normal. If he moves back he should be again in the middle. How do i do that.
Therefore you need to change the scrolling system using the Multi Scrolling Engine. I'm currently working on this engine and on exactly this problem. If you give me a fiew minutes to add some funktions to the engine I can tell you how to do this.
sanoysanoy

2014/1/11

thanks
Ok it took a bit longer than I thought but I got it working now. If you add the following code to your actor it should work: if (((MultiScrollingWorld) getWorld()).getTotalXMovement() >= MultiScrollingWorld.WORLD_WIDTH/2 - 10) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.NO_SCROLLING_SYSTEM); } else if (((MultiScrollingWorld) getWorld()).getTotalXMovement() <= -MultiScrollingWorld.WORLD_WIDTH/2 + 10) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.NO_SCROLLING_SYSTEM); } else if (((MultiScrollingWorld) getWorld()).getTotalYMovement() >= MultiScrollingWorld.WORLD_HEIGHT/2 - 10) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.NO_SCROLLING_SYSTEM); } else if (((MultiScrollingWorld) getWorld()).getTotalYMovement() <= -MultiScrollingWorld.WORLD_HEIGHT/2 + 10) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.NO_SCROLLING_SYSTEM); } if (((MultiScrollingWorld) getWorld()).getTotalXMovement() < 0 && getX() < getWorld().getWidth()/2) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.CENTRAL_ACTOR_SCROLLING_SYSTEM); } else if (((MultiScrollingWorld) getWorld()).getTotalXMovement() > 0 && getX() > getWorld().getWidth()/2) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.CENTRAL_ACTOR_SCROLLING_SYSTEM); } if (((MultiScrollingWorld) getWorld()).getTotalYMovement() < 0 && getY() < getWorld().getHeight()/2) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.CENTRAL_ACTOR_SCROLLING_SYSTEM); } else if (((MultiScrollingWorld) getWorld()).getTotalYMovement() > 0 && getY() > getWorld().getHeight()/2) { ((MultiScrollingWorld) getWorld()).setScrollingSystem(MultiScrollingWorld.CENTRAL_ACTOR_SCROLLING_SYSTEM); } This will cause that there is no scrolling system used when the actor touches the edge of the world so he's able to move everywhere.
sanoysanoy

2014/1/11

thx, but it wont help me, because i use another scenario ( this one) so i would have to recreate evrything in your scenario
sanoysanoy

2014/1/11

it works thank you
sanoysanoy

2014/1/11

@Gevater_tod how could i remove the blck squares with thee red letters
They are just used to visualize some things. You can delete them in the act method of the class ExampleWorld. If you delete the whole run method and change the super call in the constructor to this: super(800, 450, 1, 2000, 2000, MultiScrollingWorld.CENTRAL_ACTOR_SCROLLING_SYSTEM, false); it should work.
sanoysanoy

2014/1/11

Thx
sanoysanoy

2014/1/11

Just a lat question How could i diable all systems eycept for the actor in the middle System
The scrolling system usually stays the same untill you change it. In the demo I uploaded the scrolling system is changed by clicking on the worlds background. If you delete the code that causes this (in the run method of the class ExampleWorld) the scrolling system will not change until you change it manually or by moving to the side of the world.
lhtait2608lhtait2608

2015/10/9

i copied and pasted all the coding but on the first line of the coding where it says gettotalxmovement down the bottom it says it cannot find the symbol.
AreebRazaAreebRaza

2016/5/18

I found a bug, if I keep on scrolling for a long time it eventually slows down the movement
tkieseltkiesel

2017/2/17

@AreebRaza: There are some loops in the createTextur() method of the ScrollingWorld class that might take a long time to complete when the player is very far afield. Here's a version without the loops that uses mod math to do the same job. /** * Creates a moving textur on the background image of the world. */ protected final void createTextur() { // Higher performance version: int x = totalXMovement; x %= textur.getWidth(); if ( x > 0 ) x -= textur.getWidth(); int y = totalYMovement; y %= textur.getHeight(); if ( y > 0 ) y -= textur.getHeight(); getBackground().clear(); for (int i = x; i < getWidth(); i += textur.getWidth()) { for (int j = y; j < getHeight(); j += textur.getHeight()) { getBackground().drawImage(textur, i, j); } } }
LMTLMT

2018/3/28

How can I download the scenario?
XolkiyrXolkiyr

2018/4/25

Alright, say I wanted to use this to generate a world as people enter the different areas but keep track of where everything was... How would I do that?
XolkiyrXolkiyr

2018/6/19

What I mean is, how when the player dies they go back to the original 0,0 and move everything in the same amounts.
danpostdanpost

2018/6/19

@Xolkiyr, you may want to start a discussion on that.