Code edit (9 edits merged)
Please save this source code
User prompt
visually set the scoreIcon to be on the right of the scoreText
Code edit (5 edits merged)
Please save this source code
User prompt
in the game on tick, iterate through the pickupProjectileList and calling it's update statement
Code edit (4 edits merged)
Please save this source code
User prompt
create a pickupProjectile class that has an update function to move towards the player at a speed of 20
Code edit (1 edits merged)
Please save this source code
User prompt
when the pickup decor flips, randomly scale the decor's x to be between PICKUP_FLIP_SCALE and 1
Code edit (1 edits merged)
Please save this source code
User prompt
remove any console.logs
Code edit (11 edits merged)
Please save this source code
User prompt
ramps have a directional arrow indicator on top of them
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: PICKUP_TIL_SQRDIST is not defined' in this line: 'if (!tilted && distSqr <= PICKUP_TIL_SQRDIST) {' Line Number: 157
User prompt
Fix Bug: 'ReferenceError: PICKUP_TIL_SQRDIST is not defined' in this line: 'if (!tilted && distSqr <= PICKUP_TIL_SQRDIST) {' Line Number: 157
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: collectDist is not defined' in this line: 'var tiltDistSqr = collectDist * collectDist;' Line Number: 129
User prompt
when setting tilted = true in the pickup, adjust the pickupBase's graphic rotation to be between 5 and 20 degrees
Code edit (1 edits merged)
Please save this source code
User prompt
When a pickup is activated, destroy the graphic and decor and create a pickupBase graphic in their place
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.activate is not a function' in this line: 'self.activate();' Line Number: 157
User prompt
create a pickupProjectileList variable in the games class
Code edit (10 edits merged)
Please save this source code
User prompt
add an activate function to the pickups class which sets the self.active to true. This should be called where `self.active = true;` is called in the pickups class
===================================================================
--- original.js
+++ change.js
@@ -1,28 +1,19 @@
-var DropEffect = Container.expand(function (x, y) {
+var PickupProjectile = Container.expand(function (x, y, target) {
var self = Container.call(this);
- var angle = Math.random() * Math.PI;
- var speed = 10 + Math.random() * 5;
- var speedX = Math.cos(angle) * speed;
- var speedY = Math.sin(angle) * speed;
- var spinSpeed = Math.random() * 0.2 - 0.1;
- var scale = 1;
- var scaleDecrement = 1 / 60;
- var graphics = self.createAsset('pickupProjectile', 'Drop graphics', 0.5, 0.95);
- graphics.rotation = Math.random() * Math.PI * 2;
- ;
+ var speed = 20;
+ var graphics = self.createAsset('pickupProjectile', 'Pickup Projectile graphics', 0.5, 0.5);
self.x = x;
self.y = y;
- self.update = update;
- ;
- function update(velocityX, velocityY) {
- self.x += speedX - velocityX;
- self.y += speedY - velocityY;
- scale -= scaleDecrement;
- graphics.rotation += spinSpeed;
- graphics.scale.set(scale);
- return scale <= 0;
- }
+ self.update = function () {
+ var dx = target.x - self.x;
+ var dy = target.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ var velocityX = dx / distance * speed;
+ var velocityY = dy / distance * speed;
+ self.x += velocityX;
+ self.y += velocityY;
+ };
});
var BloodsplatterEffect = Container.expand(function (x, y) {
var self = Container.call(this);
var duration = 15;
@@ -150,9 +141,9 @@
activate();
} else if (--flipTickCounter <= 0) {
flipScaling *= -1;
decor.y += flipOffsetY * flipScaling;
- decor.scale.set(flipScaling, PICKUP_FLIP_SCALE + Math.random() * (1 - PICKUP_FLIP_SCALE));
+ decor.scale.set(PICKUP_FLIP_SCALE + Math.random() * (1 - PICKUP_FLIP_SCALE), flipScaling);
flipTickCounter = randomizeFlipTicks();
}
}
if (!tilted && !player.airborne && distSqr <= PICKUP_TILT_SQRDIST) {
@@ -380,9 +371,8 @@
var rampRemaining = 0;
var rampDuration = 0;
var rampHeight = 0;
var rampHeightMax = 0;
- var tiltSpeedFactor = 100;
var playerShadow = self.createAsset('shadow', 'Player shadow', 0.5, 0.5);
var platformGraphics = self.createAsset('platform', 'Platform image', 0.4, 0.5);
var playerGraphics = self.createAsset('player', 'Player character', 0.45, 1);
var hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
@@ -423,21 +413,22 @@
var dx = targetPosition.x - self.x;
var dy = targetPosition.y - self.y;
angle = angleClamp(Math.atan2(dy, dx));
}
- var acceleration = (Math.sin(angle) - 0.1) * 2.0;
+ var acceleration = (Math.sin(angle) - PLAYER_ACCELERATION_ANGLE) * PLAYER_ACCELERATION_MAGNITUDE;
var boost = self.airborne ? RAMP_SPEED_BOOST : 1;
reduction = self.invulnerable ? 1 - self.invulnerableTimer / self.invulnerableTime : 1;
- speed = Math.max(0, speed * 0.95 + acceleration);
- var velocityX = Math.cos(angle) * reduction * boost * speed;
- var velocityY = Math.sin(angle) * reduction * boost * speed;
+ speed = Math.max(0, speed * PLAYER_DECELERATION_FACTOR + acceleration);
+ var totalSpeed = speed * reduction * boost;
+ var velocityX = Math.cos(angle) * totalSpeed;
+ var velocityY = Math.sin(angle) * totalSpeed;
travelDistX += velocityX;
travelDistY += velocityY;
self.distanceTravelled = Math.sqrt(travelDistX * travelDistX + travelDistY * travelDistY);
if (!self.airborne) {
var facingSide = targetPosition.x < self.x ? -1 : 1;
platformGraphics.rotation = angle;
- playerGraphics.rotation = speed * reduction / tiltSpeedFactor * (Math.PI / 2) * facingSide;
+ playerGraphics.rotation = totalSpeed * facingSide / PLAYER_TILT_SPEED_FACTOR;
playerGraphics.scale.x = facingSide;
}
return {
velocityX,
@@ -561,8 +552,12 @@
var DIFFICULTY_FACTOR_DIST = 150 / SCREEN_METERAGE;
var TILE_SIZE = 512;
var TILE_MARGIN = TILE_SIZE;
var TILE_BACKGROUND_OFFSET = 100;
+var PLAYER_ACCELERATION_ANGLE = 0.1;
+var PLAYER_ACCELERATION_MAGNITUDE = 2.0;
+var PLAYER_DECELERATION_FACTOR = 0.95;
+var PLAYER_TILT_SPEED_FACTOR = 110 * Math.PI / 2;
var PICKUP_FLIP_BASE = 10;
var PICKUP_FLIP_VARIANCE = 60;
var PICKUP_FLIP_SCALE = 0.8;
var PICKUP_COLLECT_DIST = 300;
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 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 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.
pixel art of a red flag. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a red orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white
white
pixel art shape of a red arrow pointing downwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art banner of a pair of skis crossed. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white