Code edit (2 edits merged)
Please save this source code
User prompt
convert interface text2 to use BorderedText instead
Code edit (3 edits merged)
Please save this source code
User prompt
add a background class
User prompt
Add a fullscreen background before the floor
Code edit (4 edits merged)
Please save this source code
User prompt
Display the following text under the score "Swipe left or right to move" and "Swipe up or tap to jump" under that
User prompt
set initial invulnerability to 0
User prompt
player no longer starts invulnerable
Code edit (1 edits merged)
Please save this source code
User prompt
player starts with invulnerability equal to INVULNERABILITY_TIME
Code edit (1 edits merged)
Please save this source code
User prompt
flash the player black when invulnerability reaches 60 and 30
User prompt
tint the player gold while it is invulnerable
Code edit (1 edits merged)
Please save this source code
User prompt
decrement player invulnerability in it's update function if it's greater than 0
Code edit (8 edits merged)
Please save this source code
User prompt
Change `invulnerability` from `true` to `0`
User prompt
Rename the player's `invulnerable` variable to `invulnerability` and update checks in other classes
Code edit (7 edits merged)
Please save this source code
User prompt
Increase COLUMN_VOLUME by 1
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- 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.