Skip to content

Commit

Permalink
Merge pull request #1 from martez81/dev
Browse files Browse the repository at this point in the history
Minor improvements
  • Loading branch information
markosski authored Dec 29, 2018
2 parents 068aff7 + 630972e commit dd7cd21
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Elements in the game are:
- "|" - vertical wall
- "-" - horizontal wall

![Alt text](https://github.com/martez81/scala-dash/blob/master/resource/img/screenshot1.png)
![Alt text](resource/img/game.gif)

## Requirements
- OSX or Linux, not sure about Windows
Expand Down
Binary file added resource/img/game.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/scaladash/ScalaDash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ object ScalaDash extends App {
maybeActionSeqenceFile match {
case Some(fileName) => {
for ( line <- Source.fromFile(fileName).getLines() ) {
renderScene(line(0).toInt) // line here should be single character
Thread.sleep(250)
if (line.length > 0) {
renderScene(line(0).toInt) // line here should be single character
Thread.sleep(250)
}
}
}
case None => userMoveInput
Expand Down
8 changes: 5 additions & 3 deletions src/scaladash/Thing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Player extends Thing with CanMove {
def consume(thing: Thing): Thing = {
return thing match {
case obj: Diamond => score += obj.points; new Space()
case obj: Turf => score -= 1; new Space()
case obj: Space => thing
case obj: Turf => score += obj.points; new Space()
case obj: Space => score += obj.points; thing
case _ => throw new IllegalMove
}
}
Expand All @@ -59,7 +59,7 @@ class PsychoKiller extends Thing with CanMove {
}

class Diamond extends Thing with HasValue with CanMove {
val points = 15
val points = 30

def nextMove(): String = {
// Can only move down to simulate gravity
Expand Down Expand Up @@ -107,10 +107,12 @@ class Boulder extends Thing with CanMove {
}

class Turf extends Thing {
val points = -2
override def toString() = "#"
}

class Space extends Thing {
val points = -1
override def toString() = " "
}

Expand Down

0 comments on commit dd7cd21

Please sign in to comment.