var BluePotion = Container.expand(function () { var self = Container.call(this); var bluePotionGraphics = self.createAsset('bluePotion', 'Shield Potion', .5, .5); self.speed = 3; self.move = function () { self.y += self.speed; }; }); var OrangePotion = Container.expand(function () { var self = Container.call(this); var orangePotionGraphics = self.createAsset('orangePotion', 'Fireball Potion', .5, .5); self.speed = 3; self.move = function () { self.y += self.speed; }; }); var RedPotion = Container.expand(function () { var self = Container.call(this); var redPotionGraphics = self.createAsset('redPotion', 'Extra Heart Potion', .5, .5); self.speed = 3; self.move = function () { self.y += self.speed; }; }); var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.createAsset('heart', 'Player Life', .5, .5); }); var Rock = Container.expand(function () { var self = Container.call(this); var rockGraphics = self.createAsset('rock', 'Falling Rock', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var Potion = Container.expand(function () { var self = Container.call(this); var potionGraphics = self.createAsset('potion', 'Boost Potion', .5, .5); self.speed = 3; self.move = function () { self.y += self.speed; }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player Character', .5, .5); self.shield = false; self.move = function (x, y) { self.x = x; self.y = y; }; }); var Game = Container.expand(function () { var self = Container.call(this); var startTime = null; var background = self.createAsset('background', 'Game Background', 0, 0); background.width = 2048; background.height = 2732; var tutorialBox = self.createAsset('tutorialBox', 'Tutorial Box', .5, .5); tutorialBox.tint = 0x000000; tutorialBox.x = 2048 / 2; tutorialBox.y = 2732 / 2; var gameTitleText = new Text2('Witch Way?\nPotion Commotion', { size: 150, fill: '#ffffff', fontStyle: 'bold' }); gameTitleText.anchor.set(.5, 0); gameTitleText.y = -500; tutorialBox.addChild(gameTitleText); var tutorialText = new Text2('HOW TO PLAY', { size: 70, fill: '#ffffff', fontStyle: 'bold' }); tutorialText.anchor.set(.5, 0); tutorialText.y = 10; tutorialBox.addChild(tutorialText); var tutorialText2 = new Text2('\n\nDodge the rocks and see how long you can last!\nTap on the screen to move left or right!\n\nCollect potions for power-ups!\n\nRed Potion gives you heart\nBlue Potion gives you a shield\nOrange Potion gives you a fire spell,\n touch the fireball to remove all rocks onscreen!', { size: 50, fill: '#ffffff', fontStyle: 'bold' }); tutorialText2.anchor.set(.5, 0); tutorialBox.addChild(tutorialText2); var rocks = []; var potions = []; var player = self.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - player.height; var startButton = self.createAsset('startButton', 'Start Button', .5, .5); startButton.x = startButton.width; startButton.y = player.y; startButton.on('down', function () { startTime = Date.now(); tutorialBox.destroy(); startButton.destroy(); self.gameStarted = true; }); var lives = 3; var hearts = []; for (var i = 0; i < lives; i++) { var heart = new Heart(); heart.x = 50 + i * 100; heart.y = 50; hearts.push(heart); LK.gui.topLeft.addChild(heart); } var fireballIcon = self.createAsset('fireballIcon', 'Fireball Icon', .5, .5); fireballIcon.x = 50; fireballIcon.y = 150; fireballIcon.visible = false; LK.gui.topLeft.addChild(fireballIcon); fireballIcon.on('down', function () { if (fireballIcon.visible) { for (var i = rocks.length - 1; i >= 0; i--) { rocks[i].destroy(); rocks.splice(i, 1); } LK.effects.flashScreen(0xFFA500, 1000); fireballIcon.visible = false; } }); var shieldIcon = self.createAsset('shieldIcon', 'Shield Icon', .5, .5); shieldIcon.x = 50; shieldIcon.y = 300; shieldIcon.visible = false; LK.gui.topLeft.addChild(shieldIcon); var scoreTxt = new Text2('0', { size: 150, fill: '#ffffff' }); scoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(scoreTxt); var timerTxt = new Text2('', { size: 150, fill: "#ffffff" }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); var dragNode = null; stage.on('keydown', function (event) { if (event.key == 'ArrowLeft') { player.move(player.x - 100, player.y); } else if (event.key == 'ArrowRight') { player.move(player.x + 100, player.y); } else if (event.key == ' ') { for (var i = rocks.length - 1; i >= 0; i--) { rocks[i].destroy(); rocks.splice(i, 1); } LK.effects.flashScreen(0xFFA500, 1000); } }); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); if (pos.x < player.x) { player.move(player.x - 100, player.y); } else if (pos.x > player.x) { player.move(player.x + 100, player.y); } }); function handleMove(obj) { var event = obj.event; var pos = event.getLocalPosition(self); if (dragNode) { dragNode.move(pos.x, pos.y); } } LK.on('tick', function () { for (var a = rocks.length - 1; a >= 0; a--) { if (rocks[a]) { rocks[a].move(); if (rocks[a].y > 2732) { rocks[a].destroy(); rocks.splice(a, 1); } else if (player.intersects(rocks[a])) { rocks[a].destroy(); rocks.splice(a, 1); if (player.shield) { player.shield = false; shieldIcon.visible = false; } else { hearts[--lives].destroy(); hearts.splice(lives, 1); LK.effects.flashScreen(0xff0000, 1000); if (lives == 0) { var endTime = Date.now(); var duration = Math.floor((endTime - startTime) / 1000); scoreTxt.setText(parseInt(scoreTxt.text) + 1); LK.showGameOver({ text: 'You survived for ' + duration + ' seconds and scored ' + scoreTxt.text + ' points', position: LK.gui.topCenter }); } } } } } for (var b = potions.length - 1; b >= 0; b--) { if (potions[b]) { potions[b].move(); if (potions[b].y > 2732) { potions[b].destroy(); potions.splice(b, 1); } else if (player.intersects(potions[b])) { if (potions[b] instanceof RedPotion) { var heart = new Heart(); heart.x = 50 + hearts.length * 100; heart.y = 50; hearts.push(heart); LK.gui.topLeft.addChild(heart); lives++; } else if (potions[b] instanceof OrangePotion) { fireballIcon.visible = true; } else if (potions[b] instanceof BluePotion) { player.shield = true; shieldIcon.visible = true; } potions[b].destroy(); potions.splice(b, 1); } } } if (self.gameStarted && LK.ticks % 60 == 0) { var newRock = new Rock(); newRock.x = Math.random() * 2048; newRock.y = 0; rocks.push(newRock); self.addChild(newRock); } if (self.gameStarted && LK.ticks % 300 == 0) { var newRedPotion = new RedPotion(); newRedPotion.x = Math.random() * 2048; newRedPotion.y = 0; potions.push(newRedPotion); self.addChild(newRedPotion); } if (self.gameStarted && LK.ticks % 450 == 0) { var newOrangePotion = new OrangePotion(); newOrangePotion.x = Math.random() * 2048; newOrangePotion.y = 0; potions.push(newOrangePotion); self.addChild(newOrangePotion); } if (self.gameStarted && LK.ticks % 600 == 0) { var newBluePotion = new BluePotion(); newBluePotion.x = Math.random() * 2048; newBluePotion.y = 0; potions.push(newBluePotion); self.addChild(newBluePotion); } if (self.gameStarted) { timerTxt.setText(Math.floor((Date.now() - startTime) / 1000)); } }); });
var BluePotion = Container.expand(function () {
var self = Container.call(this);
var bluePotionGraphics = self.createAsset('bluePotion', 'Shield Potion', .5, .5);
self.speed = 3;
self.move = function () {
self.y += self.speed;
};
});
var OrangePotion = Container.expand(function () {
var self = Container.call(this);
var orangePotionGraphics = self.createAsset('orangePotion', 'Fireball Potion', .5, .5);
self.speed = 3;
self.move = function () {
self.y += self.speed;
};
});
var RedPotion = Container.expand(function () {
var self = Container.call(this);
var redPotionGraphics = self.createAsset('redPotion', 'Extra Heart Potion', .5, .5);
self.speed = 3;
self.move = function () {
self.y += self.speed;
};
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.createAsset('heart', 'Player Life', .5, .5);
});
var Rock = Container.expand(function () {
var self = Container.call(this);
var rockGraphics = self.createAsset('rock', 'Falling Rock', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Potion = Container.expand(function () {
var self = Container.call(this);
var potionGraphics = self.createAsset('potion', 'Boost Potion', .5, .5);
self.speed = 3;
self.move = function () {
self.y += self.speed;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player Character', .5, .5);
self.shield = false;
self.move = function (x, y) {
self.x = x;
self.y = y;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var startTime = null;
var background = self.createAsset('background', 'Game Background', 0, 0);
background.width = 2048;
background.height = 2732;
var tutorialBox = self.createAsset('tutorialBox', 'Tutorial Box', .5, .5);
tutorialBox.tint = 0x000000;
tutorialBox.x = 2048 / 2;
tutorialBox.y = 2732 / 2;
var gameTitleText = new Text2('Witch Way?\nPotion Commotion', {
size: 150,
fill: '#ffffff',
fontStyle: 'bold'
});
gameTitleText.anchor.set(.5, 0);
gameTitleText.y = -500;
tutorialBox.addChild(gameTitleText);
var tutorialText = new Text2('HOW TO PLAY', {
size: 70,
fill: '#ffffff',
fontStyle: 'bold'
});
tutorialText.anchor.set(.5, 0);
tutorialText.y = 10;
tutorialBox.addChild(tutorialText);
var tutorialText2 = new Text2('\n\nDodge the rocks and see how long you can last!\nTap on the screen to move left or right!\n\nCollect potions for power-ups!\n\nRed Potion gives you heart\nBlue Potion gives you a shield\nOrange Potion gives you a fire spell,\n touch the fireball to remove all rocks onscreen!', {
size: 50,
fill: '#ffffff',
fontStyle: 'bold'
});
tutorialText2.anchor.set(.5, 0);
tutorialBox.addChild(tutorialText2);
var rocks = [];
var potions = [];
var player = self.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - player.height;
var startButton = self.createAsset('startButton', 'Start Button', .5, .5);
startButton.x = startButton.width;
startButton.y = player.y;
startButton.on('down', function () {
startTime = Date.now();
tutorialBox.destroy();
startButton.destroy();
self.gameStarted = true;
});
var lives = 3;
var hearts = [];
for (var i = 0; i < lives; i++) {
var heart = new Heart();
heart.x = 50 + i * 100;
heart.y = 50;
hearts.push(heart);
LK.gui.topLeft.addChild(heart);
}
var fireballIcon = self.createAsset('fireballIcon', 'Fireball Icon', .5, .5);
fireballIcon.x = 50;
fireballIcon.y = 150;
fireballIcon.visible = false;
LK.gui.topLeft.addChild(fireballIcon);
fireballIcon.on('down', function () {
if (fireballIcon.visible) {
for (var i = rocks.length - 1; i >= 0; i--) {
rocks[i].destroy();
rocks.splice(i, 1);
}
LK.effects.flashScreen(0xFFA500, 1000);
fireballIcon.visible = false;
}
});
var shieldIcon = self.createAsset('shieldIcon', 'Shield Icon', .5, .5);
shieldIcon.x = 50;
shieldIcon.y = 300;
shieldIcon.visible = false;
LK.gui.topLeft.addChild(shieldIcon);
var scoreTxt = new Text2('0', {
size: 150,
fill: '#ffffff'
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
var timerTxt = new Text2('', {
size: 150,
fill: "#ffffff"
});
timerTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timerTxt);
var dragNode = null;
stage.on('keydown', function (event) {
if (event.key == 'ArrowLeft') {
player.move(player.x - 100, player.y);
} else if (event.key == 'ArrowRight') {
player.move(player.x + 100, player.y);
} else if (event.key == ' ') {
for (var i = rocks.length - 1; i >= 0; i--) {
rocks[i].destroy();
rocks.splice(i, 1);
}
LK.effects.flashScreen(0xFFA500, 1000);
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (pos.x < player.x) {
player.move(player.x - 100, player.y);
} else if (pos.x > player.x) {
player.move(player.x + 100, player.y);
}
});
function handleMove(obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (dragNode) {
dragNode.move(pos.x, pos.y);
}
}
LK.on('tick', function () {
for (var a = rocks.length - 1; a >= 0; a--) {
if (rocks[a]) {
rocks[a].move();
if (rocks[a].y > 2732) {
rocks[a].destroy();
rocks.splice(a, 1);
} else if (player.intersects(rocks[a])) {
rocks[a].destroy();
rocks.splice(a, 1);
if (player.shield) {
player.shield = false;
shieldIcon.visible = false;
} else {
hearts[--lives].destroy();
hearts.splice(lives, 1);
LK.effects.flashScreen(0xff0000, 1000);
if (lives == 0) {
var endTime = Date.now();
var duration = Math.floor((endTime - startTime) / 1000);
scoreTxt.setText(parseInt(scoreTxt.text) + 1);
LK.showGameOver({
text: 'You survived for ' + duration + ' seconds and scored ' + scoreTxt.text + ' points',
position: LK.gui.topCenter
});
}
}
}
}
}
for (var b = potions.length - 1; b >= 0; b--) {
if (potions[b]) {
potions[b].move();
if (potions[b].y > 2732) {
potions[b].destroy();
potions.splice(b, 1);
} else if (player.intersects(potions[b])) {
if (potions[b] instanceof RedPotion) {
var heart = new Heart();
heart.x = 50 + hearts.length * 100;
heart.y = 50;
hearts.push(heart);
LK.gui.topLeft.addChild(heart);
lives++;
} else if (potions[b] instanceof OrangePotion) {
fireballIcon.visible = true;
} else if (potions[b] instanceof BluePotion) {
player.shield = true;
shieldIcon.visible = true;
}
potions[b].destroy();
potions.splice(b, 1);
}
}
}
if (self.gameStarted && LK.ticks % 60 == 0) {
var newRock = new Rock();
newRock.x = Math.random() * 2048;
newRock.y = 0;
rocks.push(newRock);
self.addChild(newRock);
}
if (self.gameStarted && LK.ticks % 300 == 0) {
var newRedPotion = new RedPotion();
newRedPotion.x = Math.random() * 2048;
newRedPotion.y = 0;
potions.push(newRedPotion);
self.addChild(newRedPotion);
}
if (self.gameStarted && LK.ticks % 450 == 0) {
var newOrangePotion = new OrangePotion();
newOrangePotion.x = Math.random() * 2048;
newOrangePotion.y = 0;
potions.push(newOrangePotion);
self.addChild(newOrangePotion);
}
if (self.gameStarted && LK.ticks % 600 == 0) {
var newBluePotion = new BluePotion();
newBluePotion.x = Math.random() * 2048;
newBluePotion.y = 0;
potions.push(newBluePotion);
self.addChild(newBluePotion);
}
if (self.gameStarted) {
timerTxt.setText(Math.floor((Date.now() - startTime) / 1000));
}
});
});
Witch Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Witch Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rock A big rock
blue potion a blue potion
A witch's room with a cauldron A witch's room with a cauldron
heart icon heart icon
fireball icon fireball icon, no background
blue shield blue shield no background
red potion red potion, no background
orange potion orange potion, no background
START button START button