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

Report as inappropriate.

SPower
SPower presents ...

2013/9/11

World Wrapping

It's hard for me to explain what it does (although danpost was able to do so), so just try it out! Move around using the arrow keys and move to the edges of the world.

The effect you see also works with collision detection.

You may use this if you want, but do give me credit.

The classes you need to use are CutActor and CutWorld (with CutActor being the main class).

I hope you like it, and of course, leave me your thoughts and opinions!

4893 views / 26 in the last 7 days

7 votes | 0 in the last 7 days

Tags: demo with-source world wrapping unbounded

open in greenfoot
Your browser does not support the canvas tag.
danpostdanpost

2013/9/11

I believe it is called world-wrapping (you go off one edge and come back in on the opposite edge).
SPowerSPower

2013/9/11

@danpost Thank you so much! Your 'guess' is proven by this image btw: http://answers.unity3d.com/storage/temp/984-wrapping+world.png
KartoffelbrotKartoffelbrot

2013/9/11

Wow, much nicer than in Tiny Tank!
SPowerSPower

2013/9/11

Thanks! And if you want, you can always update your version to this one.
KartoffelbrotKartoffelbrot

2013/9/11

Thanks for the offer. When I contine working on it I will do that.
KartoffelbrotKartoffelbrot

2013/10/23

I saw your code now. Very nice solution. Maybe it would be easier to make a new method "whatIshouldDo" (only with a better name) in cutActor, which is used in the act method of cutActor. So the subclasses would use whatIShouldDo", by overwriting it, instead of using the act method. So you dont have to write super.act() everytime. Maybe it's easier, especially for larger scenarios. The subclasses can't use the act method if you make it private, but I am not sure if they would use the act method of Actor instead. It's only an idea, no problem if you don't like it.
SPowerSPower

2013/10/23

Well, you will still have to call whatItShouldDo every act cycle, so it would just be another way of saying super.act(), but then with your own addition. This would not be very hard for someone to add himself/herself, so I don't think it's necessary in this demo (although, if many people want it, I'll of course implement it).
KartoffelbrotKartoffelbrot

2013/10/23

I didn't meant it that way. whatIShouldDo() is supposted to replace the act method. It should be placed in cutActor, but it should be empty. The act method in cutActor should call it. So the subclassses will never use act. They use whatIShouldDo(). So the act method of the sublclass will be used every act, but because they haven't any the act method of the subclass (cutActor) will be used, which calls whatIShouldDo().
SPowerSPower

2013/10/24

Ok, now I understand. Give me one moment to implement it :)
A new version of this scenario was uploaded on Thu Oct 24 08:34:44 UTC 2013 Added the method update in CutActor, which should be overwritten instead of the act method. For an example, the Fish class is always there :)

Want to leave a comment? You must first log in.

Who likes this?

Coder12343521 puggo7 FlyingRabidUnicornPig K_wow Entity1037 Kartoffelbrot Busch2207