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
|
-
|
|
-
|
|
!
-
|
-
|
!
| #const global W1 100 #const global H1 100
#const global W2 70 #const global H2 50
#module
#defcfunc hit int x1, int y1, int x2, int y2
return (x1 < x2 + W2)&(y1 < y2 + H2)&(x2 < x1 + W1)&(y2 < y1 + H1)
#global
x1 = 1 : y1 = 1
x2 = 100 : y2 = 100
*main
gosub *move
gosub *draw
wait 1
goto *main
*move
stick key, 15 + 64
if (key & 64) {
x2 += ((key >> 2) & 1) - (key & 1)
y2 += ((key >> 3) & 1) - ((key >> 1) & 1)
} else {
x1 += ((key >> 2) & 1) - (key & 1)
y1 += ((key >> 3) & 1) - ((key >> 1) & 1)
}
return
*draw
redraw 0
color 255, 255, 255 : boxf
color 255
boxf x1, y1, x1 + W1 - 1, y1 + H1 - 1
color 0, 0, 255
boxf x2, y2, x2 + W2 - 1, y2 + H2 - 1
if(hit(x1, y1, x2, y2)){
title "衝突!"
} else {
title "..."
}
redraw 1
return
|