Okay, so I have ice levels and normal levels.
All the levels also have a backdrop of a sky image. I have some code that resets the game world if you die (duh). If you die on a level and lose the last life ,you get respawned a few levels back.
However, when this happens, the game world doesn’t really update perfectly. I’ve noticed that if I die at, let say, lvl 15 which is a normal level, then go back to 12 (ice level) since my lives ran out, then the level doesn’t skin the entities within the game to be that of an ice version. Also, there is no backdrop anymore!!
Death code in the player class (reset world)
FP.world = new GameWorld(Maps.TILESET);
FP.world.recycle(this)
game world code…
public static var isNormalLevel:Boolean = false;
public static var isIceLevel:Boolean = false;
public function GameWorld(tileset:Class)
{
_tileset = tileset
//Reset statics
Surv_Area.activated = false;
Surv_Area2.activated = false;
Surv_Area3.activated = false;
Surv_Gate.opened = false;
Surv_Gate2.opened = false;
Surv_Gate3.opened = false;
isNormalLevel = false;
isIceLevel = false;
if (currentLevel < 13) isNormalLevel = true;
else isIceLevel = true;
}
override public function begin():void
{
isNormalLevel = false;
isIceLevel = false;
if (currentLevel < 13) isNormalLevel = true;
else isIceLevel = true;
FP.volume = 1;
super.begin();
Music.main_theme.stop();
// THIS IS THE BACKDROP CODE ----------------------------------------------
if (currentLevel != 4 && currentLevel != 8 && currentLevel != 9 && currentLevel != 10 && currentLevel != 11) FP.world.add(skyone);
//HUD
add(hud);
//Level
//Set checkpoint
trace ("Current level: " + currentLevel);
//Cam
HeroStats.camCanMove = true;
if (GameWorld.currentLevel < 9) FP.screen.color = 0x4A8EFF;
if (GameWorld.currentLevel >= 9 && GameWorld.currentLevel <= 12) FP.screen.color = 0x100F15;
if (GameWorld.currentLevel >= 13 && GameWorld.currentLevel <= 15) FP.screen.color = 0x4A8EFF;
if (GameWorld.currentLevel >= 17 && GameWorld.currentLevel <= 19) FP.screen.color = 0x000000;
if (GameWorld.currentLevel >= 21 && GameWorld.currentLevel <= 23) FP.screen.color = 0x2E142E;
//Reset lives
if (HeroStats.lives == 0)
{
if (currentLevel <13)
{
_tileset
}
if (currentLevel >= 13 && currentLevel <= 15)
{
loadLevel(Maps.LEVEL_13, Maps.TILESET_ICE);
currentLevel = 13;
}
HeroStats.lives = 3;
}else {
if(currentLevel == 1) loadLevel(Maps.LEVEL_1, _tileset);
if(currentLevel == 2) loadLevel(Maps.LEVEL_2, _tileset);
if(currentLevel == 3) loadLevel(Maps.LEVEL_3, _tileset);
if(currentLevel == 4) loadLevel(Maps.LEVEL_4, _tileset);
if (currentLevel == 5) loadLevel(Maps.LEVEL_5,_tileset);
if (currentLevel == 6) loadLevel(Maps.LEVEL_6, _tileset);
if (currentLevel == 7) loadLevel(Maps.LEVEL_7, _tileset);
if (currentLevel == 8) loadLevel(Maps.LEVEL_8, _tileset);
if (currentLevel == 9) loadLevel(Maps.LEVEL_9, _tileset);
if (currentLevel == 10) loadLevel(Maps.LEVEL_10, _tileset);
if (currentLevel == 11) loadLevel(Maps.LEVEL_11, _tileset);
if (currentLevel == 12) loadLevel(Maps.LEVEL_12, _tileset);
if (currentLevel == 13) loadLevel(Maps.LEVEL_13, Maps.TILESET_ICE);
if (currentLevel == 14) loadLevel(Maps.LEVEL_14, Maps.TILESET_ICE);
if (currentLevel == 15) loadLevel(Maps.LEVEL_15, Maps.TILESET_ICE);
}
//Music
Music.main_theme.loop();
//Rain
if(currentLevel == 9) SoundFX.rain.loop();
if (currentLevel == 10) FP.camera.y = 1;
else if (currentLevel == 11) FP.camera.y = 1;
else FP.camera.y = 76;
GameStats.fireRingSoundPlaying = false;
}
As you can see, I added
isNormalLevel = false;
isIceLevel = false;
if (currentLevel < 13) isNormalLevel = true;
else isIceLevel = true;
both in the first normal function, but also in the begin() function. If I don’t do this, then the ice/normal level checking/setting doesn’t work properly. This is evidence of how shitty of a programmer I am.