-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
120 lines (103 loc) · 3.49 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
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="assets/css/style.css"/>
<script src='https://www.kongregate.com/javascripts/kongregate_api.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.2.1/echarts.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<script src="assets/script/shake.js"> </script>
<script src="assets/script/graph.js"> </script>
<script src="assets/script/pieces.js"> </script>
<script src="assets/script/shape.js"> </script>
<script src="assets/script/menuHandler.js"></script>
<script src="assets/script/hole.js"> </script>
<script src="assets/script/holder.js"> </script>
<script src="assets/script/carp.js"> </script>
<script src="assets/script/textanim.js"> </script>
</head>
<body>
<div class="gameWrapper">
<div class="game">
<div id="tutorialWindow" class="draggable">
<div class="window-top">
<div class="window-title"> Tutorial</div>
<div class="window-close">×</div>
</div>
<div class="window-bottom">
Use the randomly generated pentominoes from the holders below to fill holes in the most efficient manner.
<br><br>
Mouse Click to pick up / drop
<br><br>
Scroll wheel to rotate
<br><br>
Neglecting holes will lead to pieces falling out
<br><br>
Each shape can only be placed twice.
</div>
</div>
<div class="canvasWrapper">
<canvas id="carpCanvas"></canvas>
</div>
<div class="menuWrapper">
<div class="menu" id="mainMenu">
<img class="titleImage" src="assets/images/pentoTitle.png"/>
<button id="startGame"> Start Game </button>
</div>
<div class="menu" id="gameMenu">
<div id="levelWrapper">
<img class="levelIndicator" src="assets/images/staroutline.png" />
<img class="levelIndicator" src="assets/images/starFilled.png" />
</div>
</div>
<div class="menu" id="statsMenu">
<div class="stats">
<div id="comboGraph"></div>
</div>
</div>
</div>
</div>
</div>
<script>
let elements = document.getElementsByClassName("draggable");
for(let i = 0; i < elements.length; i++){
dragElement(elements[i]);
}
function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
elmnt.onmousedown = dragMouseDown;
// Get close button
let close = elmnt.getElementsByClassName("window-close")[0];
close.onclick = closeWindow;
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
}
function closeWindow(){
elmnt.parentNode.removeChild(elmnt);
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}</script>
</body>
</html>