-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblocks.html
More file actions
302 lines (292 loc) · 7.66 KB
/
blocks.html
File metadata and controls
302 lines (292 loc) · 7.66 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="style.css"/>
<title>Blocks</title>
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.2.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/eruda"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>eruda.init();</script>
</head>
<body>
<h1>Blocks</h1>
<p>Alpha 0.6.1<br>Play the full version <a href="blocks2.html">Here</a></p>
<canvas id="game" height="160" width="160">
</canvas>
<img style="position:absolute; top:0px; left:0px;" src="player.png" id="player">
<button id="changemap">Change map</button>
Current map: <span id="cmap">Two Islands</span><br>
If you see magenta, there was an error
<button id="up">Up</button>
<button id="dn">Down</button>
<button id="lf">Left</button>
<button id="rg">Right</button>
<br>
<button id="togCM">Toggle Country Mode</button>
Currently <span id="cm">off</span>.
<script type="module">
var x = 1
var y = 11
var mx = 0
var my = 0
var t = "w"
var cm = false
$("#togCM").click(()=>{
cm = !cm
if(cm){
$("#cm").text("on")
}else{
$("#cm").text("off")
}
})
var ct = {
terr: [[mx,my]],
name: "",
color: "#ff00ff80"
}
import {RMG} from "./rmg.js"
import {italy} from "./italy.js"
var twoIslands = [
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwffwwwwwww"],
[..."wwwwwffffwwwwwww"],
[..."wwwwwwffwwwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwgwwwwwww"],
[..."wwwwwwwggggwwwww"],
[..."wwwwwgggmmggwwww"],
[..."wwwwwwggmfggwwww"],
[..."wwwwwwwgggwwwwww"],
[..."wwwwwwwwwgwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwwwwwwwww"]
]
var cgs = twoIslands
var river = [
[..."ffffffffffffffff"],
[..."ffffffffffffffff"],
[..."ffffffffffffffff"],
[..."ffffffffgfffffff"],
[..."fffffffgggffffff"],
[..."ffffffwwwwwfffff"],
[..."fffffwwwwwwwffff"],
[..."ffffffwwwwwfffff"],
[..."ffffffffffwfffff"],
[..."ffffffffffwwffff"],
[..."fffffffffffwffff"],
[..."ffffffmmmmmfwwww"],
[..."fffmmmgggmmmffff"],
[..."fmmgggggggmgffff"],
[..."mgggggggggmggggf"],
[..."gggggggggggggggg"]
]
var delta = [
[..."wwwwwwwwwwwwwwww"],
[..."wwwwwwwwwwwwwwww"],
[..."gwgwgwgwgwgwgwgw"],
[..."ggwgggwgggwgggwg"],
[..."gggwgwgggggwgwgg"],
[..."ggggwgggggggwggg"],
[..."gggggwwwwgwwgggg"],
[..."gggggggggwgggggg"],
[..."gggggggggwgggggg"],
[..."ggggggggfwfggggg"],
[..."gggggggffwffgggg"],
[..."ggggggfffwfffggg"],
[..."gggggffffwffffgg"],
[..."ggggfffffwfffffg"],
[..."ggfffffffwffffff"],
[..."gffffffffwffffff"]
]
var cmap=0
console.log(cgs)
var i = 0
var j = 0
var c = document.getElementById("game");
var ctx = c.getContext("2d");
for(i=0;i<=255;i++){
j = Math.floor(i/16)
switch(cgs[j][i%16]){
case "w":
ctx.fillStyle="#0000ff"
break;
case "f":
ctx.fillStyle="#008000"
break;
case "g":
ctx.fillStyle="#808000"
break;
case "m":
ctx.fillStyle="#c0c0c0"
break;
}
ctx.fillRect(10*(i-(16*j)),10*j,10,10)
}
$("#changemap").click(function(){
ctx.clearRect(0, 0, c.width, c.height)
cmap = (cmap+1)%5
switch(cmap){
case 0:
cgs = twoIslands
$("#cmap").text("Two Islands")
break
case 1:
cgs = river
$("#cmap").text("River")
break
case 2:
cgs = delta
$("#cmap").text("Delta")
break
case 3:
cgs = RMG()
$("#cmap").text("Random")
break
case 4:
cgs = italy
$("#cmap").text("Italy")
$("body").append("<img src='pizza.png' id='pizza'/>")
}
for(i=0;i<=255;i++){
j = Math.floor(i/16)
switch(cgs[j][i%16]){
case "w":
ctx.fillStyle="#0000ff"
break;
case "f":
ctx.fillStyle="#008000"
break;
case "g":
ctx.fillStyle="#808000"
break;
case "m":
ctx.fillStyle="#c0c0c0"
break;
default:
ctx.fillStyle = "#ff00ff"
break;
}
ctx.fillRect(10*(i-(16*j)),10*j,10,10)
}
})
y -= 0.5
$("#player").css("top", 10*y+"px")
$("#player").css("left", 10*x+"px")
$("#up").click(function(){
y--
my--
$("#player").css("top", 10*y+"px")
t = cgs[my][mx]
})
$("#dn").click(function(){
y++
my++
t = cgs[my][mx]
$("#player").css("top", 10*y+"px")
})
$("#lf").click(function(){
x--
mx--
$("#player").css("left", 10*x+"px")
t = cgs[my][mx]
})
$("#rg").click(function(){
x++
mx++
$("#player").css("left", 10*x+"px")
t = cgs[my][mx]
})
var sl = [
"Th",
"S",
"T",
"P",
"H",
"Sh",
"M",
"B",
"V",
"J"
]
var cons = [
"b",
"bb",
"c",
"ch",
"d",
"dd",
"f",
"g",
"gh",
"h",
"j",
"k",
"kh",
"l",
"ll",
"m",
"n",
"nn",
"mm",
"p",
"ph",
"qu",
"r",
"rr",
"s",
"sh",
"t",
"th",
"v",
"w",
"x",
"y",
"z"
]
var vow = [
"a",
"aa",
"ae",
"ai",
"au",
"aw",
"e",
"ee",
"i",
"igh",
"o",
"oa",
"oo",
"u",
"uh",
"ue"
]
ct.name=sl[Math.floor(Math.random()*sl.length)]+vow[Math.floor(Math.random()*vow.length)]+cons[Math.floor(Math.random()*cons.length)]
setInterval(()=>{
if(cm){
ct.terr[0] = [mx,my]
for(i of ct.terr){
switch(cgs[i[1]][i[0]]){
case "m":
ctx.fillStyle = "#d860d8"
break
case "f":
ctx.fillStyle = "#804080"
break
case "g":
ctx.fillStyle = "#c04080"
break
case "w":
ctx.fillStyle = "#8000ff"
break
}
ctx.fillRect(10*i[0],10*(i[1]-1),10,10)
}
}
},100)
</script>
</body>
</html>