mirror of
https://github.com/IllusionMan1212/adventures-of-kuroneko.git
synced 2026-10-24 02:12:36 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
ig.module(
|
||||
'game.entities.cheese'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity',
|
||||
'game.entities.kuroneko',
|
||||
)
|
||||
.defines(function() {
|
||||
EntityCheese = ig.Entity.extend({
|
||||
|
||||
collides: ig.Entity.COLLIDES.LITE,
|
||||
|
||||
size: {x: 32, y: 20},
|
||||
offset: {x: 0, y: 12},
|
||||
gravityFactor: 0,
|
||||
|
||||
animSheet: new ig.AnimationSheet('media/cheese.png', 32, 32),
|
||||
|
||||
init: function(x, y, settings) {
|
||||
this.parent(x, y, settings);
|
||||
|
||||
this.addAnim('normal', 1, [0]);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.parent();
|
||||
|
||||
this.currentAnim = this.anims.normal;
|
||||
},
|
||||
|
||||
collideWith: function(other, axis) {
|
||||
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
|
||||
if (other instanceof EntityKuroneko) {
|
||||
this.kill();
|
||||
if (this.player.health < 4) {
|
||||
this.player.health += 1;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
kill: function() {
|
||||
ig.game.removeEntity(this);
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
ig.module(
|
||||
'game.entities.easteregg'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity',
|
||||
'game.entities.kuroneko',
|
||||
'game.entities.cheese',
|
||||
)
|
||||
.defines(function() {
|
||||
EntityEasteregg = EntityCheese.extend({
|
||||
|
||||
animSheet: new ig.AnimationSheet('media/easteregg.png', 32, 32),
|
||||
|
||||
collideWith: function(other, axis) {
|
||||
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
|
||||
if (other instanceof EntityKuroneko) {
|
||||
this.kill();
|
||||
ig.game.score += 10000;
|
||||
if (this.player.health < 4) {
|
||||
this.player.health += 4;
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
ig.module(
|
||||
'game.entities.endgame'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity',
|
||||
'game.entities.kuroneko',
|
||||
'game.entities.nextlevel',
|
||||
)
|
||||
.defines(function() {
|
||||
EntityEndgame = EntityNextlevel.extend({
|
||||
check: function( other ) {
|
||||
if(other instanceof EntityKuroneko){
|
||||
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
|
||||
this.player.currentAnim = this.player.anims.nothing;
|
||||
this.player.speed = 0;
|
||||
if (ig.game.score == 0 || ig.game.score == 10000) {
|
||||
setTimeout(function() {ig.game.loadLevel( LevelGoodend );}.bind(this), 1000);
|
||||
} else {
|
||||
setTimeout(function() {ig.game.loadLevel( LevelBadend );}.bind(this), 1000);
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,132 @@
|
||||
ig.module(
|
||||
'game.entities.kuroneko'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity'
|
||||
)
|
||||
.defines(function() {
|
||||
|
||||
EntityKuroneko = ig.Entity.extend({
|
||||
collides: ig.Entity.COLLIDES.ACTIVE,
|
||||
|
||||
size: {x: 24, y: 28},
|
||||
offset: {x: 4, y: 4},
|
||||
gravityFactor: 4,
|
||||
maxVel: {x: 150, y: 520},
|
||||
speed: 400,
|
||||
jump_height: 800,
|
||||
friction: {x: 500, y: 0},
|
||||
health: 4,
|
||||
type: ig.Entity.TYPE.A,
|
||||
is_dead: false,
|
||||
flip: false,
|
||||
kuro: true,
|
||||
|
||||
animSheet: new ig.AnimationSheet('media/kuroneko.png', 32, 32),
|
||||
jumpSheet: new ig.AnimationSheet('media/kuroneko-jump.png', 46, 32),
|
||||
|
||||
init: function(x, y, settings) {
|
||||
this.parent(x, y, settings);
|
||||
|
||||
this.invincibleTimer = new ig.Timer();
|
||||
|
||||
this.addAnim('idle', 1, [0]);
|
||||
this.addAnim('walk', 0.13, [2,3,4,5,4,3]);
|
||||
this.addAnim('idle_shiro', 1, [6]);
|
||||
this.addAnim('walk_shiro', 0.13, [8,9,10,11,10,9]);
|
||||
this.addAnim('nothing', 1, [20]);
|
||||
this.anims.jump = new ig.Animation(this.jumpSheet, 1, [0]);
|
||||
this.anims.jump_shiro = new ig.Animation(this.jumpSheet, 1, [1]);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.parent();
|
||||
|
||||
this.currentAnim.flip.x = this.flip;
|
||||
|
||||
//Handle movement
|
||||
if (ig.input.state('right')) {
|
||||
this.accel.x = this.speed;
|
||||
this.flip = false;
|
||||
} else if (ig.input.state('left')) {
|
||||
this.accel.x = -this.speed;
|
||||
this.flip = true;
|
||||
} else {
|
||||
this.accel.x = 0;
|
||||
}
|
||||
if (ig.input.pressed('up') && this.standing) {
|
||||
if (this.vel.y == 0) {
|
||||
this.vel.y -= this.jump_height;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pos.y > 640 - 32) {
|
||||
this.kill();
|
||||
}
|
||||
|
||||
//Handle animations
|
||||
if (this.kuro) {
|
||||
if (this.vel.y != 0 && !this.standing) {
|
||||
this.offset = { x: 10, y: 4 };
|
||||
this.currentAnim = this.anims.jump;
|
||||
} else if (this.vel.x != 0 && this.standing) {
|
||||
this.offset = { x: 4, y: 4 };
|
||||
this.currentAnim = this.anims.walk;
|
||||
} else {
|
||||
this.offset = { x: 4, y: 4 };
|
||||
this.currentAnim = this.anims.idle;
|
||||
}
|
||||
} else {
|
||||
if (this.vel.y != 0 && !this.standing) {
|
||||
this.offset = { x: 10, y: 4 };
|
||||
this.currentAnim = this.anims.jump_shiro;
|
||||
} else if (this.vel.x != 0 && this.standing) {
|
||||
this.offset = { x: 4, y: 4 };
|
||||
this.currentAnim = this.anims.walk_shiro;
|
||||
} else {
|
||||
this.offset = { x: 4, y: 4 };
|
||||
this.currentAnim = this.anims.idle_shiro;
|
||||
}
|
||||
}
|
||||
|
||||
//Change color on different BGs
|
||||
if (ig.game.currentLevel == LevelLevel1) {
|
||||
if (this.pos.x > 832 && this.pos.x < 1568) {
|
||||
this.kuro = false;
|
||||
} else if (this.pos.x > 1568 && this.pos.x < 2368) {
|
||||
this.kuro = true;
|
||||
} else if (this.pos.x > 2368) {
|
||||
this.kuro = false;
|
||||
} else {
|
||||
this.kuro = true;
|
||||
}
|
||||
} else if (ig.game.currentLevel == LevelLevel2) {
|
||||
if (this.pos.x > 1023 && this.pos.x < 2016) {
|
||||
this.kuro = false;
|
||||
} else if (this.pos.x > 2016 && this.pos.x < 3008) {
|
||||
this.kuro = true;
|
||||
} else if (this.pos.x > 3008 && this.pos.x < 4000) {
|
||||
this.kuro = false;
|
||||
} else if (this.pos.x > 4000 && this.pos.x < 4992) {
|
||||
this.kuro = true;
|
||||
} else if (this.pos.x > 4992 && this.pos.x < 5984) {
|
||||
this.kuro = false;
|
||||
} else if (this.pos.x > 5984) {
|
||||
this.kuro = true;
|
||||
} else {
|
||||
this.kuro = true;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
kill: function() {
|
||||
this.is_dead = true;
|
||||
ig.game.removeEntity(this);
|
||||
ig.game.score = 0;
|
||||
|
||||
setTimeout(function() {ig.game.loadLevel(LevelGameover)}, 700);
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,88 @@
|
||||
ig.module(
|
||||
'game.entities.mouse'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity',
|
||||
'game.entities.kuroneko',
|
||||
)
|
||||
.defines(function() {
|
||||
EntityMouse = ig.Entity.extend({
|
||||
|
||||
collides: ig.Entity.COLLIDES.PASSIVE,
|
||||
|
||||
size: {x: 26, y: 9},
|
||||
gravityFactor: 4,
|
||||
speed: 100,
|
||||
maxVel: {x: 300, y: 100},
|
||||
flip: true,
|
||||
player: null,
|
||||
is_dead: false,
|
||||
|
||||
animSheet: new ig.AnimationSheet('media/mouse.png', 26, 9),
|
||||
|
||||
init: function(x, y, settings) {
|
||||
this.parent(x, y, settings);
|
||||
|
||||
this.addAnim('normal', 1, [0]);
|
||||
this.addAnim('dead', 1, [1]);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.parent();
|
||||
|
||||
if (!this.is_dead) {
|
||||
this.currentAnim = this.anims.normal;
|
||||
} else {
|
||||
this.currentAnim = this.anims.dead;
|
||||
this.currentAnim.flip.y = true;
|
||||
}
|
||||
this.currentAnim.flip.x = this.flip;
|
||||
|
||||
var xdir = this.flip ? -1:1;
|
||||
this.vel.x = this.speed * this.turnAround();;
|
||||
},
|
||||
|
||||
handleMovementTrace: function(res) {
|
||||
this.parent(res);
|
||||
|
||||
if (res.collision.x) {
|
||||
this.flip = !this.flip;
|
||||
}
|
||||
},
|
||||
|
||||
collideWith: function(other, axis) {
|
||||
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
|
||||
if (other instanceof EntityKuroneko) {
|
||||
if (axis === 'y') {
|
||||
this.kill();
|
||||
this.player.vel.y = -200;
|
||||
ig.game.score += 100;
|
||||
} else if (axis === 'x') {
|
||||
this.player.receiveDamage(1, this);
|
||||
if (this.player.pos.x < this.pos.x) {
|
||||
this.player.vel.x = -400;
|
||||
} else {
|
||||
this.player.vel.x = 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
turnAround: function(){
|
||||
//is the next collision tile empty
|
||||
var x = this.pos.x + (this.flip ? + 5 : this.size.x - 5);
|
||||
var y = this.pos.y + this.size.y + 5;
|
||||
if(!ig.game.collisionMap.getTile(x, y)){
|
||||
this.flip = !this.flip;
|
||||
}
|
||||
return this.flip ? -1 : 1;
|
||||
},
|
||||
|
||||
kill: function() {
|
||||
this.is_dead = true;
|
||||
this.speed = 0;
|
||||
this.collides = ig.Entity.COLLIDES.NEVER;
|
||||
setTimeout(function(){ig.game.removeEntity(this);}.bind(this), 500);
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
ig.module(
|
||||
'game.entities.nextlevel'
|
||||
)
|
||||
.requires(
|
||||
'impact.entity',
|
||||
'game.entities.kuroneko',
|
||||
)
|
||||
.defines(function() {
|
||||
EntityNextlevel = ig.Entity.extend({
|
||||
_wmDrawBox: true,
|
||||
_wmBoxColor: 'rgba(0, 0, 255, 0.7)',
|
||||
size: {x: 16, y: 48},
|
||||
gravityFactor: 0,
|
||||
checkAgainst: ig.Entity.TYPE.A,
|
||||
player: null,
|
||||
|
||||
update: function(x, y, settings) {
|
||||
this.parent(x, y, settings);
|
||||
},
|
||||
|
||||
check: function( other ) {
|
||||
if(other instanceof EntityKuroneko){
|
||||
this.player = ig.game.getEntitiesByType(EntityKuroneko)[0];
|
||||
this.player.currentAnim = this.player.anims.nothing;
|
||||
this.player.speed = 0;
|
||||
setTimeout(function() {ig.game.loadLevel( LevelLevel2 );}.bind(this), 1000);
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user