Skip to content

Commit

Permalink
added octopus
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevsrobots committed Mar 30, 2010
1 parent a0ad35e commit bad512e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 27 deletions.
28 changes: 26 additions & 2 deletions src/breath/PlayState.as
Expand Up @@ -78,8 +78,8 @@ package breath {
this.add(oxygen_timer_display);
this.add(story_overlay);

player.x = world.octopus.x;
player.y = world.octopus.y;
player.x = world.octopus.x - 80;
player.y = world.octopus.y - 80;
}

// For testing, skip ahead to the next restore point.
Expand All @@ -104,6 +104,25 @@ package breath {
super.update();
return;
}

if(player.won_game) {
oxygen_timer_display.alpha = 0;
darkness.alpha = 0;

if(player.x < octopus.x - 24) {
player.velocity.x += 80;
} else if(player.x > octopus.x) {
player.velocity.x -= 80;
}
if(player.y > octopus.y) {
player.velocity.y -= 40;
} else if(player.y < octopus.y) {
player.velocity.y += 40;
}

super.update();
return;
}

if(player_dead) {
player_death_timer -= FlxG.elapsed;
Expand Down Expand Up @@ -197,6 +216,11 @@ package breath {
if(world_darkness.alpha < 1 && (world_darkness.alpha > 0 || player.overlaps(world.darkness_init_area))) {
world_darkness.alpha += FlxG.elapsed;
}

// Endgame init
if(player.overlaps(world.endgame_area)) {
player.won_game = true;
}

super.update();
}
Expand Down
54 changes: 29 additions & 25 deletions src/breath/Player.as
Expand Up @@ -16,12 +16,14 @@ package breath {

public var glow:FlxSprite;
public var darkness:FlxSprite;

public var won_game = false;

public function Player(X:Number, Y:Number, darkness:FlxSprite):void {
super(X,Y);

this.darkness = darkness;

glow = new FlxSprite(X,Y,GlowImage);
glow.scale = new FlxPoint(4,4);
glow.alpha = 1;
Expand All @@ -45,33 +47,35 @@ package breath {
}

override public function update():void {
// Physics/movement
if(gravity_on) {
acceleration.y = 420;
drag.x = 500;
drag.y = 0;
} else {
acceleration.y = 40;
drag.x = drag.y = 300;
}
if(!won_game) {
// Physics/movement
if(gravity_on) {
acceleration.y = 420;
drag.x = 500;
drag.y = 0;
} else {
acceleration.y = 40;
drag.x = drag.y = 300;
}

if(push_up) {
acceleration.y = -40;
}
if(push_up) {
acceleration.y = -40;
}

if(FlxG.keys.LEFT) {
facing = LEFT;
velocity.x -= _move_speed * FlxG.elapsed;
} else if(FlxG.keys.RIGHT) {
facing = RIGHT;
velocity.x += _move_speed * FlxG.elapsed;
}
if(FlxG.keys.LEFT) {
facing = LEFT;
velocity.x -= _move_speed * FlxG.elapsed;
} else if(FlxG.keys.RIGHT) {
facing = RIGHT;
velocity.x += _move_speed * FlxG.elapsed;
}

if(!gravity_on) {
if(FlxG.keys.UP) {
velocity.y -= _move_speed * FlxG.elapsed;
} else if(FlxG.keys.DOWN) {
velocity.y += _move_speed * FlxG.elapsed;
if(!gravity_on) {
if(FlxG.keys.UP) {
velocity.y -= _move_speed * FlxG.elapsed;
} else if(FlxG.keys.DOWN) {
velocity.y += _move_speed * FlxG.elapsed;
}
}
}

Expand Down

0 comments on commit bad512e

Please sign in to comment.