-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgames_singlefile.html
More file actions
157 lines (123 loc) · 3.13 KB
/
Copy pathgames_singlefile.html
File metadata and controls
157 lines (123 loc) · 3.13 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!-- Use this example to import and use games from PGIS 3 in your own projects, but make sure to give proper credits-->
<!-- All games are imported from PGIS 3. -->
<!-- Visit PGIS 3 at https://pgis3.vercel.app. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PGIS 3 Games single-file</title>
<style>
body{
scroll-behavior: smooth;
color: white;
width: 100%;
height: 100%;
font-family: Arial, sans-serif;
margin: 0;
background-color: black;
b{
text-align:center !important;
}
#games{
background-color:rgba(0,0,0,0.1);
display:flex;
justify-content:center;
gap: 40px; /* used to be 20px*/
flex-wrap:wrap;
position:relative;
padding: 30px; /* remove if bad */
height: 100%;
}
.game{
width:200px;
height:170px;
background-color:rgba(0,0,0,0.3);
background-size:cover;
background-position:center;
cursor:auto;
border:1px solid #444;
border-radius:5px;
display:flex;
flex-direction:column;
justify-content:center;
align-items:center;
position:relative;
padding: 5px; /* remove if bad */
}
img {
height: 100px;
width: 100px;
}
button{
border-radius: 4px;
border:none;
background:#444;
color:white;
cursor:pointer;
margin: 10px;
}
#launcher{
display:none;
width:100%;
height:100vh;
background:white;
}
a{
color: whitesmoke;
}
#back{
position:fixed;
}
</style>
</head>
<body>
<div id="browser">
<b>Imported from <a href="https://pgis3.vercel.app" target="_blank">pgis 3</a></b>
<div id="games"></div>
</div>
<div id="launcher"></div>
<script>
const BASE = "https://pgis3.vercel.app";
async function loadGames() {
const names = await fetch(`${BASE}/games.json`).then(r => r.json());
const container = document.getElementById("games");
for (const name of names) {
const card = document.createElement("div");
card.className = "game";
card.innerHTML = `
<b>${name}</b>
<img src="${BASE}/games/${encodeURIComponent(name)}.png" width="100" height="100">
<button>Play</button>
`;
card.querySelector("button").onclick = () => playGame(name);
container.appendChild(card);
}
}
async function playGame(name) {
const html = await fetch(`${BASE}/games/${encodeURIComponent(name)}.html`)
.then(r => r.text());
const blob = new Blob([html], { type: "text/html" });
const url = URL.createObjectURL(blob);
document.getElementById("browser").style.display = "none";
const launcher = document.getElementById("launcher");
launcher.style.display = "block";
launcher.innerHTML = `
<button id="back">← Back</button>
<iframe
id="game"
src="${url}"
style="width:100%;height:calc(100vh - 50px);border:none;"
></iframe>
`;
document.getElementById("back").onclick = () => {
URL.revokeObjectURL(url);
launcher.style.display = "none";
launcher.innerHTML = "";
document.getElementById("browser").style.display = "block";
};
}
loadGames();
</script>
</body>
</html>