Skip to content

Commit

Permalink
Hide mouse on the web version of the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwursteisen committed Jan 11, 2024
1 parent 5bf1ffc commit 0132ed4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class GameExporter {
template = template.replace("{GAME_ZOOM}", gameParameters.zoom.toString())
template = template.replace("{GAME_SPRW}", gameParameters.sprites.width.toString())
template = template.replace("{GAME_SPRH}", gameParameters.sprites.height.toString())
template = template.replace("{GAME_HIDE_MOUSE}", gameParameters.hideMouseCursor.toString())

template = replaceList(template, (gameParameters.scripts + gameParameters.libraries.map { "$it.lua" }), "{GAME_SCRIPT}", "GAME_SCRIPT")
template = replaceList(template, gameParameters.spritesheets, "{GAME_SPRITESHEET}", "GAME_SPRITESHEET")
Expand Down
2 changes: 1 addition & 1 deletion tiny-cli/src/jvmMain/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>
<body>
<div style="text-align:center;">
<tiny-game name="{GAME_NAME}" width="{GAME_WIDTH}" height="{GAME_HEIGHT}" zoom="{GAME_ZOOM}" spritew="{GAME_SPRW}" spriteh="{GAME_SPRH}">
<tiny-game name="{GAME_NAME}" mouse="{GAME_HIDE_MOUSE}" width="{GAME_WIDTH}" height="{GAME_HEIGHT}" zoom="{GAME_ZOOM}" spritew="{GAME_SPRW}" spriteh="{GAME_SPRH}">
<!-- GAME_SCRIPT -->
<tiny-script name="{GAME_SCRIPT}"></tiny-script>
<!-- GAME_SCRIPT_END -->
Expand Down
5 changes: 5 additions & 0 deletions tiny-engine/src/jsMain/kotlin/com/github/minigdx/tiny/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fun setupGames(rootPath: String, tinyGameTag: HTMLCollection) {
val gameWidth = game.getAttribute("width")?.toInt() ?: 128
val gameHeight = game.getAttribute("height")?.toInt() ?: 128
val gameZoom = game.getAttribute("zoom")?.toInt() ?: 1
val hideMouse = game.getAttribute("mouse")?.toBoolean() ?: false

val sprWidth = game.getAttribute("spritew")?.toInt() ?: 16
val sprHeight = game.getAttribute("spriteh")?.toInt() ?: 16
Expand All @@ -93,6 +94,9 @@ fun setupGames(rootPath: String, tinyGameTag: HTMLCollection) {
canvas.setAttribute("width", (gameWidth * gameZoom).toString())
canvas.setAttribute("height", (gameHeight * gameZoom).toString())
canvas.setAttribute("tabindex", "1")
if (hideMouse) {
canvas.setAttribute("style", "cursor: none;")
}
game.appendChild(canvas)

val gameOptions = GameOptions(
Expand All @@ -106,6 +110,7 @@ fun setupGames(rootPath: String, tinyGameTag: HTMLCollection) {
zoom = gameZoom,
gutter = 0 to 0,
spriteSize = sprWidth to sprHeight,
hideMouseCursor = hideMouse,
)

val logger = StdOutLogger("game-$index")
Expand Down

0 comments on commit 0132ed4

Please sign in to comment.