Quelques mises a jour amusantes
This commit is contained in:
parent
bb95f8f8fd
commit
5d4ea4e85a
14 changed files with 294 additions and 73 deletions
|
@ -15,11 +15,16 @@ class GameController @Inject()(val controllerComponents: ControllerComponents) e
|
|||
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))
|
||||
def getBricks(file: String): Action[AnyContent] = Action {
|
||||
val filePath = s"conf/$file"
|
||||
try {
|
||||
val source = scala.io.Source.fromFile(filePath)
|
||||
val jsonString = try source.mkString finally source.close()
|
||||
val bricks = Json.parse(jsonString).as[List[Brick]]
|
||||
Ok(Json.toJson(bricks))
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
BadRequest(s"Error reading file: ${e.getMessage}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,11 @@
|
|||
@()
|
||||
@()(implicit request: RequestHeader)
|
||||
|
||||
@main("Arkanoid Game") {
|
||||
|
||||
<div id="gameContainer" style="display: none;text-align:center; justify-content: center; align-items: center;">
|
||||
<canvas id="gameCanvas" width="540" height="675"></canvas>
|
||||
</div>
|
||||
|
||||
<script src="@routes.Assets.versioned("javascripts/device-detection.js")"></script>
|
||||
<script>
|
||||
if (!isMobileDevice()) {
|
||||
var script = document.createElement('script');
|
||||
script.src = '@routes.Assets.versioned("javascripts/game.js")';
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@main("Breakout Game") {
|
||||
<div id="gameContainer">
|
||||
<h1 id="themeHeader"></h1>
|
||||
<div id="canvasContainer">
|
||||
<canvas id="gameCanvas" width="540" height="675"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<script src="@routes.Assets.versioned("javascripts/game.js")"></script>
|
||||
}
|
|
@ -8,7 +8,10 @@
|
|||
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
|
||||
</head>
|
||||
<body>
|
||||
@content
|
||||
<div id="gameContainer">
|
||||
<h1 id="themeHeader"></h1>
|
||||
@content
|
||||
</div>
|
||||
<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