Skip to content

Commit

Permalink
increased score with invader death
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPritchard committed Apr 29, 2019
1 parent 390aae1 commit fc6eaff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions samples/space-invaders-clone/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type InvaderKind = {
offset: int
colour: Colour
animations: (int * int * int * int) []
score: int
}

let largeSize =
Expand All @@ -48,7 +49,8 @@ let largeSize =
animations = [|
spritemap.["invader-large-0"]
spritemap.["invader-large-1"]
|] }
|]
score = 10 }

let mediumSize =
let width, height =
Expand All @@ -61,7 +63,8 @@ let mediumSize =
animations = [|
spritemap.["invader-medium-0"]
spritemap.["invader-medium-1"]
|] }
|]
score = 20 }

let smallSize =
let width, height =
Expand All @@ -74,7 +77,8 @@ let smallSize =
animations = [|
spritemap.["invader-small-0"]
spritemap.["invader-small-1"]
|] }
|]
score = 30 }

let animationSpeed = 100L

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 @@ -175,11 +175,14 @@ let destroyInvader targetRow index model =
| Down (n, nextDir) when n = newInvaders.Length -> Down (n - 1, nextDir)
| other -> other

let scoreIncrease = model.invaders.[targetRow].kind.score

{ model with
invaders = newInvaders
invaderDirection = newInvaderDirection
explosions = newExplosion::model.explosions
shuffleInterval = max minShuffle (model.shuffleInterval - shuffleDecrease) }, Cmd.none
shuffleInterval = max minShuffle (model.shuffleInterval - shuffleDecrease)
score = model.score + scoreIncrease }, Cmd.none

let update message model =
match message with
Expand Down

0 comments on commit fc6eaff

Please sign in to comment.