Version initiale
This commit is contained in:
commit
808c9d7385
22 changed files with 403 additions and 0 deletions
BIN
app/assets/images/background.png
Normal file
BIN
app/assets/images/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
25
app/controllers/GameController.scala
Normal file
25
app/controllers/GameController.scala
Normal file
|
@ -0,0 +1,25 @@
|
|||
package controllers
|
||||
|
||||
import javax.inject._
|
||||
import play.api.mvc._
|
||||
import play.api.libs.json._
|
||||
import models.Brick
|
||||
|
||||
@Singleton
|
||||
class GameController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
|
||||
|
||||
implicit val brickWrites: Writes[Brick] = Json.writes[Brick]
|
||||
implicit val brickReads: Reads[Brick] = Json.reads[Brick]
|
||||
|
||||
def index(): Action[AnyContent] = Action { implicit request: Request[AnyContent] =>
|
||||
Ok(views.html.game())
|
||||
}
|
||||
|
||||
def getBricks: Action[AnyContent] = Action {
|
||||
|
||||
val source = scala.io.Source.fromFile("conf/bricks.json")
|
||||
val jsonString = try source.mkString finally source.close()
|
||||
val bricks = Json.parse(jsonString).as[List[Brick]]
|
||||
Ok(Json.toJson(bricks))
|
||||
}
|
||||
}
|
7
app/models/Brick.scala
Normal file
7
app/models/Brick.scala
Normal file
|
@ -0,0 +1,7 @@
|
|||
package models
|
||||
|
||||
case class Brick(x: Int,
|
||||
y: Int,
|
||||
text: String,
|
||||
color: String,
|
||||
textColor: String)
|
6
app/views/game.scala.html
Normal file
6
app/views/game.scala.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
@()
|
||||
|
||||
@main("Arkanoid Game") {
|
||||
<canvas id="gameCanvas" width="540" height="675"></canvas>
|
||||
<script src="@routes.Assets.versioned("javascripts/game.js")"></script>
|
||||
}
|
14
app/views/main.scala.html
Normal file
14
app/views/main.scala.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
@(title: String)(content: Html)
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>@title</title>
|
||||
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
|
||||
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
|
||||
</head>
|
||||
<body>
|
||||
@content
|
||||
<script src="@routes.Assets.versioned("javascripts/main.js")" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue