User prompt
Move particle #1 20px to the left and 30px down
User prompt
Have 4 fixed offsets for particles
User prompt
Spawn 4 particles per tick
User prompt
decrease random spacing of particles to 20
Code edit (2 edits merged)
Please save this source code
User prompt
in projectMovement reverse the angle of projection
User prompt
project movement with projectMovement before applying to car x,y
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self')' in this line: 'self.projectMovement = function (vector) {' Line Number: 11
User prompt
Add a method on car that takes a movement vector and projects it 45 degrees counter clockwise
User prompt
when applying momentum to x and y on car, rotate the movement vector 45 degrees counter clockwise
User prompt
when applying momentum x and y to car, rotate the momentum 45 degrees counter clockwise first
User prompt
Update momentum such that it slows down faster in the direction the car is not traveling
User prompt
Car should move right or up rather than diagonally
User prompt
Car should have different momentum depending on the direction it's traveling in, such that it slows down in the direction it's not traveling in
Code edit (1 edits merged)
Please save this source code
User prompt
Momentum modifier should be different for X and Y, such that you loose speed faster in the direction the car is not traveling
User prompt
decrease offset x y divider to 5
User prompt
Update car logic such that it has momentum. With speed being a modifier to momentum
User prompt
add 20px randomly to x and y of particle when spawning them
User prompt
Spawn particles below the car with a random 50px offset on both x and y
User prompt
When changing direction in car, flip the x scale of carGraphics
User prompt
set game background color to c39977
User prompt
Make particle lifetime be 200
User prompt
in tick use adChildAt to add the particles to z-index zero
===================================================================
--- original.js
+++ change.js
@@ -16,21 +16,25 @@
x: 0,
y: 0
};
self.move = function () {
- var momentumModifierX = 0.005;
- var momentumModifierY = 0.1;
+ var momentumModifier = 0.1;
if (self.direction === 0) {
- self.momentum.x += self.speed * momentumModifierX;
- self.momentum.y -= self.speed * momentumModifierY;
+ self.momentum.x += self.speed * momentumModifier;
+ self.momentum.y -= self.speed * momentumModifier;
} else {
- self.momentum.x -= self.speed * momentumModifierY;
- self.momentum.y -= self.speed * momentumModifierX;
+ self.momentum.x -= self.speed * momentumModifier;
+ self.momentum.y -= self.speed * momentumModifier;
}
self.x += self.momentum.x;
self.y += self.momentum.y;
- self.momentum.x *= 0.98;
- self.momentum.y *= 0.98;
+ if (self.direction === 0) {
+ self.momentum.x *= 0.98;
+ self.momentum.y *= 0.90;
+ } else {
+ self.momentum.x *= 0.90;
+ self.momentum.y *= 0.98;
+ }
};
self.changeDirection = function () {
self.direction = self.direction === 0 ? 1 : 0;
carGraphics.scale.x *= -1;