-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7pauseLoop.js
105 lines (87 loc) · 2.17 KB
/
7pauseLoop.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
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
//copied and edited from Chase a little dot 2-1
//at 8/29/2022 2:47 PM CST Monday
//make the loop a variable
var loop=false;
//start the loop
var loop=setInterval(aLoop,settings.mspf);
//var loop=setInterval(data.loopFunction,settings.mspf);
function startLoop(){
loop=setInterval(aLoop,settings.mspf);
//loop=setInterval(data.loopFunction,settings.mspf);
}
function aLoop(){
//this number is multiplied by like all velocities and stuffs
data.loopFunction(1/60);
}
var escapePressed=false;
var gameRunning=true;
//pause loop ...
//copied from matrices-3d-58
//at 7/10/2022 1:23 PM CST Sunday
var pauseLoop=setInterval(()=>{
if(!keyPressed("Escape")){
escapePressed=false;
}
if(keyPressed("Escape")&&escapePressed==false){
//escape key is pressed
escapePressed=true;
//check if the game is running or not
if(gameRunning){
//pause the game
loop?clearInterval(loop):false;
}else{
//run the game
loop?startLoop():animatedLinesLoop.newLoop();
}
//toggle gameRunning
gameRunning=!gameRunning;
//loopvariable=setInterval(waitloop,fps)
}
},1000/60);
//function waitloop(){
// if(!keys("Escape")){
// escapepressed=false;
// }
// if(keys("Escape")&&escapepressed==false){
// clearInterval(loopvariable);
// escapepressed=true;
// loopvariable=setInterval(loop,fps);
// }
//}
//},1000/60);
//the pause loop
//function pauseLoop(){
// loop.clearInterval();
// loop=setInterval(()=>{
// if(keyPressed("Escape")){
// //startLoop();
// loop.clearInterval();
// }
// },1000/60);
//}
//funny stuff happens if it is run multiple times
//startLoop();
//startLoop();
//startLoop();
//startLoop();
//start the loop
//*/
//startLoop();
//-9/6/2022 Tuesday 2:14 PM CST
//pause function
//usefull for the massive console.logs mid loop
function pause(){
//copy/pasted/reformatted indentation/
//modified to be one way from above
//check if the game is running or not
if(gameRunning){
//pause the game
loop?clearInterval(loop):false;
//toggle gameRunning
gameRunning=!gameRunning;
}//else{
//run the game
//startLoop();
//}
}
console.log("7 pauseLoop loaded");