forked from loglot/Yet-Another-Collectathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
75 lines (65 loc) · 2.27 KB
/
main.js
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
'use strict';
import { Game } from "./lib/imports.js";
var game = new Game()
function gameLoop() {
game.keyMan.update()
game.display.Game()
if(!game.MainMenu){
game.player.update()
}
if(game.keyMan.wasKeyJustPressed("KeyW") && game.MainMenu && game.MenuState == "main"){
game.MainMenu = false
game.soundMenu.volume = .15
if(game.Audios){
game.soundMenu.play()
}
game.player.grow(70)
}else if(game.keyMan.wasKeyJustPressed("KeyS") && game.MainMenu && game.MenuState == "main"){
game.MenuState = "settings"
}else if(game.keyMan.wasKeyJustPressed("KeyS") && game.MainMenu && game.MenuState == "settings"){
game.MenuState = "main"
}else if(game.keyMan.wasKeyJustPressed("ArrowUp") && game.MainMenu && game.MenuState == "settings"){
if(game.SettingSelect > 0){
game.SettingSelect -= 1
}
}else if(game.keyMan.wasKeyJustPressed("ArrowDown") && game.MainMenu && game.MenuState == "settings"){
if(game.SettingSelect < 3){
game.SettingSelect += 1
}
}else if(game.keyMan.wasKeyJustPressed("ArrowLeft") && game.MainMenu && game.MenuState == "settings"){
if(game.SettingSelect == 0){
game.Style = !game.Style
}
if(game.SettingSelect == 1){
game.Grow = !game.Grow
}
if(game.SettingSelect == 2){
game.SpeedSelect--
if(game.SpeedSelect < 0){
game.SpeedSelect = 4
}
}
if(game.SettingSelect == 3){
game.Audios = !game.Audios
}
}else if(game.keyMan.wasKeyJustPressed("ArrowRight") && game.MainMenu && game.MenuState == "settings"){
if(game.SettingSelect == 0){
game.Style = !game.Style
}
if(game.SettingSelect == 1){
game.Grow = !game.Grow
}
if(game.SettingSelect == 2){
game.SpeedSelect++
if(game.SpeedSelect > 4){
game.SpeedSelect = 0
}
}
if(game.SettingSelect == 3){
game.Audios = !game.Audios
}
}
console.log(game.MenuState)
requestAnimationFrame(gameLoop)
}
requestAnimationFrame(gameLoop)