Permalink
Browse files

This is my shit

  • Loading branch information...
1 parent 48c073e commit afc0f592a79d645f25435cf50fd96f7d9111270a @louisremi committed Nov 25, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -45,7 +45,7 @@ Crafty.c("Inventory", {
z:menuItem._z + 1
})
.saveOrigin()
- .attr({offset: data.offset, effect: data.effect});
+ .attr({offset: data.offset, effect: data.effect, name: key});
// ugly hack, means we're going fast
trap._element.style.opacity = 0;
@@ -66,30 +66,30 @@ Crafty.c("Inventory", {
});*/
Crafty.Inventory = {
- Pikes: {
+ Wolf: {
available: 3,
offsetY: 0,
- effect: "piked"
+ effect: "wolfed"
},
- Wolf: {
+ Acid: {
available: 3,
offsetY: 1,
- effect: "wolfed"
+ effect: "acided"
},
Trap: {
available: 3,
offsetY: 2,
effect: "trapped"
},
- Gaz: {
+ Pikes: {
available: 3,
offsetY: 3,
- effect: "gazzed"
+ effect: "piked"
},
- Acid: {
+ Gaz: {
available: 3,
offsetY: 4,
- effect: "acided"
+ effect: "gazzed"
}
};
View
@@ -3,15 +3,29 @@
Crafty.c("Teenager",{
movePath:[],
dead:false,
+ speed: 1,
init: function() {
this.requires('2D, DOM, Move, TilePos, Tween, Delay, Afraidable, SpriteAnimation')
.bind("piked", function() {
- this.switchSprite("Piked");
+ this.switchSprite( this.name + "Piked");
this.die( true );
})
.bind("wolfed", function() {
- this.switchSprite("Wolfed");
+ this.switchSprite( this.name + "Wolfed");
+ this.die( true );
+ })
+ .bind("trapped", function() {
+ this.switchSprite( "Trapped");
+ this.die( true );
+ })
+ .bind("gazzed", function() {
+ this.switchSprite( this.name + "Gazzed");
+ this.speed = .5;
+ //this.die( true );
+ })
+ .bind("acided", function() {
+ this.switchSprite("Acided");
this.die( true );
})
.bind('teenMoved',function() {
@@ -39,9 +53,9 @@
});
},
- switchSprite: function( state ) {
+ switchSprite: function( state ) {console.log("Switch" + state)
this.removeComponent( this.name );
- this.addComponent( this.name + state + "Sprite" );
+ this.addComponent( state + "Sprite" );
return this;
},
@@ -141,7 +155,7 @@
var dest = this.movePath[0];
- this.tween({x:dest._x-16,y:dest._y-32},30);
+ this.tween({x:dest._x-16,y:dest._y-32},30 / this.speed);
/*if (dest._x < this._x)
this.move('w',Crafty.tileSize);
@@ -156,7 +170,7 @@
this.trigger('teenMoved');
- this.delay(this.initiateMovement,700);
+ this.delay(this.initiateMovement,700 / this.speed);
} else {
this.tilePos();
this.isMoving = false;
View
@@ -5,10 +5,10 @@ Crafty.c("Teenagers", {
$.each( Crafty.Teenagers, function( key, data ) {
var sprites = {};
sprites[ key + "Sprite" ] = [ 0, data.offsetY ];
- sprites[ key + "SmokedSprite" ] = [ 1, data.offsetY ];
- sprites[ key + "PikedSprite" ] = [ 2, data.offsetY ];
- sprites[ key + "TrappedSprite" ] = [ 3, data.offsetY ];
- sprites[ key + "DeadSprite" ] = [ 4, data.offsetY ];
+ sprites[ key + "GazzedSprite" ] = [ 1, data.offsetY ];
+ sprites[ key + "PikedSprite" ] = [ 6, data.offsetY ];
+ sprites[ key + "WolfedSprite" ] = [ 2, data.offsetY ];
+ sprites[ key + "DeadSprite" ] = [ 5, data.offsetY ];
Crafty.sprite(104, "assets/sprites/teenagers.png", sprites );
@@ -26,7 +26,10 @@ Crafty.c("Teenagers", {
// Don't forget the corroded sprite
Crafty.sprite(104, "assets/sprites/teenagers.png", {
- CorrodedSprite: [0,6]
+ AcidedSprite: [0,5]
+ });
+ Crafty.sprite(64, "assets/sprites/traps.png", {
+ TrappedSprite: [1,2]
});
}
});
View
@@ -12,7 +12,7 @@
this.bind("trigger", function( teenager ) {
if ( this.preventTrigger ) { return; }
- this.unbind("trigger");
+ //this.unbind("trigger");
// play animation
/*this.requires("SpriteAnimation")
@@ -24,7 +24,10 @@
});*/
teenager.trigger( this.effect || "die" );
- this.destroy();
+
+ //if ( this.name != "Trap" ) {
+ this.destroy();
+ //}
});

0 comments on commit afc0f59

Please sign in to comment.