Skip to content

Commit

Permalink
added some additional context sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPritchard committed May 6, 2019
1 parent 2f1dff9 commit 55883ca
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/space-invaders-clone/Game.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let init highScore =
score = 0
highScore = highScore
lives = 3
soundQueue = KeyQueue()
soundQueue = KeyQueue (["startgame"])
}, Cmd.none

type Message =
Expand Down
8 changes: 7 additions & 1 deletion samples/space-invaders-clone/GameOver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ type Model = {
highScore: int
score: int
wasVictory: bool
soundQueue: KeyQueue
}

let init wasVictory score highScore =
if highScore < score then
File.WriteAllText (highScoreFile, score.ToString())
{ highScore = highScore; score = score; wasVictory = wasVictory }
{ highScore = highScore
score = score
wasVictory = wasVictory
soundQueue = KeyQueue (if wasVictory then ["victory"] else ["gameover"]) }

type Message = | StartGame of highScore: int

let view model dispatch =
let centredText colour = text "PressStart2P" 24. colour (-0.5, 0.)
let textMid = resWidth / 2
[
yield playQueuedSound model.soundQueue

if not model.wasVictory then
yield centredText Colour.Red "GAME OVER!" (textMid, 90)
yield centredText Colour.OrangeRed "YOU FAILED TO FEND OFF THE INVADERS :(" (textMid, 130)
Expand Down
5 changes: 4 additions & 1 deletion samples/space-invaders-clone/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ let main _ =
assetsToLoad = [
FileTexture ("sprites", "./content/sprites.png")
PipelineFont ("PressStart2P", "./content/PressStart2P")
FileSound ("startgame", "./content/siclone_menu_enter.wav")
FileSound ("shoot", "./content/siclone_shoot.wav")
FileSound ("explosion", "./content/siclone_explosion.wav")
FileSound ("explosion-small", "./content/siclone_explosion_small.wav")
FileSound ("beep", "./content/siclone_menu.wav") ]
FileSound ("beep", "./content/siclone_menu.wav")
FileSound ("gameover", "./content/siclone_death.wav")
FileSound ("victory", "./content/siclone_saucer.wav") ]
mouseVisible = false
showFpsInConsole = true
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 55883ca

Please sign in to comment.