Эх сурвалжийг харах

Added event focusing in the web index template and fixed an error in the docs

Karl Zylinski 1 сар өмнө
parent
commit
a2784fd898

+ 3 - 6
README.md

@@ -80,22 +80,19 @@ odin run build_web -- your_game_path
 
 The web build will end up in `your_game_path/bin/web`.
 
-It requires that you game contains a `main` procedure and a `step` procedure. The `main` procedure is called once on startup and the `step` procedure will be called every frame of your game.
-
->[!WARNING]
->When making web builds, make sure your `main` procedure does not have a "main loop" in it. That will hang the browser tab when your game starts.
+It requires that you game contains a `init` procedure and a `step` procedure. The `init` procedure is called once on startup and the `step` procedure will be called every frame of your game.
 
 Also, see the `minimal_web` example: https://github.com/karl-zylinski/karl2d/blob/master/examples/minimal_web/minimal_web.odin
 
 The `build_web` tool will copy `odin.js` file from `<odin>/core/sys/wasm/js/odin.js` into the `bin/web folder`. It will also copy a HTML index file into that folder.
 
-It will also create a `build/web` folder. That's the package it actually builds. It contains a bit of wrapper code that then calls the `main` and `step` functions of your game. The result of building the wrapper (and your game) is a `main.wasm` file that also ends up in `bin/web`.
+It will also create a `build/web` folder. That's the package it actually builds. It contains a bit of wrapper code that then calls the `init` and `step` functions of your game. The result of building the wrapper (and your game) is a `main.wasm` file that also ends up in `bin/web`.
 
 Launch your game by opening `bin/web/index.html` in a browser.
 
 ## Architecture notes
 
-The platform-independent parts and the main API lives in `karl2d.odin`
+The platform-independent parts and the API lives in `karl2d.odin`
 
 `karl2d.odin` in turn has a window interface and a rendering backend.
 

+ 2 - 2
build_web/web_entry_templates/index_template.html

@@ -3,10 +3,10 @@
 	<head>
 		<meta charset="UTF-8">
 		<meta name="viewport" content="width=device-width, initial-scale=1">
-		<title>Karl2D Example</title>
+		<title>Karl2D Web Build</title>
 	</head>
 	<body id="body" style="height: 100%; padding: 0; margin: 0; overflow: hidden; background-color: black;">
-		<canvas id="webgl-canvas" oncontextmenu="return false;"></canvas>
+		<canvas id="webgl-canvas" oncontextmenu="return false;" onmousedown="event.target.focus()" onkeydown="event.preventDefault()"></canvas>
 	
 		<script type="text/javascript" src="odin.js"></script>
 		<script type="text/javascript">