-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
107 lines (93 loc) · 3.33 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>PacManBlazorUI</title>
<base href="/pacmanplay/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
</head>
<body>
<script>
var canvas;
var context;
var sprites;
var buffer = 0;
var tc = 0;
var ctx;
var backcanvas;
var backctx;
var skip = 0;
var sounds = [];
function Setup(cv, sm, sp) {
canvas = cv;
sprites = document.createElement('img');
sprites.src = "data:image/png;base64," + sp;
}
function Sprite(ctx, fx, fy, fs, tx, ty) {
ctx.drawImage(sprites, fx, fy, fs, fs, tx, ty, fs, fs);
}
function SoundSet(num, data) {
sounds[num] = new window.Audio();
sounds[num].src = "data:audio/wav;base64," + data;
}
function PlaySound(num) {
sounds[num].currentTime = 0;
sounds[num].play();
}
function SpriteSet(width, height, parms) {
try {
if (tc == 0) {
// alert("create");
canvas.width = width;
canvas.height = height;
context = canvas.getContext("2d", { alpha: false });
context.imageSmoothingEnabled = false;
tc = document.createElement('canvas');
tc.width = width;
tc.height = height;
ctx = tc.getContext('2d', { alpha: false });
ctx.imageSmoothingEnabled = false;
backcanvas = document.createElement('canvas');
backcanvas.width = width;
backcanvas.height = height;
backctx = backcanvas.getContext('2d', { alpha: false });
backctx.imageSmoothingEnabled = false;
}
for (var i = 0; i < parms.length; i += 6) {
if (parms[i] == 1) {
Sprite(backctx, parms[i + 1], parms[i + 2], parms[i + 3], parms[i + 4], parms[i + 5]);
}
}
skip++;
if (skip > 0) {
ctx.drawImage(backcanvas, 0, 0);
for (var i = 0; i < parms.length; i += 6) {
if (parms[i] == 0) {
Sprite(ctx, parms[i + 1], parms[i + 2], parms[i + 3], parms[i + 4], parms[i + 5]);
}
}
context.drawImage(tc, 0, 0, width, height);
skip = 0;
}
}
catch (e) { }
var scale = Math.min(window.innerWidth / width, window.innerHeight / height);
var h = Math.floor(height * scale);
var w = Math.floor(width * scale);
if (canvas.style.height != h) {
canvas.style.height = Math.floor(height * scale) + "px";
canvas.style.width = Math.floor(width * scale) + "px";
}
}
</script>
<app>Loading...</app>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>