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
|
-
|
!
-
|
!
-
|
!
-
|
!
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
#define MEMBER 5 #define SQSIZE 10
#define SQRED 0 #define SQGREEN 1 #define SQYELLOW 2 #define SQPINK 3 #define SQBLUE 4 #define SQWHITE 5
screen 0,300,300,1
palette SQRED , 255 , 0 , 0
palette SQGREEN , 0 , 128 , 0
palette SQYELLOW , 255 , 192 , 0
palette SQPINK , 254 , 92 , 245
palette SQBLUE , 0 , 0 , 255
palette SQWHITE , 255 , 255 , 255 , 1
dim rngStep , MEMBER * SQSIZE rngPos = 0 , 40 , 30 , 20 , 10
gosub *drawSquare
repeat
await 1
stick key , 0b1001111 , 1
if key & 0b1001111 = 0 : continue
now = rngStep(rngPos(SQRED))
sqLeft = now & $FFFF
sqTop = now >> 16 & $FFFF
if key & 64 : speed=2 : else : speed=1
if key & 1{
if sqLeft-speed < 0 : sqLeft = 0 : else : sqLeft -= speed
}
if key & 2{
if sqTop-speed < 0 : sqTop = 0 : else : sqTop -= speed
}
if key & 4{
if sqLeft+SQSIZE+speed>ginfo(12):sqLeft=ginfo(12)-SQSIZE:else:sqLeft+=speed
}
if key & 8{
if sqTop+SQSIZE+speed>ginfo(13):sqTop=ginfo(13)-SQSIZE:else:sqTop+=speed
}
after = sqTop << 16 | sqLeft
if now ! after{
redraw 0
gosub *eraseSquare
repeat MEMBER
rngPos(cnt) = (rngPos(cnt)+1)\(MEMBER*SQSIZE)
loop
rngStep(rngPos(SQRED)) = after
gosub *drawSquare
redraw 1
}
loop
stop
*drawSquare
repeat MEMBER , 1
palcolor MEMBER-cnt
sqLeft = rngStep(rngPos(MEMBER-cnt)) & $FFFF sqTop = rngStep(rngPos(MEMBER-cnt)) >> 16 & $FFFF
boxf sqLeft , sqTop , sqLeft + SQSIZE , sqTop + SQSIZE
loop
return
*eraseSquare
palcolor SQWHITE
repeat MEMBER
sqLeft = rngStep(rngPos(cnt)) & $FFFF sqTop = rngStep(rngPos(cnt)) >> 16 & $FFFF
boxf sqLeft , sqTop , sqLeft + SQSIZE , sqTop + SQSIZE
loop
return
|