Skip to content

Commit

Permalink
feat(sprites): add ghosty
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 17, 2024
1 parent cbef61e commit 517d835
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scenes/game.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { addCursorKeys } from '../events'
import { addPlayer } from '../gameobjects'
import { ghosty } from '../sprites'

scene('game', () => {
const player = addPlayer()
Expand All @@ -13,4 +14,10 @@ scene('game', () => {
onClick(() => addKaboom(mousePos()))

add([text('Press arrow keys', { width: width() / 2 }), pos(12, 12)])

for (let i = 0; i < 3; i++) {
const x = rand(0, width())
const y = rand(0, height())
add([ghosty, pos(x, y)])
}
})
Binary file added src/sprites/ghosty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/sprites/ghosty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Sprite } from '../types'
import image from './ghosty.png'

loadSprite(Sprite.ghosty, image)

export const ghosty = sprite(Sprite.ghosty)
1 change: 1 addition & 0 deletions src/sprites/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './bean'
export * from './ghosty'
1 change: 1 addition & 0 deletions src/types/sprite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export enum Sprite {
bean = 'bean',
ghosty = 'ghosty',
}

0 comments on commit 517d835

Please sign in to comment.