Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: removedElement is null' in this line: 'removedElement.destroy();' Line Number: 249
Code edit (8 edits merged)
Please save this source code
User prompt
the new trailelement should be scaled and rotated to match the velocity
User prompt
Add an update function that takes in a velocityX and velocityY to the Trail class. The update function creates a `blank` asset and adds it to a list, if the list has more than 60 elements the first element is removed. All elements have their x and y adjusted by the velocityX and velocityY
User prompt
Create a Trail class that takes a `parent`, `x`, and `y` parameters
User prompt
Create a Trail class that takes a `parent`, `x`, `y`, and `args` parameters.
Code edit (1 edits merged)
Please save this source code
User prompt
make the player invulnerable for 3 seconds after landscapeTile.checkCollision returns true
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
flash the screen red when losing a life instead of on game over
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: scoreText is not defined' in this line: 'scoreText.setText(score);' Line Number: 328
User prompt
Move the displayed score, score icon and lives into its own Interface class. This class should have changeLives(amount) and changeScore(amount) functions which change the score and lives values by the amount
User prompt
Fix Bug: 'TypeError: self.gameInstance.lifeIcons is undefined' in this line: 'var lifeIcon = self.gameInstance.lifeIcons[self.gameInstance.lives];' Line Number: 191
User prompt
Fix Bug: 'TypeError: self.parent.lifeIcons is undefined' in this line: 'var lifeIcon = self.parent.lifeIcons[self.parent.lives];' Line Number: 190
User prompt
The player should have 3 lives, displayed as three icons under the score. The player should lose 1 life when colliding with an obstacle, and the obstacle should become inactive
User prompt
Fix Bug: 'ReferenceError: velocityX is not defined' in this line: 'playerGraphics.scale.x = velocityX < 0 ? -1 : 1;' Line Number: 193
Code edit (1 edits merged)
Please save this source code
User prompt
landscapeTiles should create the pickup before the obstructions, additionally, if a pickup is created, prevent spawning obstructions within 200 distance from the pickup
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
when a pickup is within 200*200 distance squared from the player, the pickup becomes active, flying towards the player at a speed of 5
Code edit (4 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -74,20 +74,20 @@
var densityChance = Math.pow(1 + density, 3) / 100;
var obstructionTypes = ['largeTree', 'smallTree', 'deadTree', 'rock', 'stump'];
var clearanceDist = 150;
var clearanceDistSqr = clearanceDist * clearanceDist;
- var spawnBorder = 10;
- var cellSize = 100;
+ var spawnBorder = 25;
+ var cellSize = 150;
var cols = Math.ceil(width / cellSize);
var rows = Math.ceil(height / cellSize);
var cellWidth = width / cols;
var cellHeight = height / rows;
var cellInnerWidth = Math.max(0, cellWidth - 2 * spawnBorder);
var cellInnerHeight = Math.max(0, cellHeight - 2 * spawnBorder);
var pickup;
if (Math.random() <= 0.1) {
- pickupX = self.x + Math.random() * width - width / 2;
- pickupY = self.y + Math.random() * height - height / 2;
+ var pickupX = self.x - width / 2 + spawnBorder + Math.random() * (width - spawnBorder * 2);
+ var pickupY = self.y - height / 2 + spawnBorder + Math.random() * (height - spawnBorder * 2);
pickups.push(pickup = new Pickup(parent, pickupX, pickupY));
}
for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
@@ -168,18 +168,39 @@
self.hitbox.alpha = 0;
self.hitbox.width = graphics.width * 0.8;
self.hitbox.height = graphics.width * 0.45;
});
-var Player = Container.expand(function () {
+var Player = Container.expand(function (parent, x, y) {
var self = Container.call(this);
- self.playerGraphics = self.createAsset('player', 'Player character', 0.575, 1);
- self.platformGraphics = self.createAsset('platform', 'Platform image', 0.5, 0.5);
- self.addChild(self.playerGraphics);
- self.hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
- self.hitbox.width = 25;
- self.hitbox.height = 25;
- self.hitbox.alpha = 0;
- self.addChild(self.hitbox);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
+ self.update = update;
+ var speed = 0;
+ var playerGraphics = self.createAsset('player', 'Player character', 0.575, 1);
+ var platformGraphics = self.createAsset('platform', 'Platform image', 0.5, 0.5);
+ var hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
+ hitbox.width = 25;
+ hitbox.height = 25;
+ hitbox.alpha = 0;
+ self.hitbox = hitbox;
+ function update(targetPosition) {
+ var dx = targetPosition.x - self.x;
+ var dy = targetPosition.y - self.y;
+ var angle = angleClamp(Math.atan2(dy, dx));
+ var acceleration = (Math.sin(angle) - 0.1) * 2.0;
+ speed = Math.max(0, speed * 0.95 + acceleration);
+ platformGraphics.rotation = angle + Math.PI / 2;
+ var velocityX = Math.cos(angle) * speed;
+ playerGraphics.scale.x = velocityX < 0 ? -1 : 1;
+ return {
+ velocityX: Math.cos(angle) * speed,
+ velocityY: Math.sin(angle) * speed
+ };
+ }
+ function angleClamp(angle) {
+ return angle >= 0 ? angle : angle < -Math.PI / 2 ? Math.PI : 0;
+ }
});
var Game = Container.expand(function () {
var self = Container.call(this);
var stageWidth = 2048;
@@ -189,23 +210,16 @@
var background = self.createAsset('background', 'Fullscreen background', 0, 0);
var landscapeLookup = {};
var landscapeTiles = [];
var pickups = [];
- var direction = {
- x: 0,
- y: 0
- };
var speed = 0;
background.width = stageWidth;
background.height = stageHeight;
var targetPosition = {
x: 0,
y: 0
};
- var player = new Player();
- self.addChild(player);
- player.x = stageWidth / 2;
- player.y = stageHeight / 5;
+ var player = new Player(self, stageWidth / 2, stageHeight / 5);
var speedText = new Text2('Speed: 0', {
size: 50,
fill: "#000000",
align: 'right'
@@ -251,16 +265,9 @@
updatePosition(obj.event);
}
});
LK.on('tick', function () {
- var dx = targetPosition.x - player.x;
- var dy = targetPosition.y - player.y;
- var angle = angleClamp(Math.atan2(dy, dx));
- var acceleration = (Math.sin(angle) - 0.1) * 2.0;
- speed = Math.max(0, speed * 0.95 + acceleration);
- player.platformGraphics.rotation = angle + Math.PI / 2;
- var velocityX = Math.cos(angle) * speed;
- var velocityY = Math.sin(angle) * speed;
+ var {velocityX, velocityY} = player.update(targetPosition);
for (var i = landscapeTiles.length - 1; i >= 0; i--) {
var landscapeTile = landscapeTiles[i];
landscapeTile.x -= velocityX;
landscapeTile.y -= velocityY;
@@ -286,14 +293,10 @@
}
}
scoreText.setText(score);
});
- function angleClamp(angle) {
- return angle >= 0 ? angle : angle < -Math.PI / 2 ? Math.PI : 0;
- }
function updatePosition(event) {
var pos = event.getLocalPosition(self);
targetPosition.x = pos.x;
targetPosition.y = pos.y;
- player.playerGraphics.scale.x = targetPosition.x < player.x ? -1 : 1;
}
});
Pixel art of a Santa. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a tree stump covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a dead tree covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a christmas tree covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a spruce tree covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a rock covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a christmas present counter. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a christmas present. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a blue christmas present. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art heart icon . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
two vertical lines with a blank background.
pixel art of a large, snow covered rock . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of skiis . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a floating grinch monster . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
single green firework explosion . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a wooden board covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a wooden pole with snow at it's base. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tileable white water texture pixel art.