Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
BIN  assets/sprites/teenagers.png
BIN  assets/sprites/traps.png
18 components/inventory.js
@@ -45,7 +45,7 @@ Crafty.c("Inventory", {
45 45 z:menuItem._z + 1
46 46 })
47 47 .saveOrigin()
48   - .attr({offset: data.offset, effect: data.effect});
  48 + .attr({offset: data.offset, effect: data.effect, name: key});
49 49
50 50 // ugly hack, means we're going fast
51 51 trap._element.style.opacity = 0;
@@ -66,30 +66,30 @@ Crafty.c("Inventory", {
66 66 });*/
67 67
68 68 Crafty.Inventory = {
69   - Pikes: {
  69 + Wolf: {
70 70 available: 3,
71 71 offsetY: 0,
72   - effect: "piked"
  72 + effect: "wolfed"
73 73 },
74   - Wolf: {
  74 + Acid: {
75 75 available: 3,
76 76 offsetY: 1,
77   - effect: "wolfed"
  77 + effect: "acided"
78 78 },
79 79 Trap: {
80 80 available: 3,
81 81 offsetY: 2,
82 82 effect: "trapped"
83 83 },
84   - Gaz: {
  84 + Pikes: {
85 85 available: 3,
86 86 offsetY: 3,
87   - effect: "gazzed"
  87 + effect: "piked"
88 88 },
89   - Acid: {
  89 + Gaz: {
90 90 available: 3,
91 91 offsetY: 4,
92   - effect: "acided"
  92 + effect: "gazzed"
93 93 }
94 94 };
95 95
26 components/teenager.js
@@ -3,15 +3,29 @@
3 3 Crafty.c("Teenager",{
4 4 movePath:[],
5 5 dead:false,
  6 + speed: 1,
6 7 init: function() {
7 8
8 9 this.requires('2D, DOM, Move, TilePos, Tween, Delay, Afraidable, SpriteAnimation')
9 10 .bind("piked", function() {
10   - this.switchSprite("Piked");
  11 + this.switchSprite( this.name + "Piked");
11 12 this.die( true );
12 13 })
13 14 .bind("wolfed", function() {
14   - this.switchSprite("Wolfed");
  15 + this.switchSprite( this.name + "Wolfed");
  16 + this.die( true );
  17 + })
  18 + .bind("trapped", function() {
  19 + this.switchSprite( "Trapped");
  20 + this.die( true );
  21 + })
  22 + .bind("gazzed", function() {
  23 + this.switchSprite( this.name + "Gazzed");
  24 + this.speed = .5;
  25 + //this.die( true );
  26 + })
  27 + .bind("acided", function() {
  28 + this.switchSprite("Acided");
15 29 this.die( true );
16 30 })
17 31 .bind('teenMoved',function() {
@@ -40,9 +54,9 @@
40 54 });
41 55 },
42 56
43   - switchSprite: function( state ) {
  57 + switchSprite: function( state ) {console.log("Switch" + state)
44 58 this.removeComponent( this.name );
45   - this.addComponent( this.name + state + "Sprite" );
  59 + this.addComponent( state + "Sprite" );
46 60
47 61 return this;
48 62 },
@@ -144,7 +158,7 @@
144 158
145 159 var dest = this.movePath[0];
146 160
147   - this.tween({x:dest._x-16,y:dest._y-32},30);
  161 + this.tween({x:dest._x-16,y:dest._y-32},30 / this.speed);
148 162
149 163 /*if (dest._x < this._x)
150 164 this.move('w',Crafty.tileSize);
@@ -159,7 +173,7 @@
159 173
160 174 this.trigger('teenMoved');
161 175
162   - this.delay(this.initiateMovement,700);
  176 + this.delay(this.initiateMovement,700 / this.speed);
163 177 } else {
164 178 this.tilePos();
165 179 this.isMoving = false;
13 components/teenagers.js
@@ -5,10 +5,10 @@ Crafty.c("Teenagers", {
5 5 $.each( Crafty.Teenagers, function( key, data ) {
6 6 var sprites = {};
7 7 sprites[ key + "Sprite" ] = [ 0, data.offsetY ];
8   - sprites[ key + "SmokedSprite" ] = [ 1, data.offsetY ];
9   - sprites[ key + "PikedSprite" ] = [ 2, data.offsetY ];
10   - sprites[ key + "TrappedSprite" ] = [ 3, data.offsetY ];
11   - sprites[ key + "DeadSprite" ] = [ 4, data.offsetY ];
  8 + sprites[ key + "GazzedSprite" ] = [ 1, data.offsetY ];
  9 + sprites[ key + "PikedSprite" ] = [ 6, data.offsetY ];
  10 + sprites[ key + "WolfedSprite" ] = [ 2, data.offsetY ];
  11 + sprites[ key + "DeadSprite" ] = [ 5, data.offsetY ];
12 12
13 13 Crafty.sprite(104, "assets/sprites/teenagers.png", sprites );
14 14
@@ -26,7 +26,10 @@ Crafty.c("Teenagers", {
26 26
27 27 // Don't forget the corroded sprite
28 28 Crafty.sprite(104, "assets/sprites/teenagers.png", {
29   - CorrodedSprite: [0,6]
  29 + AcidedSprite: [0,5]
  30 + });
  31 + Crafty.sprite(64, "assets/sprites/traps.png", {
  32 + TrappedSprite: [1,2]
30 33 });
31 34 }
32 35 });
7 components/trap.js
@@ -12,7 +12,7 @@
12 12 this.bind("trigger", function( teenager ) {
13 13 if ( this.preventTrigger ) { return; }
14 14
15   - this.unbind("trigger");
  15 + //this.unbind("trigger");
16 16
17 17 // play animation
18 18 /*this.requires("SpriteAnimation")
@@ -24,7 +24,10 @@
24 24 });*/
25 25
26 26 teenager.trigger( this.effect || "die" );
27   - this.destroy();
  27 +
  28 + //if ( this.name != "Trap" ) {
  29 + this.destroy();
  30 + //}
28 31
29 32 });
30 33

No commit comments for this range

Something went wrong with that request. Please try again.