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
|
-
|
|
|
|
|
|
|
!
-
|
|
|
|
|
|
|
!
-
|
-
|
!
-
|
-
|
!
|
#enum global TYPE_UNKNOWN = 0
#enum global TYPE_FADEIN
#enum global TYPE_FADEOUT
#define global WND_MAIN 0
#define global WND_BG 2
#define global WND_TEMP 3
#define WND_W 640
#define WND_H 480
#module "effect_fadein" type, offset, count, col
#define global effect_add_fadein(%1,%2,%3) newmod %1,effect_fadein,%2,%3
#modinit int _offset, int _max
type = TYPE_FADEIN
offset = _max
count = _max + _offset
col = ginfo_r, ginfo_g, ginfo_b
return
#modfunc effect_fadein_do
if count < 0 : return
if count <= offset {
sel_wnd = ginfo_sel
gsel WND_TEMP
color col(0), col(1), col(2)
boxf
gsel sel_wnd
gmode 3, 0, 0, 255 * count / offset
pos 0, 0 : gcopy WND_TEMP, 0, 0, ginfo_winx, ginfo_winy
}
count--
return
#modfunc effect_fadein_is_finish
if count < 0 : return 1
return 0
#global
#module "effect_fadeout" type, offset, count, col
#define global effect_add_fadeout(%1,%2,%3) newmod %1,effect_fadeout,%2,%3
#modinit int _offset, int _max
type = TYPE_FADEOUT
offset = _max
count = _max + _offset
col = ginfo_r, ginfo_g, ginfo_b
return
#modfunc effect_fadeout_do
if count < 0 : return
if count <= offset {
sel_wnd = ginfo_sel
gsel WND_TEMP
color col(0), col(1), col(2)
boxf
gsel sel_wnd
gmode 3, 0, 0, 255 * (offset - count - 1) / offset
pos 0, 0 : gcopy WND_TEMP, 0, 0, ginfo_winx, ginfo_winy
}
count--
return
#modfunc effect_fadeout_is_finish
if count < 0 : return 1
return 0
#global
#module "effect" type
#modinit
type = TYPE_UNKNOWN
return
#modfunc effect_get_type@effect
return type
#modfunc effect_is_finish
if type = TYPE_FADEIN {
effect_fadein_is_finish thismod
} else : if type = TYPE_FADEOUT {
effect_fadeout_is_finish thismod
}
return
#deffunc effect_do array v
foreach v
effect_get_type v.cnt
if stat = TYPE_FADEIN {
effect_fadein_do v.cnt
} else : if stat = TYPE_FADEOUT {
effect_fadeout_do v.cnt
}
loop
return
#deffunc effect_calc_count array v
n = 0
foreach v
effect_is_finish v.cnt
if stat : delmod v.cnt : else : n++
loop
return n
#global
buffer WND_TEMP, WND_W, WND_H
buffer WND_BG, WND_W, WND_H
repeat 10000
color rnd(256), rnd(256), rnd(256)
n = rnd(ginfo_winx + 100) - 50, rnd(ginfo_winy + 100) - 50, rnd(100), rnd(100), rnd(2)
circle n(0), n(1), n(0) + n(2), n(1) + n(3), n(4)
loop
gsel WND_MAIN, 0
width WND_W, WND_H
title "start"
effect_add_fadein v, 0, 30
effect_add_fadeout v, 15, 30
effect_add_fadein v, 45, 30
repeat
await 30
redraw 0
gmode 0
pos 0, 0 : gcopy WND_BG, 0, 0, 640, 480
effect_do v
color 255, 0, 0
pos 0, 0 : mes "frame " + strf("%3d", cnt)
redraw 1
effect_calc_count v
if stat < 1 : break
loop
title "finish"
|