-
Notifications
You must be signed in to change notification settings - Fork 1
/
Blocks game.bb
358 lines (310 loc) · 5.54 KB
/
Blocks game.bb
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
;
; Simple Blocks game by Pakz (Rudy van Etten)
;
Graphics 640,480,32,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Dim block(21,4,4)
Dim map(32,32)
makeblocks()
Global bx = 5 ; block x
Global by = 0 ; block y
Global cb = Rand(1,21); current block
timer = CreateTimer(60)
While KeyDown(1) = False
WaitTimer timer
Cls
drawmap
Color 255,255,255
Line 0,16*3,14*16,16*3 ; End line
Text GraphicsWidth()/2,15,"Space = rotate block - Cur left = move left - Cur right = move right",1,1
Text GraphicsWidth()/2,25,"Cur down = Drop Block",1,1
; Move left and right
If KeyHit(203) And bx => 0 Then bx = bx - 1
If KeyHit(205)
cont = True
For y1 = 1 To 4
For x1 = 1 To 4
If block(cb,x1,y1) = 1
If bx+x1 > 12 Then cont = False
End If
Next
Next
If cont = True Then bx=bx+1
End If
; Change block
If KeyHit(57)
Select cb
Case 1
Case 2 : If mapob(3) = False Then cb = 3
Case 3 : If mapob(2) = False Then cb = 2
Case 4 : If mapob(5) = False Then cb = 5
Case 5 : If mapob(6) = False Then cb = 6
Case 6 : If mapob(7) = False Then cb = 7
Case 7 : If mapob(4) = False Then cb = 4
Case 8 : If mapob(9) = False Then cb = 9
Case 9 : If mapob(10) = False Then cb = 10
Case 10: If mapob(11) = False Then cb = 11
Case 11: If mapob(8) = False Then cb = 8
Case 12: If mapob(13) = False Then cb = 13
Case 13: If mapob(12) = False Then cb = 12
Case 14: If mapob(15) = False Then cb = 15
Case 15: If mapob(16) = False Then cb = 16
Case 16: If mapob(17) = False Then cb = 17
Case 17: If mapob(14) = False Then cb = 14
Case 18: If mapob(19) = False Then cb = 19
Case 19: If mapob(18) = False Then cb = 18
Case 20: If mapob(21) = False Then cb = 21
Case 21: If mapob(20) = False Then cb = 20
End Select
End If
; See if the block is not right outside the map
For y1=1 To 4
For x1=1 To 4
If block(cb,x1,y1) = 1
If bx + x1 > 13 Then bx=bx-1
End If
Next
Next
; Draw the block
For y1=1 To 4
For x1=1 To 4
If block(cb,x1,y1) = 1
Rect bx*16+x1*16,by*16+y1*16,16,16,True
End If
Next
Next
; Fall speed
t=t+1
If t > 20
by=by+1
t = 0
End If
; Fall collision
For y2=1 To 4
For x2=1 To 4
If block(cb,x2,y2) = 1
If y2+by > 21 Then
by=by-1
fillblockinmap()
by = 0 : bx = 5 : cb = Rand(1,21)
End If
End If
done=False
If done = False
If block(cb,x2,y2) = 1
If map(bx+x2,by+y2) = 1
If by <2 Then End
by=by-1
fillblockinmap
by = 0 : bx = 5: cb= Rand(1,21)
done=True
End If
End If
End If
Next
Next
If MouseDown(1) = True
map(MouseX()/16,MouseY()/16) = 1
End If
; Line fill remove
For y1=2 To 22
fl = True
For x1=0 To 13
If map(x1,y1) = 0 Then fl=False
Next
If fl = True
For x2 = 0 To 13
map(x2,y1) = 0
Next
For y2=y1-1 To 2 Step -1
For x2=0 To 14
map(x2,y2+1) = map(x2,y2)
Next
Next
End If
Next
; Move down all the way (cursor down)
If KeyHit(208)
exitloop = False
While exitloop = False
by = by + 1
For y1=1 To 4
For x1=1 To 4
If exitloop = False
If block(cb,x1,y1) = 1
If map(bx+x1,by+y1) = 1
by=by-1
fillblockinmap()
by = 0 : bx = 5: cb = Rand(1,21)
exitloop = True
End If
If by+y1>20 Then
fillblockinmap()
by = 0 : bx = 5: cb = Rand(1,21)
exitloop = True
End If
End If
End If
Next
Next
Wend
End If
If KeyDown(2) = True Then
Cls
Color 255,255,255
cnt = 1
For y=0 To 4
For x=0 To 5
If cnt<22
Dblock(cnt,x*96,y*96)
Text x*96,y*96,cnt
End If
cnt=cnt+1
Next
Next
End If
Flip
Wend
End
; Check if block(nb) is ontop of block
Function mapob(nb)
For y=1 To 4
For x=1 To 4
If block(nb,x,y) = 1
If map(bx+x-1,by+y-1) = 1 Then Return True
End If
Next
Next
Return False
End Function
Function fillblockinmap()
For y=1 To 4
For x=1 To 4
If block(cb,x,y) = 1
map(bx+x,by+y) = 1
End If
Next
Next
End Function
Function drawmap()
Color 255,255,255
Line 0,0,0,22*16
Line 0,22*16,14*16,22*16
Line 14*16,0,14*16,22*16
For y=0 To 22
For x=0 To 14
If map(x,y) = 1 Then
Rect x*16,y*16,16,16,True
End If
Next
Next
End Function
Function dblock(b,x,y)
Color 255,255,255
For y1=1 To 4
For x1=1 To 4
If block(b,x1,y1) = 1
Rect x1*16+x,y1*16+y,16,16
End If
Next
Next
End Function
Function makeblocks()
Restore blockdata
For i=1 To 21
For y=1 To 4
For x=1 To 4
Read a
If a = 1
block(i,x,y) = 1
End If
Next
Next
Next
End Function
.blockdata
Data 1,1,0,0
Data 1,1,0,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,0,0,0
Data 1,0,0,0
Data 1,0,0,0
Data 1,0,0,0
Data 1,1,1,1
Data 0,0,0,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,0,0,0
Data 1,0,0,0
Data 1,1,0,0
Data 0,0,0,0
Data 1,1,1,0
Data 1,0,0,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,1,0,0
Data 0,1,0,0
Data 0,1,0,0
Data 0,0,0,0
Data 0,0,1,0
Data 1,1,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 0,1,0,0
Data 0,1,0,0
Data 1,1,0,0
Data 0,0,0,0
Data 1,0,0,0
Data 1,1,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,1,0,0
Data 1,0,0,0
Data 1,0,0,0
Data 0,0,0,0
Data 1,1,1,0
Data 0,0,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,1,0,0
Data 0,1,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 0,1,0,0
Data 1,1,0,0
Data 1,0,0,0
Data 0,0,0,0
Data 0,1,0,0
Data 1,1,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,0,0,0
Data 1,1,0,0
Data 1,0,0,0
Data 0,0,0,0
Data 1,1,1,0
Data 0,1,0,0
Data 0,0,0,0
Data 0,0,0,0
Data 0,1,0,0
Data 1,1,0,0
Data 0,1,0,0
Data 0,0,0,0
Data 0,1,1,0
Data 1,1,0,0
Data 0,0,0,0
Data 0,0,0,0
Data 1,0,0,0
Data 1,1,0,0
Data 0,1,0,0
Data 0,0,0,0
Data 1,1,0,0
Data 0,1,1,0
Data 0,0,0,0
Data 0,0,0,0
Data 0,1,0,0
Data 1,1,0,0
Data 1,0,0,0
Data 0,0,0,0