Code edit (3 edits merged)
Please save this source code
User prompt
when a TNT box countdown expires, create an ExplosionEffect centered on the TNT as a child of the game variable, and add it to the effectsList
Code edit (1 edits merged)
Please save this source code
User prompt
create an effectList array in the game class, iterate through it in the on tick calling their update function; if it returns truthy, remove and delete the effect
Code edit (9 edits merged)
Please save this source code
User prompt
create an explosion effect class
User prompt
while counting down, the tnt type box should flash red every 30 ticks (self.countdown % 30)
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Move the column shadow to the box class
Code edit (2 edits merged)
Please save this source code
User prompt
column shadow is only visible if the boxes array size is greater than the count
Code edit (1 edits merged)
Please save this source code
User prompt
Columns should have a sub-container called boxContainer that holds Boxes
Code edit (7 edits merged)
Please save this source code
User prompt
Columns have a shadow asset which has its y property set to: `STAGE_HEIGHT - FLOOR_OFFSET - BOX_HEIGHT * self.count` in the update function
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -124,9 +124,9 @@
self.update = update;
self.squash = squash;
;
function update(args) {
- var {interface, player} = args;
+ var {columnList, interface, player} = args;
var destroyNextTick = false;
var upperBox = column.boxes[self.index + 1];
var shadowVisible = upperBox && upperBox.falling;
shadowGraphics.visible = shadowVisible;
@@ -144,18 +144,21 @@
self.y = targetHeight;
speed = 0;
column.count++;
column.squash(self, self.index - 1);
- column.boxContainer.addChild(self);
+ column.addChild(self);
} else if (player.intersects(self.hitbox)) {
switch (type) {
case 'gold':
case 'points':
destroyNextTick = true;
self.active = true;
break;
case 'tnt':
- self.active = true;
+ if (!self.active) {
+ self.active = true;
+ self.countdown = TNT_COUNTDOWN;
+ }
default:
if (!player.invulnerability) {
interface.gameOver();
}
@@ -171,8 +174,44 @@
case 'points':
interface.increment(POINTS_GAIN_PICKUP);
break;
case 'tnt':
+ if (self.countdown !== undefined) {
+ if (--self.countdown <= 0) {
+ self.alive = false;
+ } else if (self.countdown % 30 === 0) {
+ LK.effects.flashObject(self, 0xff0000, 500);
+ }
+ var min = self.y - BOX_HEIGHT * 1.25;
+ var max = self.y + BOX_HEIGHT * 1.25;
+ for (var i = column.index - 1; i <= column.index + 1; i++) {
+ var col = columnList[i];
+ if (col) {
+ for (var j = 0; j < col.boxes.length; j++) {
+ var box = col.boxes[j];
+ if (box.y > min) {
+ if (box.y < max) {
+ if (box !== self) {
+ switch (box.type) {
+ case 'stone':
+ break;
+ case 'tnt':
+ box.active = true;
+ box.countdown = 0;
+ break;
+ default:
+ box.alive = false;
+ break;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
break;
}
}
if (!self.alive) {
@@ -188,11 +227,16 @@
switch (type) {
case 'gold':
case 'points':
self.alive = false;
- case 'tnt':
self.active = true;
break;
+ case 'tnt':
+ if (!self.active) {
+ self.active = true;
+ self.countdown = TNT_COUNTDOWN;
+ }
+ break;
}
} else if (target.type === 'stone') {
switch (type) {
case 'gold':
@@ -200,28 +244,28 @@
self.alive = false;
break;
case 'tnt':
self.active = true;
+ self.countdown = 0;
break;
}
}
}
});
-var Column = Container.expand(function (x, y) {
+var Column = Container.expand(function (x, y, index) {
var self = Container.call(this);
self.x = x;
self.y = y;
;
var boxes = [];
- var boxContainer = self.addChild(new Container());
var countdown = SPAWN_INITIAL + getCountdown();
var shadowGraphics = self.createAsset('shadow', 'Shadow image', 0.5, 0.5);
shadowGraphics.alpha = 0.5;
shadowGraphics.y = STAGE_HEIGHT - FLOOR_OFFSET;
;
self.count = 0;
self.boxes = boxes;
- self.boxContainer = boxContainer;
+ self.index = index;
self.squash = squash;
self.remove = remove;
self.update = update;
;
@@ -380,9 +424,9 @@
var PLAYER_GRAVITY = 0.5;
var PLAYER_JUMP_SPEED = 20;
var PLAYER_MOVE_SPEED = 15;
var SPAWN_OFFSET = -100;
-var SPAWN_INITIAL = 5 * STAGE_TICKS;
+var SPAWN_INITIAL = 3 * STAGE_TICKS;
var SPAWN_CONST = STAGE_TICKS / 2;
var SPAWN_VARIANCE = 10 * STAGE_TICKS - SPAWN_CONST;
var SPAWN_COUNT_VARIANCE = STAGE_TICKS / 4;
var SPAWN_TNT_CHANCE = 0.03;
@@ -394,8 +438,9 @@
var INVULNERABILITY_TIME = 5 * STAGE_TICKS;
var INSTRUCTION_DURATION = 5 * STAGE_TICKS;
var BOX_SPEED = 5;
var BOX_GRAVITY = 0.2;
+var TNT_COUNTDOWN = 2 * STAGE_TICKS;
var FLOOR_OFFSET = 100;
var COLUMN_VOLUME = Math.floor((STAGE_HEIGHT - FLOOR_OFFSET) / BOX_HEIGHT) + 1;
var BOX_SETTINGS = {
basic: {
@@ -426,19 +471,19 @@
};
;
var Game = Container.expand(function () {
var self = Container.call(this);
- var background = self.addChild(new Background(self));
;
var lastTouchX = null;
var lastTouchY = null;
var touchTime = null;
var boxList = [];
var columnList = [];
;
+ var background = self.addChild(new Background(self));
var floor = self.addChild(new Floor(STAGE_WIDTH / 2, STAGE_HEIGHT));
for (var i = 0; i < NUM_COLUMNS; i++) {
- columnList.push(self.addChild(new Column((i + 0.5) * BOX_WIDTH, 0)));
+ columnList.push(self.addChild(new Column((i + 0.5) * BOX_WIDTH, 0, i)));
}
var player = self.addChild(new Player(STAGE_WIDTH / 2, STAGE_HEIGHT - FLOOR_OFFSET - PLAYER_SIZE / 2));
var interface = LK.gui.topCenter.addChild(new Interface());
;
@@ -487,21 +532,23 @@
var columnArgs = {
game: self,
boxList
};
- for (var i = columnList.length - 1; i >= 0; i--) {
+ for (var i = 0; i < columnList.length; i++) {
columnList[i].update(columnArgs);
}
;
var boxArgs = {
+ columnList,
interface,
player
};
- for (var i = boxList.length - 1; i >= 0; i--) {
+ for (var i = 0; i < boxList.length; i++) {
var box = boxList[i];
if (box.update(boxArgs)) {
box.destroy();
boxList.splice(i, 1);
+ i--;
}
}
;
if (LK.ticks === INSTRUCTION_DURATION) {
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.