-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
278 lines (235 loc) · 9.81 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
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Hexaflare</title>
<!-- CSS -->
<link href="css/application.css" rel="stylesheet" type="text/css" media="all">
<link href="css/progress_bar.css" rel="stylesheet" type="text/css" media="all">
<link href="css/stats.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<div id="title_screen">
<span id="title">Hexaflare</span><br/>
<div id="title_screen_buttons">
<div class="title_screen_button" id="start_game_button" data-highlighted="false">start game</div>
<div class="title_screen_button" id="how_to_play_button" data-full="false">how to play</div>
<!--div class="title_screen_button" id="exit_button" data-full="false">exit</div-->
</div>
<a href="https://www.github.com/gazayas/hexaflare" target="_blank">
<image id="github-icon" src="images/github-white.png"/>
</a>
</div>
<div id="choose_level_information">
<p>choose which level to start from (1-12)</p>
<span id="choose_level_container">1</span>
</div>
<div id="how_to_play">
<h3>Controls</h3>
<span>
Rules: Make rings with the blocks to make them disappear.
</span><br/>
<span>
Movement: Arrow keys, or i, j, k, and l.
</span><br/>
<span>
Drop block: z or space.
</span><br/>
<span>
Rotate block: x and c.
</span>
<br/><br/>
<span>
You can also play with a USB controller.
</span>
<h3>Controls (tip)</h3>
<span>
Use s and d (or the bumpers on a controller) to move the star cluster along the flare star one block at a time for more precise movements.<br/>
</span>
</div>
<div id="pause_screen">
<div id="pause_screen_options">
<p>paused</p>
<p>press start to continue</p>
</div>
</div>
<div id="hexaflare">
<!-- (ToT) 🌠
<div class="space stars1"></div>
<div class="space stars2"></div>
<div class="space stars3"></div>
-->
<div class="flare_star">
<div class="core">
<!-- The general structure for hexagons. -->
<div class="hexagon background_hexagon inner_flare_star_hexagon" data-ring_level="0" data-value="1" data-x="0" data-y="0" data-full="false">
<div class="hexagon_top"></div>
<div class="hexagon_center"></div>
<div class="hexagon_bottom"></div>
</div>
</div>
</div>
<div class="timer vertical">
<div class="progress-bar progress-bar-info" role="progressbar" varia-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div id="level_container">level <span id="level">1</span></div>
<div id="message_container"></div>
<div id="score_container">score <span id="score">0</span></div>
<div id="flare_count_container">flare count <span id="flare_count">0</span></div>
<!-- TODO: Display the next clusters here (3 to 4) -->
</div>
<!-- JavaScript -->
<!-- TODO: Should probably move everything to javascript/application.js -->
<script src="javascript/application.js"></script>
<script src="javascript/title_screen.js"></script>
<script src="javascript/sleep.js"></script>
<script src="javascript/flare_star.js"></script>
<script src="javascript/hexagon.js"></script>
<script src="javascript/mapping.js"></script>
<script src="javascript/gravity.js"></script>
<script src="javascript/collision.js"></script>
<script src="javascript/flare.js"></script>
<script src="javascript/gamepad.js"></script>
<script src="javascript/keyboard_buttons.js"></script>
<script src="javascript/progress_bar.js"></script>
<!-- Star Clusters -->
<script src="javascript/star_clusters/proxima_data.js"></script>
<script src="javascript/star_clusters/jewel_data.js"></script>
<script src="javascript/star_clusters/pleiades_data.js"></script>
<script src="javascript/star_clusters/alpha_data.js"></script>
<script src="javascript/star_clusters/lambda_data.js"></script>
<script src="javascript/star_clusters/pi_data.js"></script>
<script src="javascript/star_clusters/omicron_data.js"></script>
<script src="javascript/star_clusters/pearl_data.js"></script>
<script src="javascript/star_clusters/blanco_data.js"></script>
<script src="javascript/star_clusters/butterfly_data.js"></script>
<script src="javascript/star_clusters/one_data.js"></script>
<script src="javascript/star_cluster.js"></script>
<!-- <script src="test/flare_star_test.js"></script> -->
<script type="text/javascript">
// Global variables
var HEX_CENTER_WIDTH
var HEX_CENTER_HEIGHT
var HEX_TOP_BOTTOM_BORDER_HEIGHT
var HEX_INVISIBLE_BORDERS
var HEX_TOTAL_HEIGHT
var HEX_X_MARGIN
var HEX_Y_MARGIN
var REAL_X
var REAL_Y
var HEX_COLOR
var CORONA_IS_VISIBLE
var UPDATE_TIMER
var FLIP_FACTOR
var PLAYER_SCORE
var CURRENT_LEVEL
var TOTAL_FLARE_COUNT
var GAME_OVER
var ON_TITLE_SCREEN = true
var CHOOSING_LEVEL = false
var GAME_PAUSED = false
var VIEWING_HOW_TO_PLAY = false
// TODO: Make these uppercase
var flare_star
var flare_star_ui
var floating_cluster
var preview_cluster
var star_cluster_name
// Sounds and Music
var HEXAFLARE_MUSIC = new Audio('../audio/hexaflare_music.wav')
var MOVE_SOUND = new Audio('../audio/move.wav')
var DROP_SOUND = new Audio('../audio/drop.wav')
var FLARE_SOUND = new Audio('../audio/flare.wav')
HEXAFLARE_MUSIC.volume = 0 // Muting this for now, used to be 0.6.
MOVE_SOUND.volume = 0.5
DROP_SOUND.volume = 0.7
FLARE_SOUND.volume = 0.7
// Hide the timer at first, then display it on startGame()
document.getElementsByClassName("timer")[0].style.visibility = "hidden"
// Initialize the title screen cursor on "start game"
initializeTitleScreenCursor()
var frame_update_flag = 1
function animate() {
processTimerEvents()
if(frame_update_flag >= 4) {
frame_update_flag = keyboardButtonFrameUpdate()
}
frame_update_flag++
if(keys_enabled) { UPDATE_TIMER = true }
if(HEXAFLARE_MUSIC.currentTime >= 335.77) {
HEXAFLARE_MUSIC.currentTime = 47.89
}
console.log(HEXAFLARE_MUSIC.currentTime)
window.requestAnimationFrame(animate)
}
function startGame(starting_level = 1) {
// Cue the music!
if(HEXAFLARE_MUSIC.paused) {
HEXAFLARE_MUSIC.currentTime = 0
HEXAFLARE_MUSIC.play()
}
// TODO: Maybe put this somewhere else, like in the function it's originally called from.
// Change screens
ON_TITLE_SCREEN = false
CHOOSING_LEVEL = false
document.getElementById("level_container").style.visibility = "visible"
document.getElementById("score_container").style.visibility = "visible"
document.getElementById("flare_count_container").style.visibility = "visible"
resetFlareStar()
document.getElementById("choose_level_information").style.visibility = "hidden"
document.getElementById("choose_level_container").innerHTML = 1
// TODO: Maybe put this in resetFlareStar()
// Reset stats
document.getElementById("level").innerHTML = starting_level
document.getElementById("score").innerHTML = 0
document.getElementById("flare_count").innerHTML = 0
current_prog = 100 // Resets the timer
keys_enabled = false
// TODO: Make radio buttons (1-12) and set starting_level to the radio button value
// In pixels
HEX_CENTER_WIDTH = 30
HEX_CENTER_HEIGHT = 18
HEX_TOP_BOTTOM_BORDER_HEIGHT = 7
HEX_INVISIBLE_BORDERS = 15 // Extends top and bottom triangles horizontally
HEX_TOTAL_HEIGHT = HEX_CENTER_HEIGHT + (HEX_TOP_BOTTOM_BORDER_HEIGHT * 2)
HEX_X_MARGIN = 4
HEX_Y_MARGIN = 3 // Use a negative number for greater distance
REAL_X = HEX_CENTER_WIDTH + HEX_X_MARGIN
REAL_Y = HEX_TOTAL_HEIGHT - HEX_Y_MARGIN
HEX_COLOR = "silver"
CORONA_IS_VISIBLE = false
UPDATE_TIMER = true
// Used when moving star clusters towards parent hexagons
FLIP_FACTOR = 0
// Initialize player stats
PLAYER_SCORE = 0
CURRENT_LEVEL = starting_level
TOTAL_FLARE_COUNT = 0
GAME_OVER = false
flare_star = generateFlareStar(12)
flare_star_ui = document.getElementsByClassName("flare_star")[0]
generateFlareStarUI(numberOfRings(flare_star))
var inner_flare_star_hexagons = document.getElementsByClassName("inner_flare_star_hexagon")
for (var x = 0; x < inner_flare_star_hexagons.length; x++) {
applyHexagonDimensions(inner_flare_star_hexagons[x], HEX_COLOR, {"inner_flare_star_hexagon_opacity": 0.3})
}
if(CORONA_IS_VISIBLE) {
var corona_background_hexagons = document.getElementsByClassName("corona_hexagon")
for (var i = 0; i < corona_background_hexagons.length; i++) {
applyHexagonDimensions(corona_background_hexagons[i], HEX_COLOR, {"opacity": 0.075})
}
}
star_cluster_name = randomStarClusterType()
generateStarCluster(star_cluster_name)
floating_cluster = document.getElementsByClassName("floating_cluster")
generatePreviewStarCluster(floating_cluster)
preview_cluster = document.getElementsByClassName("preview_cluster")
drop(preview_cluster, true)
keys_enabled = true
}
// This runs the game's update loop so we can
// process the timer and button presses as desired.
animate()
</script>
</body>
</html>