Skip to content

Commit 434bd1b

Browse files
feat(public): add opaque background brick wall image to game
1 parent 5497e50 commit 434bd1b

File tree

8 files changed

+27
-11
lines changed

8 files changed

+27
-11
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ Play the game on:
1818

1919
## Credits
2020

21+
### Art
22+
2123
- [Kenney - Puzzle Pack 2](https://kenney.nl/assets/puzzle-pack-2)
24+
- Photo by [Bernard Hermant](https://unsplash.com/@bernardhermant) on [Unsplash](https://unsplash.com/photos/brown-concrete-brick-t4DuoDHjxrQ)
25+
26+
### Sounds
27+
2228
- [Kenney - UI Audio](https://kenney.nl/assets/ui-audio)
2329
- [Pixabay - SPLASH](https://pixabay.com/sound-effects/splash-by-blaukreuz-6261/)
2430
- [Pixabay - Gentle ocean waves birdsong and gull](https://pixabay.com/sound-effects/gentle-ocean-waves-birdsong-and-gull-7109/)

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
</head>
4747
<body>
4848
<noscript>You need to enable JavaScript to play this game.</noscript>
49+
4950
<script type="module">
5051
import kaboom from 'kaboom'
5152
kaboom({
52-
background: [255, 255, 255],
53+
background: [0, 0, 0, 0],
5354
})
5455
</script>
5556
<script type="module" src="src/index.ts"></script>

public/sprites/backgrounds/brick.jpg

982 KB
Loading

src/constants/backgrounds.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum Background {
2+
brick = 'brick',
3+
}

src/constants/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './backgrounds'
12
export * from './pipes'
23
export * from './scenes'
34
export * from './sounds'

src/helpers/background.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ const backgrounds: [number, number, number][] = [
2424

2525
export function setRandomBackgroundColor() {
2626
const color = backgrounds[randi(backgrounds.length)]
27-
setBackground(...color)
27+
setBackground(...color, 1)
2828
}

src/scenes/game.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EmptyToFilledPipe, Scene, Sound, Tag } from '../constants'
1+
import { Background, EmptyToFilledPipe, Scene, Sound, Tag } from '../constants'
22
import {
33
checkSolution,
44
getDeviceScale,
@@ -25,6 +25,13 @@ scene(Scene.game, (levelNumber: number) => {
2525
])
2626

2727
setRandomBackgroundColor()
28+
add([
29+
sprite(Background.brick),
30+
pos(width() / 2, height() / 2),
31+
anchor('center'),
32+
opacity(0.2),
33+
])
34+
2835
const level = addLevel(...getLevel(levelNumber))
2936

3037
level.get(Tag.pipe).forEach((pipe) => {

src/scenes/preload.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import { pipes, Scene, Sound } from '../constants'
1+
import { Background, pipes, Scene, Sound } from '../constants'
22

3-
scene(Scene.preload, async () => {
4-
const sprites = pipes.map((pipe) => {
5-
loadSprite(pipe, `sprites/pipes/${pipe}.png`)
6-
})
3+
scene(Scene.preload, () => {
4+
pipes.map((pipe) => loadSprite(pipe, `sprites/pipes/${pipe}.png`))
5+
6+
loadSprite(Background.brick, 'sprites/backgrounds/brick.jpg')
77

8-
const sounds = Object.values(Sound).map((sound) => {
8+
Object.values(Sound).map((sound) => {
99
loadSound(sound, `sounds/${sound}.mp3`)
1010
})
1111

12-
await Promise.all(sprites.concat(sounds))
13-
1412
go(Scene.game, Number(new URLSearchParams(location.search).get('level')))
1513
})

0 commit comments

Comments
 (0)