mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-01-14 15:53:54 +01:00
clean up level 02
This commit is contained in:
BIN
data/images/gfx64/st_spitter_idle.png
Normal file
BIN
data/images/gfx64/st_spitter_idle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
29
index.html
29
index.html
@@ -26,6 +26,7 @@ state.preload = function() {
|
||||
this.addSpriteSheet('oneWay', './data/images/gfx64/st_oneway.png', 64, 64 );
|
||||
this.addSpriteSheet('finishMarker', './data/images/gfx64/finish_marker.png', 64, 64 );
|
||||
this.addSpriteSheet('button', './data/images/gfx64/button.png', 128, 64 );
|
||||
this.addSpriteSheet('teleport', './data/images/gfx64/st_spitter_idle.png', 64, 64);
|
||||
}
|
||||
|
||||
state.velocityX = 64;
|
||||
@@ -35,7 +36,6 @@ state.create = function() {
|
||||
var level = levels[this.game.levelIndex - 1];
|
||||
this.tilemap = new Kiwi.GameObjects.Tilemap.TileMap(this, 'level' + this.game.levelIndex.toString(), this.textures.base);
|
||||
|
||||
|
||||
this.character = new Kiwi.GameObjects.Sprite(this, this.textures.character, 2*64 - 8, 64 - 8);
|
||||
// Hitbox is detecting collision in future step.
|
||||
// This is little bit counter intuitive.
|
||||
@@ -53,23 +53,29 @@ state.create = function() {
|
||||
this.finishMarker.animation.add('idle', [ 0, 1, 2, 3, 2, 1 ], 0.3, true);
|
||||
this.finishMarker.animation.play('idle', true);
|
||||
|
||||
// Load level specific data
|
||||
level.create(this);
|
||||
|
||||
// Ground layer
|
||||
this.addChild(this.tilemap.layers[0]);
|
||||
|
||||
this.addChild(this.character);
|
||||
// Load level specific data
|
||||
level.create(this);
|
||||
|
||||
this.addChild(this.finishMarker);
|
||||
|
||||
// Walls layer
|
||||
this.addChild(this.tilemap.layers[1]);
|
||||
this.addChild(this.finishMarker);
|
||||
|
||||
// Add action objects
|
||||
this.addChild(this.redirectorGroup);
|
||||
|
||||
|
||||
this.addChild(this.character);
|
||||
|
||||
// Sky layer
|
||||
this.addChild(this.tilemap.layers[2]);
|
||||
|
||||
// Create collision layer
|
||||
for(var i = 21; i < this.tilemap.tileTypes.length; i++) {
|
||||
this.tilemap.tileTypes[i].allowCollisions = Kiwi.Components.ArcadePhysics.ANY;
|
||||
}
|
||||
|
||||
this.keyboard = this.game.input.keyboard;
|
||||
|
||||
@@ -214,8 +220,13 @@ state.checkCollision = function () {
|
||||
for ( var i = 0; i < redirectors.length; i++ ) {
|
||||
var redirector = redirectors[i];
|
||||
if (((Math.round(positionX/64) == Math.round(redirector.x/64) )) && (Math.round(positionY/64) == Math.round(redirector.y/64))) {
|
||||
this.character.physics.velocity.x = redirector.affectVelocityX;
|
||||
this.character.physics.velocity.y = redirector.affectVelocityY;
|
||||
if (redirector.type == 'vector') {
|
||||
this.character.physics.velocity.x = redirector.affectVelocityX;
|
||||
this.character.physics.velocity.y = redirector.affectVelocityY;
|
||||
} else if (redirector.type == 'teleport') {
|
||||
this.character.x = redirector.affectedX - 8;
|
||||
this.character.y = redirector.affectedY - 8;
|
||||
}
|
||||
this.character.y = Math.round(this.character.y);
|
||||
this.character.x = Math.round(this.character.x);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
var level1 = {};
|
||||
level1.create = function(context) {
|
||||
// Create redirector objects
|
||||
|
||||
addRedirector(context, 10, 2, 1, 0, 0);
|
||||
addRedirector(context, 10, 3, 0, 1, 6);
|
||||
|
||||
@@ -14,11 +13,5 @@ level1.create = function(context) {
|
||||
// Define finish coordinates
|
||||
context.finishMarker.x = 6*64;
|
||||
context.finishMarker.y = 4*64;
|
||||
|
||||
// Create collision layer
|
||||
for(var i = 21; i < context.tilemap.tileTypes.length; i++) {
|
||||
context.tilemap.tileTypes[i].allowCollisions = Kiwi.Components.ArcadePhysics.ANY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
var level2 = {};
|
||||
level2.create = function(context) {
|
||||
|
||||
// Define finish coordinates
|
||||
context.finishMarker.x = 8*64;
|
||||
context.finishMarker.y = 2*64;
|
||||
|
||||
// Add teleport
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 4*64, 2*64);
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = 9*64;
|
||||
teleport.affectedY = 2*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
|
||||
// Add target teleport marker
|
||||
var teleportTarget = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 9*64, 2*64);
|
||||
teleportTarget.animation.add('idle', [ 3, 2, 1, 0 ], 0.3, true);
|
||||
teleportTarget.animation.play('idle', true);
|
||||
teleportTarget.type = 'teleport';
|
||||
teleportTarget.affectedX = 4*64;
|
||||
teleportTarget.affectedY = 2*64;
|
||||
context.redirectorGroup.addChild(teleportTarget);
|
||||
|
||||
// Create redirector objects
|
||||
addRedirector(context, 9, 1, -1, 0, 9);
|
||||
addRedirector(context, 9, 3, 1, 0, 0);
|
||||
addRedirector(context, 10, 2, 0, -1, 3);
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
function addRedirector(context, x, y, vectorX, vectorY, imageIndex) {
|
||||
var redirector = new Kiwi.GameObjects.Sprite(context, context.textures.oneWay, x*64, y*64);
|
||||
redirector.type = 'vector';
|
||||
redirector.affectVelocityX = context.velocityX * vectorX;
|
||||
redirector.affectVelocityY = context.velocityY * vectorY;
|
||||
redirector.cellIndex = imageIndex;
|
||||
|
||||
Reference in New Issue
Block a user