Spaces:
Sleeping

byte-vortex commited on
Commit
b94ce88
·
verified ·
1 Parent(s): b30a564

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/myco_game.html +66 -0
ui/myco_game.html ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <style>
5
+ body { background: #1a2e1a; color: #fef3c7; text-align: center; font-family: 'Arial', sans-serif; }
6
+ canvas { border: 4px solid #4d7c0f; background: #0c1a0c; display: block; margin: 10px auto; border-radius: 8px; }
7
+ #title { font-size: 32px; margin: 10px 0; color: #a3e635; font-weight: bold; }
8
+ #log { margin-top: 10px; font-style: italic; color: #d1d5db; min-height: 20px; padding: 0 20px; }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="title">Myco's Forest</div>
13
+ <canvas id="gameCanvas" width="400" height="400"></canvas>
14
+ <div id="log">Help Myco gather mushrooms to grow!</div>
15
+
16
+ <script>
17
+ const canvas = document.getElementById("gameCanvas");
18
+ const ctx = canvas.getContext("2d");
19
+ let snake = [{x: 200, y: 200}];
20
+ let food = {x: 100, y: 100};
21
+ let dx = 20, dy = 0;
22
+ let score = 0;
23
+
24
+ function draw() {
25
+ ctx.clearRect(0, 0, 400, 400);
26
+
27
+ // Draw Mushroom
28
+ ctx.fillStyle = "#ef4444";
29
+ ctx.beginPath();
30
+ ctx.arc(food.x + 10, food.y + 10, 8, 0, Math.PI * 2);
31
+ ctx.fill();
32
+ ctx.fillStyle = "#ffffff";
33
+ ctx.fillRect(food.x + 8, food.y + 12, 4, 6);
34
+
35
+ // Draw Myco (The Vine/Snake)
36
+ ctx.fillStyle = "#4d7c0f";
37
+ snake.forEach(part => {
38
+ ctx.fillRect(part.x + 2, part.y + 2, 16, 16);
39
+ });
40
+
41
+ let head = {x: snake[0].x + dx, y: snake[0].y + dy};
42
+ snake.unshift(head);
43
+
44
+ if (head.x === food.x && head.y === food.y) {
45
+ score++;
46
+ food = {x: Math.floor(Math.random()*20)*20, y: Math.floor(Math.random()*20)*20};
47
+ document.getElementById('log').innerText = "Myco found a delicious mushroom!";
48
+ } else {
49
+ snake.pop();
50
+ }
51
+
52
+ if(head.x < 0 || head.x >= 400 || head.y < 0 || head.y >= 400) {
53
+ alert("Myco got lost! Score: " + score);
54
+ snake = [{x: 200, y: 200}]; score = 0;
55
+ }
56
+ }
57
+ document.addEventListener("keydown", e => {
58
+ if(e.key === "ArrowUp" && dy === 0) { dx = 0; dy = -20; }
59
+ if(e.key === "ArrowDown" && dy === 0) { dx = 0; dy = 20; }
60
+ if(e.key === "ArrowLeft" && dx === 0) { dx = -20; dy = 0; }
61
+ if(e.key === "ArrowRight" && dx === 0) { dx = 20; dy = 0; }
62
+ });
63
+ setInterval(draw, 100);
64
+ </script>
65
+ </body>
66
+ </html>