Code edit (2 edits merged)
Please save this source code
User prompt
Create an interface class that handles the score. It should contain the scoreTxt variable, and should have an increment function that takes in a value
Code edit (1 edits merged)
Please save this source code
User prompt
check if the squash target is a player
Code edit (9 edits merged)
Please save this source code
User prompt
boxes have an empty squash function that takes in a bool
User prompt
boxes have an activate function which takes in a bool
Code edit (1 edits merged)
Please save this source code
User prompt
clamp the new targetColumn value in the player's move function between 0 and NUM_COLUMNS
Code edit (10 edits merged)
Please save this source code
User prompt
remove the debug console.logs in the player
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: COLUMN_WIDTH is not defined' in this line: 'columns.push(new Column(self, i * COLUMN_WIDTH, 0));' Line Number: 121
User prompt
Replace any and all occurances of `COLUMN_WIDTH` with `BOX_SIZE`
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
columns have a `count` variable which increases by one every time a box is spawned. Additionally, created boxes take in a 4th parameter which is a `targetHeight` calculated as the STAGE_HEIGHT - count * COLUMN_WIDTH, which prevents it falling further
Code edit (2 edits merged)
Please save this source code
User prompt
instead of using tick offset for box spawning, columns should have a countdown variable that is randomly set after creation and after spawning a box
User prompt
The columns should be updated in the tick callback, not on creation silly
User prompt
columns should handle the spawning of boxes in an update function instead
User prompt
Fix Bug: 'ReferenceError: floor is not defined' in this line: 'if (self.y > floor.y - self.height) {' Line Number: 57
User prompt
Fix Bug: 'TypeError: LK.tween is not a function' in this line: 'LK.tween(player, {' Line Number: 94
User prompt
it should take the player 0.2s to move from it's old position, and should also rotate 90 degrees during the move
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,5 @@
-var ScoreInterface = Container.expand(function (parent) {
+var Interface = Container.expand(function (parent) {
var self = Container.call(this);
parent.addChild(self);
var score = 0;
var scoreTxt = new Text2(score.toString(), {
@@ -7,13 +7,22 @@
fill: "#ffffff"
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
- self.increment = function (value) {
+ ;
+ self.increment = increment;
+ self.gameOver = gameOver;
+ ;
+ function increment(value) {
score += value;
scoreTxt.setText(score.toString());
LK.setScore(score);
- };
+ }
+ ;
+ function gameOver() {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
});
var Box = Container.expand(function (parent, x, y, targetHeight) {
var self = Container.call(this);
parent.addChild(self);
@@ -37,19 +46,47 @@
self.hitbox = hitboxGraphics;
self.update = update;
self.squash = squash;
;
- function update() {
+ function update(args) {
+ var {interface, player} = args;
if (self.falling) {
speed += BOX_GRAVITY;
self.y += speed;
if (self.y >= targetHeight) {
self.falling = false;
self.y = targetHeight;
speed = 0;
parent.count++;
+ } else if (player.intersects(box.hitbox)) {
+ switch (type) {
+ case 'gold':
+ case 'points':
+ self.alive = false;
+ self.active = true;
+ break;
+ case 'tnt':
+ self.active = true;
+ default:
+ if (!player.invulnerable) {
+ interface.gameOver();
+ }
+ break;
+ }
}
}
+ if (self.active) {
+ switch (type) {
+ case 'gold':
+ break;
+ case 'points':
+ interface.increment(POINTS_GAIN_PICKUP);
+ break;
+ case 'tnt':
+ break;
+ }
+ }
+ return !self.alive;
}
function squash(target) {
if (target instanceof Player) {
switch (type) {
@@ -180,8 +217,10 @@
var SPAWN_TNT_CHANCE = 0.03;
var SPAWN_GOLD_CHANCE = 0.01;
var SPAWN_POINTS_CHANCE = 0.05;
var SPAWN_STONE_CHANCE = 0.1;
+var POINTS_GAIN_CLIMBING = 1;
+var POINTS_GAIN_PICKUP = 5;
var BOX_SPEED = 5;
var BOX_GRAVITY = 0.2;
var FLOOR_OFFSET = 100;
var COLUMN_VOLUME = Math.floor((STAGE_HEIGHT - FLOOR_OFFSET) / BOX_HEIGHT);
@@ -226,9 +265,9 @@
}
var player = self.addChild(new Player(self, STAGE_WIDTH / 2, STAGE_HEIGHT - FLOOR_OFFSET - PLAYER_SIZE / 2));
var isGameOver = false;
var tickOffset = 0;
- var scoreInterface = new ScoreInterface(self);
+ var interface = new Interface(self);
;
stage.on('down', function (obj) {
var event = obj.event;
lastTouchX = event.global.x;
@@ -264,28 +303,23 @@
}
}
});
LK.on('tick', function () {
- if (isGameOver) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
+ if (isGameOver) {}
player.update({
columns
});
columns.forEach(function (column) {
column.update(boxes, tickOffset);
});
for (var i = boxes.length - 1; i >= 0; i--) {
var box = boxes[i];
- box.update();
- if (box.y > STAGE_HEIGHT) {
+ if (box.update({
+ interface,
+ player
+ })) {
box.destroy();
boxes.splice(i, 1);
- } else if (box.active && player.intersects(box.hitbox)) {
- if (!player.invulnerable) {
- isGameOver = true;
- }
}
}
});
});
Pixel art, side view of a concrete factory floor . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art, square with cute eyes . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art, square with the texture of a tnt . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a crate, side view . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a crate, flat side view . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a crate, flat side view . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of a golden christmas present. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of a green christmas present with red ribbons. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of an elaborate green christmas present with red ribbons. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a metal background.
pixel art of a crate made of stone with a label of coal on the side, flat side view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a square tnt explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.