Skip to content

Commit

Permalink
Merge pull request #1 from onegrx/master
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
barsumek authored Oct 9, 2016
2 parents 4ab8c63 + 50ef7de commit 08b4999
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/lab/project/game/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ object Direction extends Enumeration {
def checkBounds(dir: Direction, pos: Vec, speed: Int,
width : Int = windowWidth,
height: Int = windowHeight): Boolean = dir match {
case Right => if (pos.x > width - speed - 1) true else false
case Left => if (pos.x < speed + 1) true else false
case Up => if (pos.y > height - speed - 1) true else false
case Down => if (pos.y < speed + 1) true else false
case Right => pos.x > width - speed - 1
case Left => pos.x < speed + 1
case Up => pos.y > height - speed - 1
case Down => pos.y < speed + 1
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/lab/project/game/Player.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Player extends ShootsBolts {
override def changeState(changer: GameObject, state: State): Unit = {
state.neededKeys {
case ("hit", true) => shieldsDrop()
case ("crash", true) => (1 to 5).foreach(_ => shieldsDrop())
case ("crash", true) => shieldsDrop(5)
}
}
}
Expand Down Expand Up @@ -65,12 +65,12 @@ object Player extends ShootsBolts {
}

/**
* If player has shields it drops them by 1,
* If player has shields it drops them by the amount of damage,
* otherwise player dies and it's game over.
*/
private def shieldsDrop(): Unit = {
if (shields > 0) {
shields -= 1
private def shieldsDrop(damage: Int = 1): Unit = {
if (shields >= damage) {
shields -= damage
} else {
alive = false
}
Expand Down

0 comments on commit 08b4999

Please sign in to comment.