Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (51 sloc) 1.1 kb
e035428 @whitingjp Adding reseter
authored
1 package
2 {
3 import net.flashpunk.*;
4 import net.flashpunk.graphics.*;
5 import net.flashpunk.masks.*;
6 import net.flashpunk.utils.*;
7
8 import flash.utils.*;
9 import flash.display.BitmapData;
10 import flash.geom.Point;
11 import flash.geom.Rectangle;
12
13 public class Reseter extends Entity
14 {
15 [Embed(source="gfx/reseter.png")]
16 public static const ReseterGfx: Class;
17
18 public var sprite:Spritemap;
19
20 public var timer:int;
21
22 public function Reseter():void
23 {
24 sprite = new Spritemap(ReseterGfx,16,16);
25 sprite.x -= 8;
26 sprite.y -= 8;
27 setHitbox(8,8,4,4);
28 graphic = sprite;
29 type = "reseter";
30 timer = 0;
31 }
32
33 public override function update():void
34 {
35 layer = -y+5;
36 var player_e:Entity = collide("player", x, y);
37 if(player_e)
38 {
89dcdac @whitingjp Resetter sounds
authored
39 if(timer == 0) Main.galaxy.play("resetter");
e035428 @whitingjp Adding reseter
authored
40 var player:Player = Player(player_e);
41 timer++;
42 sprite.frame = timer/8;
89dcdac @whitingjp Resetter sounds
authored
43 if(timer > 120)
e035428 @whitingjp Adding reseter
authored
44 {
45 // do reset
46 timer = 0;
47 Dungeon(FP.world).reset();
48 FP.world.add(player);
89dcdac @whitingjp Resetter sounds
authored
49 Main.galaxy.play("reset");
e035428 @whitingjp Adding reseter
authored
50 }
51 } else
52 {
53 timer = 0;
54 }
55 }
56 }
57 }
Something went wrong with that request. Please try again.