forked from ceu-lang/ceu-sdl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimul.ceu
112 lines (102 loc) · 2.77 KB
/
simul.ceu
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
/*{-{*/
// TODO
// - test scrolling
native do
#define SDL_SIMUL
end
native _rand(), _srand(), _time();
_srand(_time(null));
var int n1=0, n2=0;
par/or do
/*
*/
await 30min;
_printf("%d %d\n", n1, n2);
await 30min;
_printf("%d %d\n", n1, n2);
await 30min;
_printf("%d %d\n", n1, n2);
await 30min;
_printf("%d %d\n", n1, n2);
await 30min;
_printf("%d %d\n", n1, n2);
await 30min;
_printf("%d %d\n", n1, n2);
with
loop do
n1 = n1 + 1;
async do
emit SDL_REDRAW;
end
await 2min;
end
with
loop do
n2 = n2 + 1;
var int win_w = win_rect.w;
var int win_h = win_rect.h;
async (ren, win_w, win_h) do
var int dt = 0;
// mouse: one click (0->w, 0->h) every (0->500)ms
var _SDL_MouseButtonEvent e_mse;
e_mse.type = _SDL_MOUSEBUTTONDOWN;
e_mse.x = _rand() % win_w;
e_mse.y = _rand() % win_h;
emit SDL_MOUSEBUTTONDOWN(&e_mse);
do
var int v = _rand() % 500;
emit(v)ms;
dt = dt + v;
end
/*
*/
// input
// 32=' ' => 126='~'
var char[2] str;
str[0] = ' ';
str[1] = '\0';
str[0] = _rand() % (126-32) + 32;
var _SDL_TextInputEvent e_inp;
e_inp.type = _SDL_TEXTINPUT;
_strcpy(e_inp.text, str);
emit SDL_TEXTINPUT(&e_inp);
do
var int v = _rand() % 500;
emit(v)ms;
dt = dt + v;
end
// keys
var _SDL_KeyboardEvent e_key;
e_key.type = _SDL_KEYDOWN;
var int pct = _rand() % 100;
if pct > 50 then
if pct < 95 then
e_key.keysym.sym = _SDLK_BACKSPACE;
else
e_key.keysym.sym = _SDLK_RETURN;
end
loop i, 10 do
emit SDL_KEYDOWN(&e_key);
end
do
var int v = _rand() % 500;
emit(v)ms;
dt = dt + v;
end
end
/*
emit SDL_REDRAW;
_SDL_SetRenderDrawColor(ren, 0xFF,0x00,0xFF, 0);
var _SDL_Rect r;
r.x = e_mse.x-7;
r.y = e_mse.y-7;
r.w = 14;
r.h = 14;
_SDL_RenderFillRect(ren, &r);
_SDL_RenderPresent(ren);
_SDL_Delay(dt);
*/
end
end
end
/*}-}*/ dnl