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
|
-
|
|
!
| #const BODYSIZE 16 #const WAITTIME 16 #const WINX 300 #const WINY 300 #const MAPX 480 #const MAPY 480 #const TURF 32
#enum MAINSCREEN = 0 #enum MAPBUFFER
randomize
cx = 0 : cy = 0 originX = 0 : originY = 0
buffer MAPBUFFER, MAPX, MAPY
repeat MAPY / TURF
up_cnt = cnt
tmp = cnt\2 * TURF / 2
repeat MAPX / TURF
pos cnt*TURF + tmp, up_cnt*TURF
mes "\""
loop
loop
font "Webdings", 32
pos 270, 100 : mes "H"
pos 80, 300 : mes "G"
pos 370, 320 : mes "P"
screen MAINSCREEN, WINX, WINY
gmode 0, WINX, WINY
gosub *draw
*main
await WAITTIME
stick key , 0b1001111 , 1
if key & 0b1001111 == 0 {
goto *main
}
redraw 0
gosub *fixSpeed gosub *move gosub *draw redraw 1
goto *main
*fixSpeed
speed = (key>>6 & 1) + 1
vx = (key>>2&1) - (key&1)
vy = (key>>3&1) - (key>>1&1)
return
*move
cx += vx * speed
cy += vy * speed
cx = limit(cx, 0, MAPX - BODYSIZE)
cy = limit(cy, 0, MAPY - BODYSIZE)
originX = limit(cx - WINX/2, 0, MAPX - WINX)
originY = limit(cy - WINY/2, 0, MAPY - WINY)
return
*draw
pos 0, 0 : gcopy MAPBUFFER, originX, originY
color 255
x = cx - originX
y = cy - originY
boxf x, y, x + BODYSIZE, y + BODYSIZE
return
|