Code edit (13 edits merged)
Please save this source code
User prompt
prevent box shadow scale being less than the `SHADOW_MIN_SCALE` value
User prompt
add a global called `SHADOW_MIN_SCALE` of value 0.1
User prompt
Fix Bug: 'ReferenceError: count is not defined' in this line: 'if (countdown <= 0) {' Line Number: 329
Code edit (1 edits merged)
Please save this source code
User prompt
Rename `shiftContainer` function to `shift` for all classes
User prompt
Fix Bug: 'ReferenceError: shift is not defined' in this line: 'self.shift = shift;' Line Number: 95
User prompt
Rename `shiftContainer` to `shift` for all classes
User prompt
Rename `shiftContainer` to `shift` for all classes
User prompt
Remove the unused shift variable from the shiftableContainer class only
User prompt
Rename every single occurrence of `baseShiftContainer` to `baseShift`
User prompt
Fix Bug: 'ReferenceError: baseShiftContainer is not defined' in this line: 'baseShiftContainer(amount);' Line Number: 574
User prompt
Fix Bug: 'ReferenceError: baseShiftContainer is not defined' in this line: 'baseShiftContainer();' Line Number: 119
User prompt
Rename every single occurrence of `baseShiftContainer` to `baseShift`
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Box.expend is not a function' in this line: 'var InvisBox = Box.expend(function (x, y, args) {' Line Number: 556
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in the box update method, before checking the alive state, set self.alive to false if the box's y value goes above: `STAGE_HEIGHT + BOX_HEIGHT / 2`
Code edit (3 edits merged)
Please save this source code
User prompt
add an isPaused = false variable to the interface class, which when true prevents non-interface update ticks
User prompt
Add a global TERMINAL_VELOCITY = 20 and make sure boxes and the player never exceeds this value while falling
User prompt
Replace both PLAYER_GRAVITY and BOX_GRAVITY with a single GRAVITY global of 0.5. Make sure to update old references in the box and player class
Code edit (7 edits merged)
Please save this source code
User prompt
remove all console.log commands in the tnt explode function
===================================================================
--- original.js
+++ change.js
@@ -176,17 +176,21 @@
self.collide = collide;
self.touch = touch;
;
function build(name, xAnchor, yAnchor, variations) {
- var nameVariant = !variations || variations <= 1 ? '' : 1 + Math.floor(Math.random() * variations);
- var boxGraphics = self.createAsset(name + nameVariant + 'Box', 'Box graphics', xAnchor, yAnchor);
+ var boxGraphics;
+ if (name) {
+ var nameVariant = !variations || variations <= 1 ? '' : 1 + Math.floor(Math.random() * variations);
+ boxGraphics = self.createAsset(name + nameVariant + 'Box', 'Box graphics', xAnchor, yAnchor);
+ }
var shadowGraphics = self.createAsset('shadow', 'Shadow image', 0.5, 0.5);
var hitboxGraphics = self.createAsset('hitbox', 'Hitbox graphics', .5, .25);
shadowGraphics.alpha = 0.5;
shadowGraphics.y = -BOX_HEIGHT * 0.5;
hitboxGraphics.width = BOX_WIDTH * 0.9;
hitboxGraphics.height = BOX_HEIGHT * 0.6;
hitboxGraphics.alpha = 0;
+ self.graphic = boxGraphics;
self.hitbox = hitboxGraphics;
self.shadow = shadowGraphics;
}
function update(args) {
@@ -315,9 +319,9 @@
function activation(args) {
if (countdown <= 0) {
explode(args);
} else if (countdown % 20 === 0) {
- LK.effects.flashObject(self, 0xff0000, 500);
+ LK.effects.flashObject(self.graphic, 0xff0000, 500);
}
countdown--;
}
function collide(args) {
@@ -358,9 +362,9 @@
if (box.y > min) {
if (box !== self) {
if (box instanceof TntBox) {
box.active = true;
- } else if (!(box instanceof StoneBox)) {
+ } else if (!(box instanceof StoneBox || box instanceof InvisBox)) {
box.alive = false;
}
}
} else {
@@ -373,13 +377,10 @@
}
});
var Column = Container.expand(function (x, y, index) {
var self = Container.call(this);
- var boxes = [];
+ var boxes = [self.add(new InvisBox(0, STAGE_HEIGHT - FLOOR_OFFSET))];
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.x = x;
self.y = y;
self.boxes = boxes;
@@ -414,15 +415,8 @@
}
}
}
function update(args) {
- var upperBox = boxes[0];
- var shadowVisible = upperBox && upperBox.falling;
- shadowGraphics.visible = shadowVisible;
- if (shadowVisible) {
- var scale = 1 - (STAGE_HEIGHT - FLOOR_OFFSET - upperBox.y) / STAGE_HEIGHT;
- shadowGraphics.scale.set(scale);
- }
if (--countdown <= 0) {
countdown = getCountdown();
if (self.count < COLUMN_VOLUME) {
var {boxList, game} = args;
@@ -446,13 +440,11 @@
}
}
}
});
-var Player = Container.expand(function (x, y) {
- var self = Container.call(this);
- self.x = x;
- self.y = y;
- ;
+var Player = ShiftableContainer.expand(function (x, y) {
+ var self = ShiftableContainer.call(this);
+ var baseShiftContainer = self.shiftContainer;
var isJumping = false;
var verticalSpeed = 0;
var floorHeight = y;
var targetColumn = Math.floor(x / BOX_WIDTH);
@@ -463,15 +455,18 @@
hitboxGraphics.width = PLAYER_SIZE * 0.6;
hitboxGraphics.height = PLAYER_SIZE * 0.8;
hitboxGraphics.alpha = 0;
;
+ self.x = x;
+ self.y = y;
self.heightClimbed = 0;
self.invulnerability = 0;
self.airborne = false;
self.hitbox = hitboxGraphics;
self.move = move;
self.jump = jump;
self.update = update;
+ self.shiftContainer = shiftContainer;
;
function getColIndex() {
return Math.floor(self.x / BOX_WIDTH);
}
@@ -539,16 +534,31 @@
newColIndex = colIndex;
}
}
if (!self.airborne) {
+ var heightIndex = Math.round(self.heightClimbed / BOX_HEIGHT);
columnList[newColIndex].touch(self, rowIndex - 1);
- if (rowIndex > self.heightClimbed) {
- interface.increment((newRowIndex - self.heightClimbed) * POINTS_GAIN_CLIMBING);
- self.heightClimbed = rowIndex;
+ if (rowIndex > heightIndex) {
+ interface.increment((newRowIndex - heightIndex) * POINTS_GAIN_CLIMBING);
+ self.heightClimbed = newRowIndex * BOX_HEIGHT;
+ if (heightIndex >= SHIFT_THRESHOLD) {
+ return true;
+ }
}
}
+ return false;
}
+ function shiftContainer(amount) {
+ baseShiftContainer(amount);
+ ;
+ self.heightClimbed -= amount;
+ }
});
+var InvisBox = Box.expand(function (x, y, args) {
+ var self = Box.call(this, x, y, args);
+ ;
+ self.build();
+});
;
var STAGE_WIDTH = 2048;
var STAGE_HEIGHT = 2732;
var STAGE_TICKS = 60;
@@ -575,9 +585,9 @@
var INVULNERABILITY_TIME = 5 * STAGE_TICKS;
var INSTRUCTION_DURATION = 5 * STAGE_TICKS;
var SHIFT_THRESHOLD = 6;
var SHIFT_COUNT = 3;
-var SHIFT_DURATION = STAGE_TICKS / 2;
+var SHIFT_DURATION = STAGE_TICKS / 3;
var SHIFT_AMOUNT = SHIFT_COUNT * BOX_HEIGHT / SHIFT_DURATION;
var BOX_SPEED = 5;
var BOX_GRAVITY = 0.2;
var TNT_COUNTDOWN = 2 * STAGE_TICKS;
@@ -641,10 +651,10 @@
LK.on('tick', function () {
if (interface.isGameOver) {
interface.gameOver();
} else if (interface.isPaused = shiftTicks > 0) {
- shiftTicks--;
var containers = [[background, floor, player], boxList, effectList];
+ shiftTicks--;
containers.forEach(function (subContainers) {
subContainers.forEach(function (container) {
container.shiftContainer(SHIFT_AMOUNT);
});
@@ -653,9 +663,11 @@
var playerArgs = {
interface,
columnList
};
- player.update(playerArgs);
+ if (player.update(playerArgs)) {
+ shiftTicks += SHIFT_DURATION;
+ }
;
var columnArgs = {
game: self,
boxList
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.