-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add in flying bird asset to city map plus sprite sheet and credits
- Loading branch information
1 parent
2638604
commit 75a92e2
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export const flyingBirds = (k, map) => { | ||
// Load the bird sprite from the sprite sheet | ||
k.loadSprite('bird', './assets/sprites/bird_flying.png', { | ||
sliceX: 6, | ||
sliceY: 1, | ||
anims: { | ||
fly: { from: 0, to: 5, loop: true }, | ||
}, | ||
}); | ||
|
||
function spawnBird() { | ||
const bird = k.add([ | ||
k.sprite('bird'), | ||
k.pos(k.vec2(0, 780)), | ||
k.area(), | ||
]); | ||
|
||
bird.play('fly'); | ||
|
||
//Update bird movement and animation based on its state | ||
bird.onUpdate(() => { | ||
bird.move(140, 0); | ||
|
||
if (bird.pos.x > 1900) { | ||
k.destroy(bird); | ||
} | ||
}); | ||
|
||
return bird; | ||
} | ||
|
||
const birds = []; | ||
|
||
k.loop(8, () => { | ||
const bird = spawnBird(); | ||
birds.push(bird); | ||
}); | ||
|
||
return birds; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { movingCars } from './movingCars'; | ||
import { flyingBirds } from './flyingBirds'; | ||
import { npcsInCityMap } from './npcsOnmap_city'; | ||
const gameObjects = [ | ||
npcsInCityMap, | ||
// Add more game objects here | ||
movingCars, | ||
flyingBirds, | ||
]; | ||
|
||
export default gameObjects; |