Skip to content

Commit 07a7520

Browse files
chore: Link to demo actualized.
1 parent 5e98119 commit 07a7520

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ normalizedName := "main"
1919
scalaVersion in ThisBuild := "2.11.8"
2020

2121
libraryDependencies ++= Seq(
22+
"be.doeraene" %%% "scalajs-jquery" % "0.9.0",
2223
"org.scala-js" %%% "scalajs-dom" % "0.9.1",
2324
"org.scalatest" %%% "scalatest" % "3.0.0" % "test",
2425
"com.lihaoyi" %%% "scalatags" % "0.6.0"

src/main/scala-2.11/nl/amsscala/simplegame/Page.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import org.scalajs.dom
55

66
import scalatags.JsDom.all._
77

8-
/**
9-
*
10-
*/
8+
/** All related to Html5 visuals */
119
protected trait Page {
1210
// Create the canvas
13-
protected val canvas = dom.document.createElement("canvas").asInstanceOf[dom.html.Canvas]
11+
private[simplegame] val canvas = dom.document.createElement("canvas").asInstanceOf[dom.html.Canvas]
1412
canvas.setAttribute("crossOrigin", "anonymous")
1513
private[this] val ctx = canvas.getContext("2d") // .asInstanceOf[dom.CanvasRenderingContext2D]
1614
private[this] val (bgImage, heroImage, monsterImage) = (Image("img/background.png"), Image("img/hero.png"), Image("img/monster.png"))

src/main/scala-2.11/nl/amsscala/simplegame/game.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import org.scalajs.dom.ext.KeyCode.{ Down, Left, Right, Up }
77
import scala.collection.mutable
88
import scala.scalajs.js
99

10-
/**
11-
*
12-
*/
10+
/** The game with its rules. */
1311
protected trait Game {
1412
private[this] val framesPerSec = 30
1513

@@ -129,7 +127,7 @@ private case class GameState(
129127
}
130128

131129
/**
132-
* Monster class, holder for its coordinates, copied as extentension to the Hero class
130+
* Monster class, holder for its coordinate, copied as extentension to the Hero class
133131
*
134132
* @param pos Monsters' position
135133
* @tparam T Numeric generic abstraction

src/main/scala-2.11/nl/amsscala/simplegame/package.scala

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
package nl.amsscala
22

33
/**
4-
* Provides generic class and operators for dealing with 2D positions.
5-
* As well dealing with 2D areas.
4+
* Provides generic class and operators for dealing with 2D positions. As well dealing with 2D areas.
65
*/
76
package object simplegame {
8-
// Experimental timestamp and position, displacement is a function of time
9-
type keysBufferType = scala.collection.mutable.Map[Int, (Double, Position[Int])]
7+
/** Experimental timestamp and position, displacement is a function of time */
8+
protected[simplegame]type keysBufferType = scala.collection.mutable.Map[Int, (Double, Position[Int])]
109

1110
/**
12-
* Generic base class Position, holding the two coordinates
11+
* Generic base class Position, holding the two ordinates
1312
*
14-
* @param x
15-
* @param y
16-
* @tparam P
13+
* @param x The abscissa
14+
* @param y The ordinate
15+
* @tparam P Numeric type
1716
*/
18-
case class Position[P: Numeric](x: P, y: P) {
17+
protected[simplegame] case class Position[P: Numeric](x: P, y: P) {
1918

2019
import Numeric.Implicits.infixNumericOps
2120
import Ordering.Implicits.infixOrderingOps
@@ -45,9 +44,9 @@ package object simplegame {
4544
/**
4645
* Check if the square area is within the rectangle area
4746
*
48-
* @param canvasPos
49-
* @param side
50-
* @return
47+
* @param canvasPos Position of the second square
48+
* @param side side of both two squares
49+
* @return False if a square out of bound
5150
*/
5251
def isValidPosition(canvasPos: Position[P], side: P): Boolean = {
5352
// println(s"Testing: $x, $y")

src/test/scala-2.11/nl/amsscala/simplegame/PageSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package nl.amsscala.simplegame
33
import org.scalajs.dom
44

55
class PageSuite extends SuiteSpec /*with Page*/ {
6-
val page = new Page {}
6+
val page = new Page {}
77
describe("A Hero") {
88
describe("should tested within the limits") {
99

0 commit comments

Comments
 (0)