var Cube = Container.expand(function () { var self = Container.call(this); var cubeGraphics = self.createAsset('cube', 'Cube Graphics', .5, .5); cubeGraphics.tint = Math.floor(Math.random() * 16777215); self.speed = 0; self.move = function (direction) { if (self.speed !== 0) { self.y += self.speed; if (direction === 'left' && self.x - 10 >= 0) { self.x -= 10; } else if (direction === 'right' && self.x + 10 <= 2048) { self.x += 10; } } }; self.stack = function (otherCube, intersection) { if (otherCube) { if (intersection === 'side') { if (self.x < otherCube.x) { self.x = otherCube.x - self.width; } else { self.x = otherCube.x + otherCube.width; } } else { self.y = otherCube.y - self.height; } } else if (self.y + self.height >= 2732) { self.y = 2732 - self.height; } self.speed = 0; }; self.intersectsWith = function (otherCube) { var intersects = self.x < otherCube.x + otherCube.width && self.x + self.width > otherCube.x && self.y < otherCube.y + otherCube.height && self.y + self.height > otherCube.y; if (intersects) { if (self.x + self.width - otherCube.x < 20 || otherCube.x + otherCube.width - self.x < 20) { return 'side'; } return 'top'; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Background Image', 0, 0); background.width = 2048; background.height = 2732; var overlayBox = self.createAsset('overlayBox', 'Overlay Box', 0, 0); overlayBox.width = 1948; overlayBox.x = 1024 - overlayBox.width / 2; overlayBox.height = 2432; overlayBox.y = 1450 - overlayBox.height / 2; overlayBox.alpha = 0.3; self.addChild(overlayBox); var cubes = []; var cubeSpeed = 5; function spawnCube() { var newCube = new Cube(); newCube.x = 1024; newCube.y = 400; newCube.speed = cubeSpeed; cubes.push(newCube); self.addChild(newCube); } function checkCubes() { for (var i = cubes.length - 1; i >= 0; i--) { if (cubes[i].y > 2732) { cubes[i].destroy(); cubes.splice(i, 1); } } } var leftCircle = self.createAsset('circle', 'Left Circle', .5, .5); leftCircle.tint = 0xFFFFFF; leftCircle.alpha = 0.6; leftCircle.x = -300 + leftCircle.width / 2; leftCircle.y = 2732 / 2; self.addChild(leftCircle); var leftButton = self.createAsset('leftButton', 'Left Button', .5, .5); leftButton.x = leftCircle.x + 125; leftButton.y = leftCircle.y; leftButton.rotation = Math.PI; leftButton.scale.set(1.5); self.addChild(leftButton); var rightCircle = self.createAsset('circle', 'Right Circle', .5, .5); rightCircle.tint = 0xFFFFFF; rightCircle.alpha = 0.6; rightCircle.x = 1860 + rightCircle.width / 2; rightCircle.y = 2732 / 2; self.addChild(rightCircle); var rightButton = self.createAsset('rightButton', 'Right Button', .5, .5); rightButton.x = rightCircle.x - 125; rightButton.y = rightCircle.y; rightButton.scale.set(1.5); self.addChild(rightButton); var spawnButton = self.createAsset('spawnButton', 'Spawn Button', .5, .5); spawnButton.x = 1024; spawnButton.y = 150; self.addChild(spawnButton); var speedLabel = new Text2('Drop speed', { size: 70, fill: '#ffffff' }); speedLabel.x = 1460; speedLabel.y = 20; self.addChild(speedLabel); var speedText = new Text2(cubeSpeed, { size: 100, fill: '#000000' }); speedText.x = 1600; speedText.y = 100; self.addChild(speedText); var speedUpButton = self.createAsset('speedUpButton', 'Speed Up Button', .5, .5); speedUpButton.x = 1024 + 750; speedUpButton.y = 150; self.addChild(speedUpButton); var speedDownButton = self.createAsset('speedDownButton', 'Speed Down Button', .5, .5); speedDownButton.x = 1024 + 500; speedDownButton.y = 150; speedDownButton.rotation = Math.PI; self.addChild(speedDownButton); var canSpawn = true; spawnButton.on('down', function () { if (canSpawn) { spawnCube(); canSpawn = false; LK.setTimeout(function () { canSpawn = true; }, 500); } }); speedUpButton.on('down', function () { if (cubeSpeed < 12) { cubeSpeed++; speedText.setText(cubeSpeed); } }); speedDownButton.on('down', function () { if (cubeSpeed > 1) { cubeSpeed--; speedText.setText(cubeSpeed); } }); var moveDirection = ''; speedText.setText(cubeSpeed); var leftButtonPressed = false; leftButton.on('down', function () { leftButtonPressed = true; leftCircle.alpha = 0.8; }); var rightButtonPressed = false; rightButton.on('down', function () { rightButtonPressed = true; rightCircle.alpha = 0.8; }); rightButton.on('up', function () { rightButtonPressed = false; rightCircle.alpha = 0.6; }); leftButton.on('up', function () { leftButtonPressed = false; leftCircle.alpha = 0.6; }); LK.on('tick', function () { for (var i = 0; i < cubes.length; i++) { if (leftButtonPressed) { cubes[i].move('left'); } else if (rightButtonPressed) { cubes[i].move('right'); } else { cubes[i].move(moveDirection); } var stacked = false; for (var j = 0; j < cubes.length; j++) { var intersection = cubes[i].intersectsWith(cubes[j]); if (i != j && intersection) { cubes[i].stack(cubes[j], intersection); stacked = true; break; } } if (!stacked) { if (cubes[i].y + cubes[i].height >= 2732) { cubes[i].stack(); } else if (cubes[i].y <= 200) { LK.showGameOver(); } } } checkCubes(); moveDirection = ''; }); });
===================================================================
--- original.js
+++ change.js
@@ -96,28 +96,28 @@
var spawnButton = self.createAsset('spawnButton', 'Spawn Button', .5, .5);
spawnButton.x = 1024;
spawnButton.y = 150;
self.addChild(spawnButton);
- var speedLabel = new Text2('Speed:', {
+ var speedLabel = new Text2('Drop speed', {
size: 70,
fill: '#ffffff'
});
- speedLabel.x = 1500;
- speedLabel.y = 50;
+ speedLabel.x = 1460;
+ speedLabel.y = 20;
self.addChild(speedLabel);
var speedText = new Text2(cubeSpeed, {
size: 100,
- fill: '#ffffff'
+ fill: '#000000'
});
- speedText.x = 1500;
- speedText.y = 150;
+ speedText.x = 1600;
+ speedText.y = 100;
self.addChild(speedText);
var speedUpButton = self.createAsset('speedUpButton', 'Speed Up Button', .5, .5);
- speedUpButton.x = 1024 + 700;
+ speedUpButton.x = 1024 + 750;
speedUpButton.y = 150;
self.addChild(speedUpButton);
var speedDownButton = self.createAsset('speedDownButton', 'Speed Down Button', .5, .5);
- speedDownButton.x = 1024 + 300;
+ speedDownButton.x = 1024 + 500;
speedDownButton.y = 150;
speedDownButton.rotation = Math.PI;
self.addChild(speedDownButton);
var canSpawn = true;
arrow pointing left, transparent background, cartoon style, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white square, 2d in-game asset, blank background, high contrast, no shadows, single game texture Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
vertical slider. 1000 pixels tall and 50 pixels wide. with numbers 1 at top and 10 at bottom. 2d in-game asset. blank background no shadows. high contrast Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white square, 2d in-game asset, blank background, high contrast, no shadows, single game texture Single Game Texture. With word DROP in middle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
background image 2732 high x 2048 wide. high contrast, light cartoon image of colored stacked cubes. out in open fields. Single Game Texture. In-Game asset. 3d. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
stone square, bevelled edges. 2d in-game asset, blank background, high contrast, no shadows, single-game texture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Triangle pointing left, transparent background, cartoon style, no shadow Single Game Texture. In-Game asset. 2d. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.