Skip to content

Commit

Permalink
Run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 14, 2024
1 parent 2150b19 commit 6365cec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/gameObjects/map_city/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { movingCars } from "./movingCars";
import { movingCars } from './movingCars';
import { npcsInCityMap } from './npcsOnmap_city';
const gameObjects = [
npcsInCityMap,
// Add more game objects here
movingCars
movingCars,
];

export default gameObjects;
25 changes: 12 additions & 13 deletions src/gameObjects/map_city/movingCars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const movingCars = (k, map) => {
sliceX: 7,
sliceY: 2,
anims: {
drive: { from: 0, to: 0, loop: true },
drive: { from: 0, to: 0, loop: true },
turningPoint: { from: 5, to: 11, loop: true },
down: { from: 12, to: 12, loop: true }
down: { from: 12, to: 12, loop: true },
},
});

Expand All @@ -19,9 +19,9 @@ export const movingCars = (k, map) => {
function spawnCar(street) {
const car = k.add([
k.sprite('car'),
k.pos(street.start),
k.area(),
'car',
k.pos(street.start),
k.area(),
'car',
{
state: 'right',
},
Expand All @@ -32,23 +32,22 @@ export const movingCars = (k, map) => {
// Update car movement and animation based on its state
car.onUpdate(() => {
if (car.state === 'right') {
car.move(160, 0);
car.move(160, 0);

if (car.pos.x >= street.turnPoint.x) {
car.state = 'down';
car.play('turningPoint');
car.play('turningPoint');
}

} else if (car.state === 'down') {
car.move(0, 160);
car.move(0, 160);

if (car.curAnim() === 'turningPoint' && car.frame === 11) {
car.play('down');
if (car.curAnim() === 'turningPoint' && car.frame === 11) {
car.play('down');
}

if (car.pos.y > street.end.y - 100) {
k.destroy(car);
}
}
}
});

Expand All @@ -63,4 +62,4 @@ export const movingCars = (k, map) => {
});

return cars;
};
};

0 comments on commit 6365cec

Please sign in to comment.