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
User prompt
boxes should get increasingly faster as if affected by gravity
User prompt
boxes have a 1% chance of being a tnt instead
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: COLUMN_WIDTH is not defined' in this line: 'player.x = Math.floor(2048 / 2 / COLUMN_WIDTH) * COLUMN_WIDTH + COLUMN_WIDTH / 2;' Line Number: 97
User prompt
Create a columns array that holds a Column class instances.
User prompt
if quickly tapping on the screen, make the player jump
User prompt
the player can move a maximum of 1 column when swiping
User prompt
add a hitbox asset to the box class that, the player should check the hitbox instead of the box for intersections
User prompt
Add a floor image that is the full width of the game
User prompt
if the player collides with a box it's game over
User prompt
Fix Bug: 'TypeError: event.data is undefined' in this line: 'var currentTouchX = event.data.global.x;' Line Number: 27
User prompt
Fix Bug: 'TypeError: event.data is undefined' in this line: 'lastTouchX = event.data.global.x;' Line Number: 22
User prompt
instead of the player moving with the mouse, the player should move on swipe left or right
User prompt
divide the stage width equally into 16 columns, and align both the player and the boxes to the columns
User prompt
Fix Bug: 'TypeError: boxes[a] is undefined' in this line: 'boxes[a].move();' Line Number: 37
User prompt
Fix Bug: 'TypeError: player.update is not a function' in this line: 'player.update();' Line Number: 32
===================================================================
--- original.js
+++ change.js
@@ -10,17 +10,21 @@
var boxGraphics = self.createAsset(type + 'Box', 'Box graphics', .5, .5);
var hitboxGraphics = self.createAsset('hitbox', 'Hitbox graphics', .5, .5);
hitboxGraphics.alpha = 0.5;
;
+ self.active = true;
self.hitbox = hitboxGraphics;
self.update = update;
;
function update() {
- speed += BOX_GRAVITY;
- self.y += speed;
- if (self.y > targetHeight) {
- self.y = targetHeight;
- speed = 0;
+ if (self.active) {
+ speed += BOX_GRAVITY;
+ self.y += speed;
+ if (self.y >= targetHeight) {
+ self.active = false;
+ self.y = targetHeight;
+ speed = 0;
+ }
}
}
});
var Floor = Container.expand(function (parent, x, y) {
@@ -38,26 +42,31 @@
self.x = x;
self.y = y;
;
var playerGraphics = self.createAsset('player', 'Player character', .5, .5);
+ ;
self.isJumping = false;
self.jumpHeight = 150;
self.jumpSpeed = -15;
self.gravity = 0.5;
self.verticalSpeed = 0;
- self.move = function (x, y) {
+ self.move = move;
+ self.jump = jump;
+ self.update = update;
+ ;
+ function move(x, y) {
self.x = x;
if (!self.isJumping) {
self.y = y;
}
- };
- self.jump = function () {
+ }
+ function jump() {
if (!self.isJumping) {
self.isJumping = true;
self.verticalSpeed = self.jumpSpeed;
}
- };
- self.update = function () {
+ }
+ function update() {
if (self.isJumping) {
self.verticalSpeed += self.gravity;
self.y += self.verticalSpeed;
if (self.y > FLOOR_OFFSET - self.height) {
@@ -65,9 +74,9 @@
self.isJumping = false;
self.verticalSpeed = 0;
}
}
- };
+ }
});
var Column = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
@@ -80,10 +89,9 @@
self.update = update;
;
function update(boxes) {
if (--countdown <= 0) {
- count++;
- boxes.push(new Box(self, x, y + SPAWN_OFFSET, STAGE_HEIGHT - count * COLUMN_WIDTH));
+ boxes.push(new Box(self, x, y + SPAWN_OFFSET, STAGE_HEIGHT - count++ * COLUMN_WIDTH));
countdown = SPAWN_CONST + Math.floor(Math.random() * SPAWN_VARIANCE);
}
}
});
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.