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

Report as inappropriate.

danpost
danpost presents ...

2013/11/4

Level Changing Demo

This project demonstrates a way to pass an actor and two counters that the actor uses from one world to the next. When the main actor reaches the edge of one world, a new world is introduced to continue in if not outside the larger grid of worlds. A crazy looking 'setRotation' statement is given to make the actor face the appropriate direction when moving. The world class can be subclassed with levels to create different set-ups for each one. The boolean argument in one of the Level world constructors is used to differentiate between the starting world and continuation worlds. This allows the proper operations when the scenario is reset without re-compilation.

2341 views / 14 in the last 7 days

2 votes | 0 in the last 7 days

Tags: demo with-source levels danpost transference world_changing

This scenario is a member of: Demos by danpost


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

2013/11/4

Danpost -- this is EXACTLY what I was looking for. Thank you so much!
askgriffaskgriff

2013/11/4

Quick question: If I want to set up different objects (i.e. walls, food, bad guys) in each room, where would I post those? Something like a section of "addObjects" depending on which room the player is in?
danpostdanpost

2013/11/4

@askgriff, that is one way. Another would be subclassing the Level class and having an array of worlds in the Level class ('room' and 'level' fields would then be the indices of the array).
askgriffaskgriff

2013/11/4

So under Level you would have several worlds -- i.e. L1R1, L1R2, L1R3, etc. And you would set up the array to call those worlds depending on the room the player was entering? I think I'm just not ready for this level yet. I hate being the guy who doesn't understand something in technology. I've been the go-to guy for the last 20 years so it's frustrating.
danpostdanpost

2013/11/4

You would only need to create the array if, and only if, you are not going to re-create the worlds when they are re-entered into. That is, if you want the worlds to be as they were when you main character left them, then you need to save the world in the array, so you can recall that same world when re-entered into. If it does not matter, and the world can create anew again, then the array is not necessary.
askgriffaskgriff

2013/12/9

Okay, looking back at this scenario because it seems to be the closest to what I'm trying to achieve. How do I edit each "world" so that when you walk into a different "room" there is something to do? I'm still confused about that piece.
danpostdanpost

2013/12/9

@askgriff, as it is right now, the levels (worlds) will reset everytime you enter or re-enter one. However, if you still want to do that, you can use a switch in the world constructor to add your objects into each world. swich (level*3+room) { case 0: // add objects for room 101 break; // etc. to case 8: // add objects for room 303 break; }

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

Who likes this?

davemib123 askgriff