Skip to content

Commit

Permalink
Adding reseter
Browse files Browse the repository at this point in the history
  • Loading branch information
whitingjp committed Dec 18, 2011
1 parent 606c387 commit e035428
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
55 changes: 55 additions & 0 deletions Reseter.as
@@ -0,0 +1,55 @@
package
{
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import net.flashpunk.masks.*;
import net.flashpunk.utils.*;

import flash.utils.*;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

public class Reseter extends Entity
{
[Embed(source="gfx/reseter.png")]
public static const ReseterGfx: Class;

public var sprite:Spritemap;

public var timer:int;

public function Reseter():void
{
sprite = new Spritemap(ReseterGfx,16,16);
sprite.x -= 8;
sprite.y -= 8;
setHitbox(8,8,4,4);
graphic = sprite;
type = "reseter";
timer = 0;
}

public override function update():void
{
layer = -y+5;
var player_e:Entity = collide("player", x, y);
if(player_e)
{
var player:Player = Player(player_e);
timer++;
sprite.frame = timer/8;
if(timer > 80)
{
// do reset
timer = 0;
Dungeon(FP.world).reset();
FP.world.add(player);
}
} else
{
timer = 0;
}
}
}
}
5 changes: 4 additions & 1 deletion Room.as
Expand Up @@ -27,6 +27,7 @@ package
public static const ORB_ON:int = 7;
public static const ORB_GOAL:int = 8;
public static const OTHER:int = 9;
public static const RESETER:int = 10;

[Embed(source="gfx/editor_tile.png")]
public static const EditorTileGfx: Class;
Expand Down Expand Up @@ -118,7 +119,9 @@ package
break;
case OTHER:
e = new Other();
trace("other");
break;
case RESETER:
e = new Reseter();
break;
default:
static_rows[j].setTile(i, j, tile);
Expand Down
3 changes: 3 additions & 0 deletions RoomEditor.as
Expand Up @@ -35,6 +35,9 @@ package
if(Input.pressed(Key.DIGIT_1 + i))
editTile = i;

if(Input.pressed(Key.R))
editTile = Room.RESETER;

var mx:int = Input.mouseX / Room.TILEW;
var my:int = Input.mouseY / Room.TILEW;
if(Input.mouseDown)
Expand Down
Binary file modified gfx/editor_tile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/reseter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/playingwithblocks.xcf
Binary file not shown.

0 comments on commit e035428

Please sign in to comment.