This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseElement { | |
def foo() { println("I like foo") } | |
} | |
class SubElement extends BaseElement { | |
def bar() { println("I like bar") } | |
} | |
trait Base { | |
//Abstract type T must be BaseElement or a subclass of BaseElement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseElement { | |
def foo() { println("I like foo") } | |
} | |
class SubElement extends BaseElement { | |
def bar() { println("I like bar") } | |
} | |
trait Base[T <: BaseElement] { | |
var map = Map[Int, T]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wololo.wastelands.core.fgfd | |
import scala.collection.mutable.Publisher | |
import scala.collection.mutable.Subscriber | |
object Main extends App { | |
override def main(args: Array[String]) { | |
val world = new World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait UnitAction { | |
def performAction(myself: Unit) { | |
//do nothing | |
} | |
} | |
object Idle extends UnitAction | |
class Moving(val from: Coordinate, val to: Coordinate) extends UnitAction { | |
override def performAction(myself: Unit){ | |
if(myself.at(to)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def click(x: Int, y: Int) { | |
val mx = screen.calculateTileIndex(screen.sx+x) | |
val my = screen.calculateTileIndex(screen.sy+y) | |
val tile = map.tiles(mx,my) | |
performPossibleUnitAction(tile.unit, mx, my) | |
} | |
private def performPossibleUnitAction(tileUnit:Option[Unit], mx: Int, my: Int) { | |
(tileUnit, selectedUnit) match { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tailrec | |
def tileSizeCalc(f: Int): Int = { | |
val tileSize = math.pow(2, f) | |
if (graphicsContext.screenWidth / tileSize < 22) | |
math.pow(2, f).toInt | |
else | |
tileSizeCalc(f+1) | |
} |