-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_shadebob.html
45 lines (40 loc) · 1.4 KB
/
demo_shadebob.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>retro js</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="fps"></div>
<script src="retro.js"></script>
<script>
my_screen = new Screen(
128, 128,
Palette.gradient(0, 0, 0, 255, 0, 0, 64)
.add_colors(Palette.gradient(255, 0, 0, 0, 255, 0, 64))
.add_colors(Palette.gradient(0, 255, 0, 0, 0, 255, 64))
.add_colors(Palette.gradient(0, 0, 255, 255, 0, 0, 64)),
(app) => {
bob_width = 16
bob_height = 16
width = (app.width - bob_width) / 2
height = (app.height - bob_height) / 2
var blob = function (sx, sy, add) {
ix = Math.floor(sx)
iy = Math.floor(sy)
for (var y = 0; y < 15; y++) {
for (var x = 0; x < 15; x++) {
app.screen[(iy + y) * app.width + (ix + x)] += add
}
}
}
blob(
Math.sin(app.frame_number * 3.14 / 180 * 0.37) * width + width,
Math.cos(app.frame_number * 3.14 / 180 * 0.73) * height + height,
1
)
}, 2)
</script>
</body>
</html>