-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathiTime.prg
More file actions
292 lines (232 loc) · 5.07 KB
/
iTime.prg
File metadata and controls
292 lines (232 loc) · 5.07 KB
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
//Autor: Adrian Melian (KeiDash)
//Date: 10/12/2017
//Description: Modulo que distribuye y manipula las proporciones de tiempo.
Function int iTIME_get_PercentToShowSon(byte chordSpeed)
Begin
ciclos = _MAXCHORD_Y - _MINCHORD_Y;
frame;
Switch(chordSpeed)
case 1:
minTime = ((ciclos / FPS) * 2);
end
case 2:
minTime = ciclos / FPS;
end
case 3:
minTime = ciclos / (FPS * 3);
end
End
return minTIme * 1000;
End
Function float iTIME_get_TiempoMinimoEspera()
Begin
return ((_MAXCHORD_Y - _MINCHORD_Y) / FPS) * 1000;
End
Function int TimeToMiliseconds(string time)
Private
float ftime = 0.0;
int mTime = 0;
Begin
ftime = atof(time);
mTime = ftime * 1000;
return mTime;
End
/*Process initialiceTimer()
Private
Begin
Loop
gi_MILIS = get_timer();
frame;
End
End*/
/*Function WaitSeconds(int milis)
Private
int toWait = 0;
Begin
toWait = get_timer() + milis;
Repeat
frame;
Until(get_timer() >= towait)
End*/
/*
* Descripcion: Proceso que lanza una espera de tiempo en milisegundos.
* Para indicar que ha terminado, actualiza la varible global
* gi_TimeFinished a 1.
* Nota: El usuario debe actualizar el valor de gi_TimeFinished a -1
* para que vuelva a inicializarse la variable y se pueda usar posteriormente.
* Parametros:
* - int milis Tiempo en milisegundos. Se puede generar con la ayuda de la función TimeToMiliseconds()
*/
Process Waiting(int milis)
Private
int toWait = 0;
Begin
frame;
gi_TimeFinished = -1;
toWait = get_timer() + milis;
Repeat
frame;
Until(get_timer() >= towait)
OnExit
gi_TimeFinished = 1;
End
Process WaitingVar()
Private
int toWait = 0;
int myTime = 0;
Begin
gi_TimeVarFinished = -1;
//write_var(0,40,20, 0, gi_TimeVar);
//write_var(0,20,40, 0, myTime);
//write_var(0,20,20, 0, fps);
Repeat
myTime = get_timer();
frame;
Until(myTime >= gi_TimeVar)
OnExit
gi_TimeVarFinished = 1;
End
Function WaitingUntil(int milis)
Begin
Waiting(milis);
Repeat
frame;
Until(gi_TimeFinished == 1)
gi_TimeFinished = -1;
End
Function WaitingUntilKey(int milis, int keyId)
Begin
Waiting(milis);
Repeat
frame;
Until(gi_TimeFinished == 1 || key(keyId))
gi_TimeFinished = -1;
End
/*Process Cronometro()
Private
int i = 0;
char val = "";
End
Begin
//PRIORITY = 1;
Loop
if(itoa(time()*1000)[5] != val)
val = itoa(time()*1000)[5];
gi_SECONDS = atoi(val);
end
frame;
End
End*/
//Establece la cantidad de ciclos que tiene que dar un bucle, para que se ejecute una instrucción.
//Parámetros:
//Segundo (float) - Tiempo en segundos.décimas (0.0)
/*Function int ObtenerCiclos(float segundo)
Private
int sec = 0;
int dec = 0;
int total = 0;
string strsec = "";
int i = 0;
byte beforePoint = false;
int lenght = 0;
End
Begin
lenght = len(ftoa(segundo));
for(i = 0; i < len(ftoa(segundo)); i++)
if(ftoa(segundo)[i] == ".") break; end
strsec += ftoa(segundo)[i];
end
sec = atoi(strsec);
strsec = "";
for(i = 0; i < len(ftoa(segundo)); i++)
if(ftoa(segundo)[i] == ".")
beforePoint = true;
continue;
end
if(beforePoint)
strsec += ftoa(segundo)[i];
break; //Fuerzo que se detenga porque a veces bennu me da un float con más decimales.
end
end
dec = atoi(strsec);
total = (60 * sec) + (60 * (dec * 10) / 100);
return total;
End*/
/*Function int ObtenerCiclos2(string segundos)
Private
int sec = 0;
int dec = 0;
float cen = 0.0;
int total = 0;
string strsec = "";
byte beforePoint = false;
int lenght = 0;
string str = "";
string newstr = "";
string a[4];
int n;
int i;
End
Begin
if(len(segundos) <= 0) return; end
lenght = len(segundos) - 1;
//NO debe estar eliminado, lo comenté por optimización de código.
//newstr = Remove(segundos, '.');
for(i=0; i<lenght; i++)
if(newstr[i] == "") continue; end
a[i] = newstr[i];
end
//2 = 0.0, 3 = 0.00, 4 = 00.00
switch(lenght)
case 2:
sec = atoi(a[0]);
dec = atoi(a[1]);
total = (60 * sec) + (60 * (dec * 10) / 100);
end
case 3:
sec = atoi(a[0]);
cen = ftoa("0." + a[1] + a[2]);
total = (60 * sec) + (60 * (cen * 100) / 100);
end
case 4:
sec = atoi(a[0] + a[1]);
cen = ftoa("0." + a[2] + a[3]);
say(ftoa(cen));
total = (60 * sec) + (60 * (cen * 100) / 100);
end
end
return total;
End*/
/*Process ObtenerFecha()
Private
int pi_Before = 0;
int pi_Now = 0;
int pi_Weeks = 0;
int pi_Days = 0;
int pi_Hours = 0;
int pi_Minutes = 0;
int pi_Seconds = 0;
int pi_MSeconds = 0;
int pi_diff = 0;
int i;
End
Begin
//$milliseconds = time()*1000 - $user_timestamp*1000;
pi_Before = time()*1000; //Tiempo anterior
for(i = 0; i < 100; i++) //5 Seg aprox
frame;
end
pi_Now = time()*1000;
pi_diff = pi_Now - pi_Before;
If(1 > pi_diff)
//
Else
pi_Weeks = pi_diff / 86400 / 7;
pi_Days = pi_diff / 86400 % 7;
pi_Hours = pi_diff / 3600 % 24;
pi_Minutes = pi_diff / 60 % 60;
pi_Seconds = pi_diff % 60;
pi_MSeconds = pi_diff;
say("El tiempo transcurrido es: Semanas = " + pi_Weeks + "; Dias = " + pi_Days + "; Horas = " + pi_Hours + "; Minutos = " + pi_Minutes + "; Segundos = " + pi_Seconds + "; MSeg = " + pi_MSeconds);
End
End*/