Code edit (2 edits merged)
Please save this source code
User prompt
After moving obstructions, check if their hitbox intersect the player hitbox and show a game over
User prompt
The player also has a 1x1 hitbox centered on the bottom
User prompt
all obstructions have a hitbox graphic, centered on the bottom of the graphic. These hitboxes have a width of the graphics and a height of half the width
User prompt
add black text to the top-right of the screen showing the current velocity as "Speed:"
Code edit (3 edits merged)
Please save this source code
User prompt
spawn a new obstacle below the bottom of the screen, with a random x position, every 100 distance traveled in the y direction
Code edit (1 edits merged)
Please save this source code
User prompt
velocity should scale based on the angle, with vertical being 100%, and horizonal being 0%
User prompt
destroy obstructions whose y position is < -100
User prompt
obstructions should be stored in an obstructions array. Instead of iterating through the children in the tick function, use the obstructions array
User prompt
instead of setting the player position to the position variable, increase the positions of all obstructions by the velocity
User prompt
every tick adjust the position variable by the speed in the direction of angle
User prompt
when spawning obstructions, they should uniformally randomize their scale between 0.9 and 1.1, and have their x scale randomly flipped
Code edit (11 edits merged)
Please save this source code
User prompt
on game start, randomly spawn 10 obstructions within the screen space
User prompt
Add several obstruction classes; LargeTree, SmallTree, Rock, Stump, DeadTree and a function that would randomly spawn one of these obstructions at a given location
Code edit (2 edits merged)
Please save this source code
User prompt
when setting the targetPosition, flip the playerGraphics if the targetPos.x < player.x
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: player is undefined' in this line: 'platform.y = player.y + playerGraphics.height / 2 + platformGraphics.height / 2;' Line Number: 47
User prompt
center the platform on the bottom of the player
User prompt
add a platform image under the player and set it's rotation to the angle
User prompt
on tick, determine the angle between the player and the targetPosition and clamp it to quadrant 3 and 4.
User prompt
add a targetPosition variable, initially to 0,0. This variable should be updated to the mouse position when moving the mouse while the mouse button is down
===================================================================
--- original.js
+++ change.js
@@ -1,56 +1,22 @@
-var LargeTree = Container.expand(function () {
+var Obstruction = Container.expand(function (parent, x, y, type) {
var self = Container.call(this);
- self.graphics = self.createAsset('largeTree', 'Large Tree', 0.5, 1);
- self.hitbox = new Container();
- self.hitbox.width = self.graphics.width;
- self.hitbox.height = self.graphics.width / 2;
- self.hitbox.y = -self.hitbox.height;
- self.addChild(self.hitbox);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
+ var graphics = self.createAsset(type, 'Obstruction graphics', 0.5, 1);
+ var randomScale = 0.9 + Math.random() * 0.2;
+ self.scale.set(randomScale, randomScale);
+ self.hitbox = self.createAsset('hitbox', 'Obstruction hitbox', 0.5, 0.5);
+ self.hitbox.width = graphics.width;
+ self.hitbox.height = graphics.width / 2;
});
-var SmallTree = Container.expand(function () {
- var self = Container.call(this);
- self.graphics = self.createAsset('smallTree', 'Small Tree', 0.5, 1);
- self.hitbox = new Container();
- self.hitbox.width = self.graphics.width;
- self.hitbox.height = self.graphics.width / 2;
- self.hitbox.y = -self.hitbox.height;
- self.addChild(self.hitbox);
-});
-var Rock = Container.expand(function () {
- var self = Container.call(this);
- self.graphics = self.createAsset('rock', 'Rock', 0.5, 1);
- self.hitbox = new Container();
- self.hitbox.width = self.graphics.width;
- self.hitbox.height = self.graphics.width / 2;
- self.hitbox.y = -self.hitbox.height;
- self.addChild(self.hitbox);
-});
-var Stump = Container.expand(function () {
- var self = Container.call(this);
- self.graphics = self.createAsset('stump', 'Stump', 0.5, 1);
- self.hitbox = new Container();
- self.hitbox.width = self.graphics.width;
- self.hitbox.height = self.graphics.width / 2;
- self.hitbox.y = -self.hitbox.height;
- self.addChild(self.hitbox);
-});
-var DeadTree = Container.expand(function () {
- var self = Container.call(this);
- self.graphics = self.createAsset('deadTree', 'Dead Tree', 0.5, 1);
- self.hitbox = new Container();
- self.hitbox.width = self.graphics.width;
- self.hitbox.height = self.graphics.width / 2;
- self.hitbox.y = -self.hitbox.height;
- self.addChild(self.hitbox);
-});
var Player = Container.expand(function () {
var self = Container.call(this);
- self.playerGraphics = self.createAsset('player', 'Player character', 0.575, 0.5);
+ self.playerGraphics = self.createAsset('player', 'Player character', 0.575, 1);
self.platformGraphics = self.createAsset('platform', 'Platform image', 0.5, 0.5);
- self.platformGraphics.y = self.playerGraphics.height / 2;
self.addChild(self.playerGraphics);
- self.hitbox = new Container();
+ self.hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
self.hitbox.width = 1;
self.hitbox.height = 1;
self.hitbox.x = 0;
self.hitbox.y = self.playerGraphics.height / 2;
@@ -145,16 +111,11 @@
spawnObstruction(randomX, stageHeight + 200);
}
}
function spawnObstruction(x, y) {
- var obstructionTypes = [LargeTree, SmallTree, Rock, Stump, DeadTree];
- var ObstructionClass = obstructionTypes[Math.floor(Math.random() * obstructionTypes.length)];
- var obstruction = new ObstructionClass();
- var randomScale = 0.9 + Math.random() * 0.2;
- obstruction.scale.set(randomScale, randomScale);
- obstruction.scale.x *= Math.random() < 0.5 ? -1 : 1;
- obstruction.x = x;
- obstruction.y = y;
+ var obstructionTypes = ['largeTree', 'smallTree', 'deadTree', 'rock', 'stump'];
+ var obstructionType = obstructionTypes[Math.floor(Math.random() * obstructionTypes.length)];
+ var obstruction = new Obstruction(self, x, y, obstructionType);
self.obstructions.push(obstruction);
self.addChild(obstruction);
}
function updatePosition(event) {
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.