User prompt
Fix Bug: 'TypeError: self.children.order is not a function' in this line: 'self.children.order(function (a, b) {' Line Number: 488
Code edit (3 edits merged)
Please save this source code
User prompt
player starts off being invulnerable for the invulnerability time
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: DEATH_CRUSH_STONE is not defined' in this line: 'self.deathReason = DEATH_CRUSH_STONE;' Line Number: 286
Code edit (1 edits merged)
Please save this source code
User prompt
when the interface's gameover function is called, display the death reason as a BorderedText below the score, and additionally call the hideInstructions function
Code edit (4 edits merged)
Please save this source code
User prompt
add a deathReason variable to the interface
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -17,14 +17,8 @@
fill: settings.fill || defaultFill,
font: settings.font || defaultFont,
size: settings.size || defaultSize
};
- ;
- self.x = settings.x;
- self.y = settings.y;
- self.setText = setText;
- self.setFill = setFill;
- ;
for (var i = 0; i < offsets.length; i++) {
var localSettings = i === offsets.length - 1 ? textSettings : borderSettings;
var text = self.addChild(new Text2(string, localSettings));
text.x += offsets[i][0] * weight;
@@ -34,22 +28,26 @@
}
textList.push(text);
}
;
+ self.x = settings.x;
+ self.y = settings.y;
+ self.setText = setText;
+ self.setFill = setFill;
+ ;
function setText(string) {
for (var i = 0; i < textList.length; i++) {
textList[i].setText(string);
}
}
- ;
function setFill(newFill) {
textList[textList.length - 1].fill = newFill;
}
- ;
});
var Interface = Container.expand(function () {
var self = Container.call(this);
var score = 0;
+ var shown = true;
var scoreTxt = self.addChild(new BorderedText(score.toString(), {
size: 150,
anchor: {
x: .5
@@ -83,10 +81,13 @@
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
function hideInstructions() {
- moveInstructions.destroy();
- jumpInstructions.destroy();
+ if (shown) {
+ shown = false;
+ moveInstructions.destroy();
+ jumpInstructions.destroy();
+ }
}
});
var ShiftableContainer = Container.expand(function () {
var self = Container.call(this);
@@ -102,9 +103,9 @@
return self;
});
var Background = ShiftableContainer.expand(function () {
var self = ShiftableContainer.call(this);
- var baseShiftContainer = self.shiftContainer;
+ var baseShift = self.shiftContainer;
var backgroundBotGraphics = self.createAsset('background', 'Background Top image', 0, 0);
var backgroundTopGraphics = self.createAsset('background', 'Background Top image', 0, 0);
backgroundBotGraphics.width = STAGE_WIDTH;
backgroundBotGraphics.height = STAGE_HEIGHT;
@@ -159,8 +160,9 @@
}
});
var Box = ShiftableContainer.expand(function (x, y, args) {
var self = ShiftableContainer.call(this);
+ var baseShift = self.shiftContainer;
var {index, column} = args;
var speed = BOX_SPEED;
;
self.x = x;
@@ -191,8 +193,9 @@
hitboxGraphics.alpha = 0;
self.graphic = boxGraphics;
self.hitbox = hitboxGraphics;
self.shadow = shadowGraphics;
+ self.shiftContainer = shiftContainer;
}
function update(args) {
var destroyNextTick = false;
var upperBox = column.boxes[self.index + 1];
@@ -205,9 +208,9 @@
if (self.falling) {
var {player} = args;
speed += self.gravity;
self.y += speed;
- var targetHeight = STAGE_HEIGHT - (self.index + 0.5) * BOX_HEIGHT - FLOOR_OFFSET - self.shift;
+ var targetHeight = BOX_LINE - self.index * BOX_HEIGHT;
if (self.y >= targetHeight) {
speed = 0;
self.x = 0;
self.y = targetHeight;
@@ -221,11 +224,8 @@
}
if (self.active) {
self.activation(args);
}
- if (self.y > STAGE_HEIGHT + BOX_HEIGHT / 2) {
- self.alive = false;
- }
if (!self.alive) {
column.remove(self);
return true;
}
@@ -241,8 +241,16 @@
}
return false;
}
function touch(target) {}
+ function shiftContainer(amount) {
+ baseShiftContainer(amount);
+ ;
+ if (self.y > BOX_LINE) {
+ column.remove(self);
+ return true;
+ }
+ }
;
return self;
});
var InvisBox = Box.expand(function (x, y, args) {
@@ -380,12 +388,19 @@
}
}
}
});
-var Column = Container.expand(function (x, y, index) {
+var Column = Container.expand(function (x, y, args) {
var self = Container.call(this);
- var boxes = [self.add(new InvisBox(0, STAGE_HEIGHT - FLOOR_OFFSET))];
+ var {index, boxList} = args;
+ var boxes = [];
var countdown = SPAWN_INITIAL + getCountdown();
+ var defaultBox = self.addChild(new InvisBox(0, BOX_LINE, {
+ column: self,
+ index: 0
+ }));
+ boxList.push(defaultBox);
+ boxes.push(defaultBox);
;
self.x = x;
self.y = y;
self.boxes = boxes;
@@ -423,9 +438,9 @@
function update(args) {
if (--countdown <= 0) {
countdown = getCountdown();
if (self.count < COLUMN_VOLUME) {
- var {boxList, game} = args;
+ var {boxList} = args;
var typeValue = Math.random();
var typeInstance = BasicBox;
if ((typeValue -= SPAWN_GOLD_CHANCE) < 0) {
typeInstance = GoldBox;
@@ -435,9 +450,9 @@
typeInstance = PointsBox;
} else if ((typeValue -= SPAWN_STONE_CHANCE) < 0) {
typeInstance = StoneBox;
}
- var box = game.addChild(new typeInstance(self.x, SPAWN_OFFSET, {
+ var box = self.addChild(new typeInstance(0, SPAWN_OFFSET, {
column: self,
index: boxes.length
}));
boxList.push(box);
@@ -447,9 +462,9 @@
}
});
var Player = ShiftableContainer.expand(function (x, y) {
var self = ShiftableContainer.call(this);
- var baseShiftContainer = self.shiftContainer;
+ var baseShift = self.shiftContainer;
var isJumping = false;
var verticalSpeed = 0;
var floorHeight = y;
var targetColumn = Math.floor(x / BOX_WIDTH);
@@ -475,9 +490,9 @@
function getColIndex() {
return Math.floor(self.x / BOX_WIDTH);
}
function getRowIndex() {
- return Math.floor((STAGE_HEIGHT - self.y - FLOOR_OFFSET) / BOX_HEIGHT);
+ return Math.floor((BOX_LINE - self.y) / BOX_HEIGHT + 0.5);
}
function move(direction) {
var colIndex = getColIndex();
if (targetColumn === colIndex) {
@@ -494,9 +509,9 @@
var {interface, columnList} = args;
var colIndex = getColIndex();
var rowIndex = getRowIndex();
var targetX = (targetColumn + 0.5) * BOX_WIDTH;
- var targetY = floorHeight - columnList[colIndex].count * BOX_HEIGHT;
+ var targetY = BOX_LINE - columnList[colIndex].count * BOX_HEIGHT;
if (self.invulnerability > 0) {
self.invulnerability--;
if (self.invulnerability === 60 || self.invulnerability === 30) {
LK.effects.flashObject(playerGraphics, 0x000000, 1000);
@@ -517,8 +532,11 @@
if (self.y >= targetY) {
self.y = targetY;
self.airborne = false;
verticalSpeed = 0;
+ if (self.y === BOX_LINE) {
+ interface.isGameOver = true;
+ }
}
} else {
if (self.y < targetY) {
self.airborne = true;
@@ -566,8 +584,11 @@
var CONTROL_TAP_TICKS = STAGE_TICKS / 3;
var NUM_COLUMNS = 9;
var BOX_WIDTH = STAGE_WIDTH / NUM_COLUMNS;
var BOX_HEIGHT = 0.75 * BOX_WIDTH;
+var BOX_LINE = STAGE_HEIGHT;
+var BOX_SPEED = 5;
+var BOX_GRAVITY = 0.2;
var PLAYER_SIZE = 0.8 * BOX_WIDTH;
var PLAYER_GRAVITY = 0.5;
var PLAYER_JUMP_SPEED = 20;
var PLAYER_MOVE_SPEED = 25;
@@ -587,13 +608,10 @@
var SHIFT_THRESHOLD = 6;
var SHIFT_COUNT = 3;
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;
-var FLOOR_OFFSET = 100;
-var COLUMN_VOLUME = Math.floor((STAGE_HEIGHT - FLOOR_OFFSET) / BOX_HEIGHT) + 1;
+var COLUMN_VOLUME = Math.ceil(BOX_LINE / BOX_HEIGHT);
;
var Game = Container.expand(function () {
var self = Container.call(this);
;
@@ -603,16 +621,19 @@
var boxList = [];
var effectList = [];
var columnList = [];
var shiftTicks = 0;
- ;
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, i)));
+ columnList.push(self.addChild(new Column((i + 0.5) * BOX_WIDTH, 0, {
+ index: i,
+ boxList
+ })));
}
- var player = self.addChild(new Player(STAGE_WIDTH / 2, STAGE_HEIGHT - FLOOR_OFFSET - PLAYER_SIZE / 2));
+ var player = self.addChild(new Player(STAGE_WIDTH / 2, BOX_LINE - PLAYER_SIZE / 2));
var interface = LK.gui.topCenter.addChild(new Interface());
+ var shiftContainers = [[player, background, floor], boxList, effectList];
;
stage.on('down', function (obj) {
var event = obj.event;
lastTouchX = event.global.x;
@@ -634,11 +655,13 @@
var deltaX = lastTouchX - event.global.x;
var deltaY = lastTouchY - event.global.y;
if (Math.abs(deltaX) > CONTROL_SWIPE_DIST) {
var direction = deltaX > 0 ? -1 : 1;
+ interface.hideInstructions();
player.move(direction);
reset = true;
} else if (deltaY > CONTROL_SWIPE_DIST) {
+ interface.hideInstructions();
player.jump();
reset = true;
}
if (reset) {
@@ -651,14 +674,17 @@
LK.on('tick', function () {
if (interface.isGameOver) {
interface.gameOver();
} else if (interface.isPaused = shiftTicks > 0) {
- var containers = [[background, floor, player], boxList, effectList];
shiftTicks--;
- containers.forEach(function (subContainers) {
- subContainers.forEach(function (container) {
- container.shiftContainer(SHIFT_AMOUNT);
- });
+ shiftContainers.forEach(function (containers) {
+ for (var i = containers.length - 1; i >= 0; i--) {
+ var container = containers[i];
+ if (container.shiftContainer(SHIFT_AMOUNT)) {
+ container.destroy();
+ containers.splice(i, 1);
+ }
+ }
});
} else {
var playerArgs = {
interface,
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.