Skip to content

Commit

Permalink
Autosplitter necessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirrorcult committed Aug 10, 2022
1 parent babb8c8 commit cbac60d
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 7 deletions.
37 changes: 36 additions & 1 deletion src/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,48 @@ package

public static const DEPTH_ENVIRON:int = -5;

public static var pause:Pauser;
public static var _pause:Pauser;

public static function get pause():Pauser
{
return _pause;
}

public static function set pause(pause:Pauser):void
{
_pause = pause;
if (pause == null)
{
GameState = STATE_LEVEL_RUNNING;
}
else
{
GameState = STATE_LEVEL_PAUSED;
}
}

public static const DEPTH_SPEECH:int = -7;

public static var instance:Main;

private var focus:Boolean = true;

/* AUTOSPLITTER QOL */

public static var GameState:uint;
public static var LevelType:uint;
public static var TotalTime:uint;

// Magics for easy autosplitting.
public static const STATE_MAIN_MENU:uint = 0xABCDEF;
public static const STATE_LEVEL_START:uint = 0xBCDEFA;
public static const STATE_LEVEL_RUNNING:uint = 0xCDEFAB;
public static const STATE_LEVEL_PAUSED:uint = 0xDEFABC;
public static const STATE_LEVEL_TRANSITION:uint = 0xFABCDE;
public static const STATE_FINISH:uint = 0xFFFFFF;

public static const TYPE_START_OR_END:uint = 0xAABBCC;
public static const TYPE_NORMAL:uint = 0xDDEEFF;

public function Main()
{
Expand Down
3 changes: 2 additions & 1 deletion src/game/LastKey.as
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ package game
}
Assets.SndGetKey.play();
Assets.setMusic();
(FP.world as Level).countTime = false;
(FP.world as Level)._countTime = false;
Main.GameState = Main.STATE_FINISH;
this.sprite.frame = 0;
this.glow.alpha = 1;
this.player.grabLastKey();
Expand Down
1 change: 1 addition & 0 deletions src/game/cosmetic/Win.as
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package game.cosmetic

public function Win()
{
Main.GameState = Main.STATE_LEVEL_TRANSITION;
this.timer = new Alarm(20,this.done,Tween.ONESHOT);
super();
addTween(this.timer,true);
Expand Down
5 changes: 2 additions & 3 deletions src/game/engine/EndLevel.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ package game.engine

public class EndLevel extends Level
{


public function EndLevel(num:uint)
{
super(0,num);
Main.LevelType = Main.TYPE_START_OR_END;
}

override protected function specifics() : void
Expand All @@ -30,7 +29,7 @@ package game.engine
world = 1;
}
load(new Assets["E" + world]());
countTime = false;
_countTime = false;
}
}
}
31 changes: 30 additions & 1 deletion src/game/engine/Level.as
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,35 @@ package game.engine

public var practice:Boolean;

public var countTime:Boolean;
public var _countTime:Boolean;

public function get countTime():Boolean
{
return _countTime;
}

public function set countTime(value:Boolean):void
{
_countTime = value;
if (value && player && player.active)
{
Main.GameState = Main.STATE_LEVEL_RUNNING;
}
else if (value)
{
// Level just started.
Main.GameState = Main.STATE_LEVEL_START;
}
else
{
Main.GameState = Main.STATE_LEVEL_PAUSED;
}
}

public function Level(mode:uint, num:uint, practice:Boolean = false, str:String = null)
{
super();
Main.LevelType = Main.TYPE_NORMAL;
this.mode = mode;
this.levelNum = num;
this.practice = practice;
Expand Down Expand Up @@ -189,6 +213,11 @@ package game.engine
if(this.player && this.player.active && this.countTime)
{
this.time++;
Main.TotalTime = Main.saveData.time + this.time;
if (!changing)
{
Main.GameState = Main.STATE_LEVEL_RUNNING;
}
if(this.drawTime)
{
this.drawTime.updateTotal();
Expand Down
3 changes: 2 additions & 1 deletion src/game/engine/StartLevel.as
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package game.engine
public function StartLevel(num:uint)
{
super(0,num);
Main.LevelType = Main.TYPE_START_OR_END;
}

override protected function specifics() : void
Expand Down Expand Up @@ -47,7 +48,7 @@ package game.engine
world = 2;
}
load(new Assets["S" + world]());
countTime = false;
_countTime = false;
}

private function makePlayer() : void
Expand Down
2 changes: 2 additions & 0 deletions src/game/menus/MainMenu.as
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ package game.menus

private function gotoMain(m:MenuButton = null) : void
{
Main.GameState = Main.STATE_MAIN_MENU;
var hard:MenuButton = null;
var load:MenuButton = null;
var stats:MenuButton = null;
Expand Down Expand Up @@ -91,6 +92,7 @@ package game.menus

override public function update() : void
{
//Main.GameState = Main.STATE_MAIN_MENU;
super.update();
if(this.options && Input.pressed(Key.DELETE) && Input.check(Key.CONTROL) && Input.check(Key.SHIFT))
{
Expand Down
1 change: 1 addition & 0 deletions src/game/menus/WinMenu.as
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package game.menus
override public function begin() : void
{
super.begin();
Main.GameState = Main.STATE_FINISH;
Main.clearGame();
if(Main.saveData.mode == 0)
{
Expand Down

0 comments on commit cbac60d

Please sign in to comment.