User prompt
You can make the speed cap a little bit bigger. We could use a bit more challenge
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'var shapeSpeed = Math.min(7.2 + Math.floor(player.score / 10), 28.8);' Line Number: 81
User prompt
The game still doesn't work. Review the entire code and make sure you implemented the different 3 characters right, then continue updating the game.
User prompt
The issue is still not solved
User prompt
Fix the error that causes a black screen right now
User prompt
Fix the bugs
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'scoreTxt.setText(player.score);' Line Number: 86
User prompt
Now let's copy everything we did in the middle to the left and right side. We want to have 3 individual player controlled shapes (one left, one middle and one right) each of them sharing the same score but having individual enemies and only change their shape when clicked on their side.
User prompt
Change the colors to more lively and ligher ones
User prompt
Fix Bug: 'ReferenceError: background is not defined' in this line: 'LK.effects.flashObject(background, 0xFFFFFF, 1000);' Line Number: 82
User prompt
Divide the screen in 3 1/3 sides, color all of them diferently. The player can only change its shape if cliked on the side of the screen where the character is situated.
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'scoreTxt.setText(player.score);' Line Number: 73
User prompt
Now we will scale everything we did on the middle side for the other 2 sides (the left one and the right one). That means we will create another player character on the left and another on the right, both of them having their own obstacles.
User prompt
Fix Bug: 'ReferenceError: background is not defined' in this line: 'LK.effects.flashObject(background, 0xFFFFFF, 1000);' Line Number: 82
User prompt
Make it so you can only change the shape of the player if you click on the side of the screen where it is situated
User prompt
Change the colours to more lively ones
User prompt
Divide the game area in 3 1/3 sides (1/3 left, 1/3 middle and 1/3 right) and mark them (have them have different background colours for example)
User prompt
Fix the newly created bugs
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'scoreTxt.setText(player.score);' Line Number: 84
User prompt
Now you will furtherly develop the game by making so there is a player on each of the 3 sides of the screen,
User prompt
Fix Bug: 'ReferenceError: background is not defined' in this line: 'LK.effects.flashObject(background, 0xFFFFFF, 1000);' Line Number: 82
User prompt
Make it so the character changes its shape only when you click the adequate side of the screen (the one which it is in, so the middle one)
User prompt
Divide the screen in 1/3 parts, and mark them (1/3 left, 1/3 middle, 1/3 right)
User prompt
I did not mean that. I mean't that the switch function only works on the middle side of the screen
User prompt
Divide the screen in 3 sides (1/3 left, 1/3 middle, 1/3 right) and make it so the shape only changes if you click on it's side of the screen
===================================================================
--- original.js
+++ change.js
@@ -14,62 +14,38 @@
});
var Triangle = Shape.expand(function () {
Shape.call(this, 'triangleAsset');
});
-var Player1 = Container.expand(function () {
+var Player = Container.expand(function () {
var self = Container.call(this);
- self.playerGraphics = self.createAsset('player1', 'Player1 Graphics', .5, .5);
+ self.playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5);
self.score = 0;
self.shape = 'square';
self.incrementScore = function () {
self.score += 1;
};
});
-var Player2 = Container.expand(function () {
- var self = Container.call(this);
- self.playerGraphics = self.createAsset('player2', 'Player2 Graphics', .5, .5);
- self.score = 0;
- self.shape = 'circle';
- self.incrementScore = function () {
- self.score += 1;
- };
-});
-var Player3 = Container.expand(function () {
- var self = Container.call(this);
- self.playerGraphics = self.createAsset('player3', 'Player3 Graphics', .5, .5);
- self.score = 0;
- self.shape = 'triangle';
- self.incrementScore = function () {
- self.score += 1;
- };
-});
var Game = Container.expand(function () {
var self = Container.call(this);
var gameStarted = false;
- var leftThird = self.createAsset('leftThirdAsset', 'Left Third of Screen', 0, 0);
- leftThird.width = 2048 / 3;
- leftThird.height = 2732;
- leftThird.tint = 0xADD8E6;
- var middleThird = self.createAsset('middleThirdAsset', 'Middle Third of Screen', 0, 0);
- middleThird.width = 2048 / 3;
- middleThird.height = 2732;
- middleThird.x = 2048 / 3;
- middleThird.tint = 0xADD8E6;
- var rightThird = self.createAsset('rightThirdAsset', 'Right Third of Screen', 0, 0);
- rightThird.width = 2048 / 3;
- rightThird.height = 2732;
- rightThird.x = 2048 / 3 * 2;
- rightThird.tint = 0xADD8E6;
+ var leftBackground = self.createAsset('backgroundAsset', 'Left Background Graphics', 0, 0);
+ leftBackground.width = 2048 / 3;
+ leftBackground.height = 2732;
+ leftBackground.tint = 0xFF0000;
+ var middleBackground = self.createAsset('backgroundAsset', 'Middle Background Graphics', 0, 0);
+ middleBackground.width = 2048 / 3;
+ middleBackground.height = 2732;
+ middleBackground.x = 2048 / 3;
+ middleBackground.tint = 0x00FF00;
+ var rightBackground = self.createAsset('backgroundAsset', 'Right Background Graphics', 0, 0);
+ rightBackground.width = 2048 / 3;
+ rightBackground.height = 2732;
+ rightBackground.x = 2048 / 3 * 2;
+ rightBackground.tint = 0x0000FF;
var shapes = [];
- var player1 = self.addChild(new Player1());
- player1.x = 2048 / 3;
- player1.y = 2732 - player1.playerGraphics.height;
- var player2 = self.addChild(new Player2());
- player2.x = 2048 / 2;
- player2.y = 2732 - player2.playerGraphics.height;
- var player3 = self.addChild(new Player3());
- player3.x = 2048 / 3 * 2;
- player3.y = 2732 - player3.playerGraphics.height;
+ var player = self.addChild(new Player());
+ player.x = 2048 / 2;
+ player.y = 2732 - player.playerGraphics.height;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -80,9 +56,9 @@
tutorialTxt.anchor.set(.5, .5);
tutorialTxt.x = 2048 / 2;
tutorialTxt.y = 2732 / 2;
self.addChild(tutorialTxt);
- scoreTxt.setText(player1.score + player2.score + player3.score);
+ scoreTxt.setText(player.score);
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var shapeTypes = [Circle, Square, Triangle];
var shapeOrder = ['square', 'circle', 'triangle'];
@@ -98,40 +74,18 @@
shapes.push(shape);
}
for (var a = shapes.length - 1; a >= 0; a--) {
shapes[a].y += shapeSpeed + Math.floor(player.score / 10);
- if (shapes[a].y >= player1.y && shapes[a].x >= player1.x && shapes[a].x <= player1.x + player1.playerGraphics.width) {
- if (shapes[a] instanceof Circle && player1.shape === 'circle' || shapes[a] instanceof Square && player1.shape === 'square' || shapes[a] instanceof Triangle && player1.shape === 'triangle') {
- player1.incrementScore();
- scoreTxt.setText(player1.score);
- LK.effects.flashObject(self, 0xFFFFFF, 1000);
+ if (shapes[a].y >= player.y) {
+ if (shapes[a] instanceof Circle && player.shape === 'circle' || shapes[a] instanceof Square && player.shape === 'square' || shapes[a] instanceof Triangle && player.shape === 'triangle') {
+ player.incrementScore();
+ scoreTxt.setText(player.score);
+ LK.effects.flashObject(background, 0xFFFFFF, 1000);
shapes[a].destroy();
shapes.splice(a, 1);
} else {
LK.showGameOver();
}
- }
- if (shapes[a].y >= player2.y && shapes[a].x >= player2.x && shapes[a].x <= player2.x + player2.playerGraphics.width) {
- if (shapes[a] instanceof Circle && player2.shape === 'circle' || shapes[a] instanceof Square && player2.shape === 'square' || shapes[a] instanceof Triangle && player2.shape === 'triangle') {
- player2.incrementScore();
- scoreTxt.setText(player2.score);
- LK.effects.flashObject(self, 0xFFFFFF, 1000);
- shapes[a].destroy();
- shapes.splice(a, 1);
- } else {
- LK.showGameOver();
- }
- }
- if (shapes[a].y >= player3.y && shapes[a].x >= player3.x && shapes[a].x <= player3.x + player3.playerGraphics.width) {
- if (shapes[a] instanceof Circle && player3.shape === 'circle' || shapes[a] instanceof Square && player3.shape === 'square' || shapes[a] instanceof Triangle && player3.shape === 'triangle') {
- player3.incrementScore();
- scoreTxt.setText(player3.score);
- LK.effects.flashObject(self, 0xFFFFFF, 1000);
- shapes[a].destroy();
- shapes.splice(a, 1);
- } else {
- LK.showGameOver();
- }
} else if (shapes[a].y > 2732) {
shapes[a].destroy();
shapes.splice(a, 1);
}
@@ -142,67 +96,27 @@
gameStarted = true;
tutorialTxt.destroy();
return;
}
+ var shapeOrder = ['square', 'circle', 'triangle'];
+ var currentShapeIndex = shapeOrder.indexOf(player.shape);
+ currentShapeIndex = (currentShapeIndex + 1) % shapeOrder.length;
+ player.shape = shapeOrder[currentShapeIndex];
+ player.removeChild(player.playerGraphics);
+ player.playerGraphics = player.createAsset(player.shape + 'Asset', 'Player Graphics', .5, .5);
+ player.addChild(player.playerGraphics);
var event = obj.event;
var pos = event.getLocalPosition(self);
- if (pos.x >= player1.x - player1.playerGraphics.width / 2 && pos.x <= player1.x + player1.playerGraphics.width / 2) {
- var shapeOrder = ['square', 'circle', 'triangle'];
- var currentShapeIndex = shapeOrder.indexOf(player1.shape);
- currentShapeIndex = (currentShapeIndex + 1) % shapeOrder.length;
- player1.shape = shapeOrder[currentShapeIndex];
- player1.removeChild(player1.playerGraphics);
- player1.playerGraphics = player1.createAsset(player1.shape + 'Asset', 'Player1 Graphics', .5, .5);
- player1.addChild(player1.playerGraphics);
- }
- if (pos.x >= player2.x - player2.playerGraphics.width / 2 && pos.x <= player2.x + player2.playerGraphics.width / 2) {
- var shapeOrder = ['square', 'circle', 'triangle'];
- var currentShapeIndex = shapeOrder.indexOf(player2.shape);
- currentShapeIndex = (currentShapeIndex + 1) % shapeOrder.length;
- player2.shape = shapeOrder[currentShapeIndex];
- player2.removeChild(player2.playerGraphics);
- player2.playerGraphics = player2.createAsset(player2.shape + 'Asset', 'Player2 Graphics', .5, .5);
- player2.addChild(player2.playerGraphics);
- }
- if (pos.x >= player3.x - player3.playerGraphics.width / 2 && pos.x <= player3.x + player3.playerGraphics.width / 2) {
- var shapeOrder = ['square', 'circle', 'triangle'];
- var currentShapeIndex = shapeOrder.indexOf(player3.shape);
- currentShapeIndex = (currentShapeIndex + 1) % shapeOrder.length;
- player3.shape = shapeOrder[currentShapeIndex];
- player3.removeChild(player3.playerGraphics);
- player3.playerGraphics = player3.createAsset(player3.shape + 'Asset', 'Player3 Graphics', .5, .5);
- player3.addChild(player3.playerGraphics);
- }
for (var a = shapes.length - 1; a >= 0; a--) {
if (shapes[a] && shapes[a].intersects({
x: pos.x,
y: pos.y
- }) && shapes[a] instanceof window[player1.shape.charAt(0).toUpperCase() + player1.shape.slice(1)]) {
+ }) && shapes[a] instanceof window[player.shape.charAt(0).toUpperCase() + player.shape.slice(1)]) {
shapes[a].match();
shapes[a].destroy();
shapes.splice(a, 1);
- player1.incrementScore();
- scoreTxt.setText(player1.score);
+ player.incrementScore();
+ scoreTxt.setText(player.score);
}
- if (shapes[a] && shapes[a].intersects({
- x: pos.x,
- y: pos.y
- }) && shapes[a] instanceof window[player2.shape.charAt(0).toUpperCase() + player2.shape.slice(1)]) {
- shapes[a].match();
- shapes[a].destroy();
- shapes.splice(a, 1);
- player2.incrementScore();
- scoreTxt.setText(player2.score);
- }
- if (shapes[a] && shapes[a].intersects({
- x: pos.x,
- y: pos.y
- }) && shapes[a] instanceof window[player3.shape.charAt(0).toUpperCase() + player3.shape.slice(1)]) {
- shapes[a].match();
- shapes[a].destroy();
- shapes.splice(a, 1);
- player3.incrementScore();
- scoreTxt.setText(player3.score);
- }
}
});
});