mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-02-24 19:35:49 +01:00
reafactor teleport pair into one function
This commit is contained in:
@@ -4,23 +4,8 @@ level4.create = function(context) {
|
||||
context.finishMarker.x = 8*64;
|
||||
context.finishMarker.y = 2*64;
|
||||
|
||||
// Add teleport
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 4*64, 3*64);
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = 8*64;
|
||||
teleport.affectedY = 3*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
|
||||
// Add target teleport marker
|
||||
var teleportTarget = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 8*64, 3*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 = 3*64;
|
||||
context.redirectorGroup.addChild(teleportTarget);
|
||||
// Add teleports
|
||||
addTeleportPair(context, 4, 3, 8, 3);
|
||||
|
||||
// Create redirector objects
|
||||
addRedirector(context, 9, 1, -1, 0, 9);
|
||||
|
||||
@@ -4,23 +4,8 @@ level5.create = function(context) {
|
||||
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);
|
||||
// Add teleports
|
||||
addTeleportPair(context, 4, 2, 9, 2);
|
||||
|
||||
// Create redirector objects
|
||||
addRedirector(context, 9, 1, -1, 0, 9);
|
||||
|
||||
@@ -10,23 +10,8 @@ level6.create = function(context) {
|
||||
context.finishMarker.x = 9*64;
|
||||
context.finishMarker.y = 4*64;
|
||||
|
||||
// Add teleport
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 3*64, 3*64);
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = 10*64;
|
||||
teleport.affectedY = 1*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
|
||||
// Add target teleport marker
|
||||
var teleportTarget = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 10*64, 1*64);
|
||||
teleportTarget.animation.add('idle', [ 3, 2, 1, 0 ], 0.3, true);
|
||||
teleportTarget.animation.play('idle', true);
|
||||
teleportTarget.type = 'teleport';
|
||||
teleportTarget.affectedX = 3*64;
|
||||
teleportTarget.affectedY = 3*64;
|
||||
context.redirectorGroup.addChild(teleportTarget);
|
||||
// Add teleports
|
||||
addTeleportPair(context, 3, 3, 10, 1)
|
||||
|
||||
// Create redirector objects
|
||||
addRedirector(context, 3, 1, -1, 0, 9);
|
||||
|
||||
@@ -10,23 +10,8 @@ level7.create = function(context) {
|
||||
context.finishMarker.x = 9*64;
|
||||
context.finishMarker.y = 4*64;
|
||||
|
||||
// Add teleport
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 3*64, 3*64);
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = 10*64;
|
||||
teleport.affectedY = 1*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
|
||||
// Add target teleport marker
|
||||
var teleportTarget = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, 10*64, 1*64);
|
||||
teleportTarget.animation.add('idle', [ 3, 2, 1, 0 ], 0.3, true);
|
||||
teleportTarget.animation.play('idle', true);
|
||||
teleportTarget.type = 'teleport';
|
||||
teleportTarget.affectedX = 3*64;
|
||||
teleportTarget.affectedY = 3*64;
|
||||
context.redirectorGroup.addChild(teleportTarget);
|
||||
// Add teleports
|
||||
addTeleportPair(context, 3, 3, 10, 1);
|
||||
|
||||
// Create redirector objects
|
||||
addRedirector(context, 3, 1, -1, 0, 9);
|
||||
|
||||
33
js/app/level-09.js
Normal file
33
js/app/level-09.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var level9 = {};
|
||||
level9.create = function(context) {
|
||||
// Define start coordinates
|
||||
context.character.initialX = 11*64;
|
||||
context.character.initialY = 4*64;
|
||||
context.character.initialVelocityX = 64;
|
||||
context.character.initialVelocityY = 0;
|
||||
|
||||
// Define finish coordinates
|
||||
context.finishMarker.x = 9*64;
|
||||
context.finishMarker.y = 4*64;
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
}
|
||||
@@ -13,3 +13,28 @@ function addRedirector(context, x, y, vectorX, vectorY, imageIndex) {
|
||||
|
||||
context.redirectorGroup.addChild(redirector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new teleport
|
||||
*/
|
||||
function addTeleport(context, x, y, affectedX, affectedY, isForwardAnimation) {
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, x*64, y*64);
|
||||
if (isForwardAnimation) {
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
} else {
|
||||
teleport.animation.add('idle', [ 3, 2, 1, 0 ], 0.3, true);
|
||||
}
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = affectedX*64;
|
||||
teleport.affectedY = affectedY*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pair of binded teleports
|
||||
*/
|
||||
function addTeleportPair(context, x, y, x2, y2) {
|
||||
addTeleport(context, x, y, x2, y2, true);
|
||||
addTeleport(context, x2, y2, x, y, false);
|
||||
}
|
||||
Reference in New Issue
Block a user