add level 8

This commit is contained in:
Juraj Michalek
2015-12-28 15:21:12 +01:00
parent a38c81c7e0
commit ab882484c0
7 changed files with 218 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

64
data/levels/level-08.json Normal file
View File

@@ -0,0 +1,64 @@
{ "height":6,
"layers":[
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 2, 2, 11, 0, 0, 0, 0, 0, 0, 0, 2, 2, 12, 2, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 2, 12, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":6,
"name":"ground",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":18,
"x":0,
"y":0
},
{
"data":[22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 0, 0, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, 32, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 32, 0, 0, 0, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, 52, 0, 0, 0, 32, 0, 0, 0, 0, 0, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 0, 0, 0, 0, 0],
"height":6,
"name":"walls",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":18,
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":6,
"name":"sky",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":18,
"x":0,
"y":0
}],
"nextobjectid":4,
"orientation":"orthogonal",
"properties":
{
},
"renderorder":"right-down",
"tileheight":64,
"tilesets":[
{
"firstgid":1,
"image":"..\/images\/gfx64\/tiles.png",
"imageheight":448,
"imagewidth":640,
"margin":0,
"name":"base",
"properties":
{
},
"spacing":0,
"tilecount":70,
"tileheight":64,
"tilewidth":64
}],
"tilewidth":64,
"version":1,
"width":18
}

View File

@@ -16,12 +16,13 @@
<script src="js/app/level-05.js"></script>
<script src="js/app/level-06.js"></script>
<script src="js/app/level-07.js"></script>
<script src="js/app/level-08.js"></script>
</head>
<body>
<script>
var state = new Kiwi.State('state');
var levels = [level1, level2, level3, level4, level5, level6, level7];
var levels = [level1, level2, level3, level4, level5, level6, level7, level8];
state.preload = function() {
this.addJSON('level1', 'data/levels/level-01.json');
@@ -31,6 +32,7 @@ state.preload = function() {
this.addJSON('level5', 'data/levels/level-05.json');
this.addJSON('level6', 'data/levels/level-06.json');
this.addJSON('level7', 'data/levels/level-07.json');
this.addJSON('level8', 'data/levels/level-08.json');
this.addSpriteSheet('base', './data/images/gfx64/tiles.png', 64, 64);
this.addSpriteSheet('character', './data/images/gfx64/marble_black.png', 80, 80 );
this.addSpriteSheet('oneWay', './data/images/gfx64/st_oneway.png', 64, 64 );
@@ -38,6 +40,9 @@ state.preload = function() {
this.addSpriteSheet('button', './data/images/gfx64/button.png', 128, 64 );
this.addSpriteSheet('teleport', './data/images/gfx64/st_spitter_idle.png', 64, 64);
this.addSpriteSheet('box', './data/images/gfx64/st_box_wood.png', 64, 64);
this.addSpriteSheet('switch', './data/images/gfx64/st_switch.png', 64, 64);
this.addSpriteSheet('laserBeam', './data/images/gfx64/it_laser.png', 64, 64);
this.addSpriteSheet('laser', './data/images/gfx64/st_laser.png', 64, 64);
}
state.velocityX = 64;
@@ -143,6 +148,12 @@ state.resetStage = function() {
if (redirector.type == 'box') {
redirector.x = redirector.initialX;
redirector.y = redirector.initialY;
} else if (redirector.type == 'switch') {
redirector.cellIndex = redirector.initialCellIndex;
} else if (redirector.type == 'laserBeam') {
redirector.visible = redirector.initialVisible;
} else if (redirector.type == 'laser') {
redirector.animation.play(redirector.initialAnimation, true);
}
}
}
@@ -238,6 +249,32 @@ state.updateCharacterAnimation = function () {
}
}
state.turnOff = function(items) {
for (var i=0; i!=items.length; i++) {
var item = items[i];
if (item.type == 'laserBeam') {
item.visible = false;
} else if (item.type == 'switch') {
item.cellIndex = 2;
} else {
item.animation.play('idle');
}
}
}
state.turnOn = function(items) {
for (var i=0; i!=items.length; i++) {
var item = items[i];
if (item.type == 'laserBeam') {
item.visible = true;
} else if (item.type == 'switch') {
item.cellIndex = 0;
} else {
item.animation.play('burning');
}
}
}
/**
* Create effect based on type of redirector.
*/
@@ -276,6 +313,20 @@ state.applyRedirectorMechanics = function(tileX, tileY, redirector) {
// Bounce from box should relaunch direction calculation
// This is for the case when box lies close to redirector
isRecalculationRequired = true;
} else if (redirector.type == 'switch') {
// Flip the switch
if (redirector.cellIndex == 0) {
redirector.cellIndex = 2;
this.turnOff(redirector.linkedItems);
} else {
redirector.cellIndex = 0;
this.turnOn(redirector.linkedItems);
}
} else if (redirector.type == 'laserBeam') {
if (redirector.visible) {
this.character.physics.velocity.x = 0;
this.character.physics.velocity.y = 0;
}
}
// Correction of coordinates

View File

@@ -48,6 +48,7 @@ level7.create = function(context) {
// Add moving box
var box2 = new Kiwi.GameObjects.Sprite(context, context.textures.box, 9*64, 3*64);
box2.type = 'box';
box2.cellIndex = 1;
box2.initialX = 9*64;
box2.initialY = 3*64;
context.redirectorGroup.addChild(box2);

101
js/app/level-08.js Normal file
View File

@@ -0,0 +1,101 @@
var level8 = {};
level8.create = function(context) {
// Define start coordinates
context.character.initialX = 1*64;
context.character.initialY = 2*64;
context.character.initialVelocityX = 64;
context.character.initialVelocityY = 0;
// Define finish coordinates
context.finishMarker.x = 11*64;
context.finishMarker.y = 4*64;
// Laser
var laser = new Kiwi.GameObjects.Sprite(context, context.textures.laser, 4*64, 1*64);
laser.animation.add('idle', [ 2, 6, 10, 6 ], 0.4, true);
laser.animation.add('burning', [ 2, 6, 10, 14, 18, 22, 26, 30, 34 ], 0.2, true);
laser.animation.play('burning', true);
laser.initialAnimation = 'burning';
laser.type = 'laser';
context.redirectorGroup.addChild(laser);
var laser2 = new Kiwi.GameObjects.Sprite(context, context.textures.laser, 4*64, 3*64);
laser2.animation.add('idle', [ 0, 4, 8, 4 ], 0.4, true);
laser2.animation.add('burning', [ 0, 4, 8, 12, 16, 20, 24, 28, 32 ], 0.2, true);
laser2.animation.play('burning', true);
laser2.initialAnimation = 'burning';
laser2.type = 'laser';
context.redirectorGroup.addChild(laser2);
var laserBeam = new Kiwi.GameObjects.Sprite(context, context.textures.laserBeam, 4*64, 2*64);
laserBeam.cellIndex = 1;
laserBeam.initialVisible = true;
laserBeam.type = 'laserBeam';
context.redirectorGroup.addChild(laserBeam);
var laserSwitch = new Kiwi.GameObjects.Sprite(context, context.textures.switch, 2*64, 3*64);
laserSwitch.cellIndex = 0;
laserSwitch.initialCellIndex = 0;
laserSwitch.type = 'switch';
context.redirectorGroup.addChild(laserSwitch);
// Laser
var laser3 = new Kiwi.GameObjects.Sprite(context, context.textures.laser, 8*64, 2*64);
laser3.animation.add('idle', [ 2, 6, 10, 6 ], 0.4, true);
laser3.animation.add('burning', [ 2, 6, 10, 14, 18, 22, 26, 30, 34 ], 0.25, true);
laser3.animation.play('burning', true);
laser3.initialAnimation = 'burning';
laser3.type = 'laser';
context.redirectorGroup.addChild(laser3);
var laser4 = new Kiwi.GameObjects.Sprite(context, context.textures.laser, 8*64, 4*64);
laser4.animation.add('idle', [ 0, 4, 8, 4 ], 0.4, true);
laser4.animation.add('burning', [ 0, 4, 8, 12, 16, 20, 24, 28, 32 ], 0.25, true);
laser4.animation.play('burning', true);
laser4.initialAnimation = 'burning';
laser4.type = 'laser';
context.redirectorGroup.addChild(laser4);
var laserBeam2 = new Kiwi.GameObjects.Sprite(context, context.textures.laserBeam, 8*64, 3*64);
laserBeam2.cellIndex = 1;
laserBeam2.initialVisible=true;
laserBeam2.type = 'laserBeam';
context.redirectorGroup.addChild(laserBeam2);
var laserSwitch2 = new Kiwi.GameObjects.Sprite(context, context.textures.switch, 6*64, 3*64);
laserSwitch2.cellIndex = 0;
laserSwitch2.initialCellIndex = 0;
laserSwitch2.type = 'switch';
laserSwitch2.linkedItems = [laser3, laser4, laserBeam2];
context.redirectorGroup.addChild(laserSwitch2);
var laserSwitch3 = new Kiwi.GameObjects.Sprite(context, context.textures.switch, 5*64, 3*64);
laserSwitch3.cellIndex = 0;
laserSwitch3.initialCellIndex = 0;
laserSwitch3.type = 'switch';
laserSwitch3.linkedItems = [laser, laser2, laserBeam, laserSwitch];
context.redirectorGroup.addChild(laserSwitch3);
// Link 1st switch
laserSwitch.linkedItems = [laser, laser2, laserBeam, laserSwitch3];
// Create redirector objects
// Right
addRedirector(context, 11, 3, 1, 0, 0);
addRedirector(context, 11, 2, 1, 0, 0);
addRedirector(context, 11, 1, 1, 0, 0);
addRedirector(context, 9, 3, 1, 0, 0);
// Down
addRedirector(context, 10, 3, 0, 1, 6);
addRedirector(context, 10, 1, 0, 1, 6);
addRedirector(context, 9, 1, 0, 1, 6);
// Up
addRedirector(context, 10, 2, 0, -1, 3);
addRedirector(context, 9, 2, 0, -1, 3);
}