awacke1 commited on
Commit
b6059e7
·
1 Parent(s): a833a31

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +4 -86
index.html CHANGED
@@ -2,10 +2,11 @@
2
  <html>
3
  <head>
4
  <meta charset="utf-8">
5
- <title>Tilemap Example</title>
6
  <style>
7
  body {
8
  margin: 0;
 
9
  overflow: hidden;
10
  }
11
  canvas {
@@ -16,89 +17,6 @@
16
  </head>
17
  <body>
18
  <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
19
- <script>
20
- // create the scene
21
- var scene = new THREE.Scene();
22
-
23
- // create the camera
24
- var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
25
- camera.position.z = 5;
26
-
27
- // create the renderer
28
- var renderer = new THREE.WebGLRenderer();
29
- renderer.setSize(window.innerWidth, window.innerHeight);
30
- document.body.appendChild(renderer.domElement);
31
-
32
- // create the tilemap
33
- var tilemap = [
34
- [0, 0, 0, 0, 0],
35
- [0, 1, 1, 1, 0],
36
- [0, 1, 1, 1, 0],
37
- [0, 1, 1, 1, 0],
38
- [0, 0, 0, 0, 0],
39
- ];
40
- var tileSize = 1;
41
- var tileGeometry = new THREE.PlaneGeometry(tileSize, tileSize);
42
- var tileMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff });
43
- var tiles = [];
44
- for (var i = 0; i < tilemap.length; i++) {
45
- for (var j = 0; j < tilemap[i].length; j++) {
46
- if (tilemap[i][j] === 1) {
47
- var tile = new THREE.Mesh(tileGeometry, tileMaterial);
48
- tile.position.x = (j - tilemap[i].length / 2) * tileSize;
49
- tile.position.y = (-i + tilemap.length / 2) * tileSize;
50
- scene.add(tile);
51
- tiles.push(tile);
52
- }
53
- }
54
- }
55
-
56
- // create the arrow buttons
57
- var arrowUp = document.createElement('button');
58
- arrowUp.innerText = '↑';
59
- arrowUp.style.position = 'absolute';
60
- arrowUp.style.left = '50%';
61
- arrowUp.style.top = '10px';
62
- arrowUp.addEventListener('click', function() {
63
- camera.position.y += 1;
64
- });
65
- document.body.appendChild(arrowUp);
66
-
67
- var arrowDown = document.createElement('button');
68
- arrowDown.innerText = '↓';
69
- arrowDown.style.position = 'absolute';
70
- arrowDown.style.left = '50%';
71
- arrowDown.style.bottom = '10px';
72
- arrowDown.addEventListener('click', function() {
73
- camera.position.y -= 1;
74
- });
75
- document.body.appendChild(arrowDown);
76
-
77
- var arrowLeft = document.createElement('button');
78
- arrowLeft.innerText = '←';
79
- arrowLeft.style.position = 'absolute';
80
- arrowLeft.style.left = '10px';
81
- arrowLeft.style.top = '50%';
82
- arrowLeft.addEventListener('click', function() {
83
- camera.position.x -= 1;
84
- });
85
- document.body.appendChild(arrowLeft);
86
-
87
- var arrowRight = document.createElement('button');
88
- arrowRight.innerText = '→';
89
- arrowRight.style.position = 'absolute';
90
- arrowRight.style.right = '10px';
91
- arrowRight.style.top = '50%';
92
- arrowRight.addEventListener('click(function() {
93
- camera.position.x += 1;
94
- });
95
- document.body.appendChild(arrowRight);
96
- // animate the scene
97
- function animate() {
98
- requestAnimationFrame(animate);
99
- renderer.render(scene, camera);
100
- }
101
- animate();
102
- </script>
103
  </body>
104
- </html>
 
2
  <html>
3
  <head>
4
  <meta charset="utf-8">
5
+ <title>Tower Defense Game</title>
6
  <style>
7
  body {
8
  margin: 0;
9
+ padding: 0;
10
  overflow: hidden;
11
  }
12
  canvas {
 
17
  </head>
18
  <body>
19
  <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
20
+ <script src="game.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  </body>
22
+ </html>