-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.html
128 lines (126 loc) · 5.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<script src="wasm_exec.js"></script>
<script defer>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("game.wasm"), go.importObject).then((result) => {
go.run(result.instance);
start();
});
</script>
<script defer src="app.js"></script>
<style>
.circle:hover {
cursor: pointer;
}
#yellow {
background-color: yellow;
}
#red {
background-color: red;
}
#green {
background-color: green;
}
#blue {
background-color: blue;
}
#pink {
background-color: pink;
}
</style>
</head>
<body>
<section class="hero is-small has-background-primary-light">
<div class="hero-body">
<div class="container">
<p class="title">
Color Flood
</p>
</div>
</div>
<div class="hero-foot">
<nav class="navbar">
<div class="container">
<div class="navbar-menu">
<div class="navbar-end">
<a class="navbar-item" id="about-link">about</a>
</div>
</div>
</div>
</nav>
</div>
</section>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Your score</p>
<p class="title" id="count">0</p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Computer's score</p>
<p class="title" id="try-to-beat">0</p>
</div>
</div>
</nav>
<section class="section">
<nav class="level">
<div class="level-item has-text-centered">
<button class="button is-large" id="red"></button>
<button class="button is-large" id="blue"></button>
<button class="button is-large" id="pink"></button>
<button class="button is-large" id="green"></button>
<button class="button is-large" id="yellow"></button>
</div>
</div>
</nav>
<div class="container has-text-centered">
<canvas id="canvas" width="300" height="300"></canvas>
</div>
</section>
<section class="section">
<div class="box has-background-info-light">
<label class="label" for="level">level selector</label>
<form class="field has-addons">
<p class="control">
<input type="text" class="input" id="level" name="level" value="0"></input>
</p>
<p class="control">
<input class="button" type="submit" value="go"></input>
</p>
</form>
</div>
</section>
<div class="modal" id="about-modal">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">About</p>
<button class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="content">
<p>
This is an experimental game where the backend is written
in Go and compiled to <a href="https://webassembly.org">Wasm</a>.
Honestly, it started from a desire to learn about import maps but then
I didn't really feel like implementing anything hard in JavaScript. Then
the frontend code was so simple I didn't need any dependencies.
So overall, a bad pick for learning import maps, but great for Wasm!
</p>
<p>I found <a href="https://golangbot.com/webassembly-using-go/">this page to be quite helpful</a> when writing Go for Wasm.</p>
<p>Feel free to read through the source code and find me on <a href="https://twitter.com/chuck_ha">twitter</a> if you have questions!</p>
</div>
</section>
<footer class="modal-card-foot">
<a class="card-footer-item" href="https://github.com/chuckha/ColorFlood">View the source code</a>
</footer>
</div>
</div>
</body>
</html>