Hi, i wanted to know if it’s possible to find a world used previously or must i change the way i’m designing my game. I’m using a world class for each level,for the start menu and for the game over. But how to do to find the world where the player was before the game over ? Is there any way or must i reset the actual level world and put my game over in it ?
How to find a world used previously
I’m not exactly sure when this would make sense. For my games, I have one World
which loads level files for whichever level the player is on. Then, you switch to this world from anywhere and don’t have to worry about which level you need to load since the world itself handles that. This also makes it way easier to reorder levels later if you want to. I can explain this in more detail if you want.
Typically I create a Globals
object, which can look something like this:
public class Globals
{
public static var currentLevel:uint = 3;
public static var powerups:Array = [];
public static var playerName:String = "Player";
// etc
}
Then, when your player beats a level, you can call Globals.currentLevel++
and it will go up, and you can check the current level like var levelToLoad:uint = Globals.currentLevel
. These are also typically the values you save/load so your player can continue where they left off if they leave your website and come back.
Note that the Globals
class utilizes static
variables so they are accessible from anywhere. I make a similar class, Assets
, to store references to all the game’s assets (graphics, sound, etc.) in one place.
Just another question, do you use something specific to design your levels like ogmo editor or do you design them from scratch with pure code and sprites ?
I personally use Ogmo Editor, although I’m also a Mac user. Ogmo Editor doesn’t run on Macs, so I’ve been thinking about making my own level editor for Mac. I was just thinking about how to design it today, actually.
Ok, that’s what i’m trying to use. If i’ve correctly understood it, i should use 4 layers :
- map (with the level design)
- objects (like ennemies, keys, etc…)
- a grid used for collision detection
- the player starting place
But when i’m using all that can i use other entities like a timer i made ?
It’s been a while since I last used Ogmo - so I might be getting some of the terminology/usage wrong… But here’s what I would do:
- object/entity layer. you can put the “player” on this layer and not need a separate layer for the player’s location. just load the location of the player entity at runtime! of course, put enemies and other entities here as well.
- tile layer. If you want to create a separate grid for collisions, you can do that, or simply use
Tilemap
'screateGrid()
function to do it for you. (personally, I would opt for havingTilemap
generate it for you, but that’s just my opinion. It will make things way easier if you have to make changes later.) - background layer (if necessary)
Of course, you can make things as complicated as you want, with multiple layers and whatnot, but for most games, this should be sufficient.
You can place any entities you want on your map, wherever you want. I’m not sure what your timer does exactly, but since you’re inevitably going to be writing your own map parser, you can do whatever you want with the tilemap you generate.
So suppose you place a timer in your level at coordinates (3, 40). When you parse the generated map file, you can just ignore the coordinates and add a new timer to your world.
Even better: if there’s only one timer per level (like in Mario) and all you care about is how much time is on the timer, you can make it a property of the level itself rather than an object in the level. Then, just load this number when you load your level and create a timer object with that amount of time.
Also, you might want to look into FlashPunk’s Alarm
class. I’m not sure what your timer does but you may not need to reinvent the wheel here.
Sorry for the late reply, but yes it’s exactly like in mario cause i’m working on a platformer with very fast levels (30s per level)