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
|
-
|
-
|
!
-
|
!
!
-
|
-
|
!
-
|
!
!
-
|
-
|
!
-
|
!
!
-
|
-
|
!
-
|
!
!
| #define SQUARE 10
screen 0 , 640 , 480 , 1
palette 0 , 0 , 0 , 0
palette 1 , 255 , 0 , 0
palette 2 , 255 , 255 , 255 , 1
nx = (640-SQUARE) / 2
ny = (480-SQUARE) / 2
px = nx
py = ny
nxf = double(nx)
nyf = double(ny)
pxf = double(px)
pyf = double(py)
speed = 1.0
gosub *draw
repeat
wait 1 : stick key , 1+2+4+8
if key & 1 {
nx = limit(nx-speed , 0 , 640-SQUARE)
if (key & 2) | (key & 8){
nxf = limitf(nxf-speed/sqrt(2) , 0 , 640-SQUARE)
}
else{
nxf = limitf(nxf-speed , 0 , 640-SQUARE)
}
}
if key & 2 {
ny = limit(ny-speed , 0 , 480-SQUARE)
if (key & 1) | (key & 4){
nyf = limitf(nyf-speed/sqrt(2) , 0 , 480-SQUARE)
}
else{
nyf = limitf(nyf-speed , 0 , 480-SQUARE)
}
}
if key & 4 {
nx = limit(nx+speed , 0 , 640-SQUARE)
if (key & 2) | (key & 8){
nxf = limitf(nxf+speed/sqrt(2) , 0 , 640-SQUARE)
}
else{
nxf = limitf(nxf+speed , 0 , 640-SQUARE)
}
}
if key & 8 {
ny = limit(ny+speed , 0 , 480-SQUARE)
if (key & 1) | (key & 4){
nyf = limitf(nyf+speed/sqrt(2) , 0 , 480-SQUARE)
}
else{
nyf = limitf(nyf+speed , 0 , 480-SQUARE)
}
}
if (nx=px) & (ny=py) & (nxf=pxf) & (nyf=pyf) : continue
gosub *draw
px = nx
py = ny
pxf = nxf
pyf = nyf
loop
stop
*draw
palcolor 2
boxf px,py,px+SQUARE,py+SQUARE
boxf pxf,pyf,pxf+SQUARE,pyf+SQUARE
palcolor 0
boxf nx,ny,nx+SQUARE,ny+SQUARE
palcolor 1
boxf nxf,nyf,nxf+SQUARE,nyf+SQUARE
return
|