-
Notifications
You must be signed in to change notification settings - Fork 0
/
CBRICK.BAS
330 lines (316 loc) · 9.39 KB
/
CBRICK.BAS
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
SCREEN 12: CLS
RANDOMIZE TIMER
REM $DYNAMIC
DIM palet(500): DIM ball(100): DIM nulball(100)
DIM brick(300): DIM nul(300)
DIM nom$(10): DIM score(10)
DIM bonus(300)
'OPEN "joystick.dat" FOR RANDOM AS #5
'GET #5, 1, xjoy
'CLOSE #5
niveau = 1
OPEN "palet.spr" FOR INPUT AS #1
OPEN "ball.spr" FOR INPUT AS #2
OPEN "brick.spr" FOR INPUT AS #3
OPEN "bonus.spr" FOR INPUT AS #4
FOR x = 1 TO 99
FOR y = 1 TO 9
i = i + 1
INPUT #1, i, a
PSET (x + 50, y + 50), a
NEXT y
NEXT x
FOR x = 1 TO 9
FOR y = 1 TO 9
i = i + 1
INPUT #2, i, a
PSET (x + 10, y + 10), a
NEXT y
NEXT x
FOR x = 1 TO 29
FOR y = 1 TO 19
i = i + 1
INPUT #3, i, a
INPUT #4, i, B
PSET (x + 200, y + 50), a
PSET (x + 200, y + 100), B
NEXT y
NEXT x
CLOSE #1
CLOSE #2
CLOSE #3
CLOSE #4
LOCATE 15, 1
PRINT "'Entr‚e' pour jouer, 'e' pour ‚diter..."
SLEEP
GET (30, 45)-(170, 65), palet
GET (10, 10)-(20, 20), ball
GET (200, 50)-(230, 70), brick
GET (200, 100)-(230, 120), bonus
GET (300, 50)-(330, 70), nul
GET (300, 50)-(310, 60), nulball
CLS
DIM position(27, 2): DIM etat(27)
i = 1
FOR x = 124 TO 444 STEP 40
FOR y = 32 TO 84 STEP 26
PUT (x, y), brick
position(i, 1) = x
position(i, 2) = y
i = i + 1
NEXT y
NEXT x
FOR i = 1 TO 27
etat(i) = 1
NEXT i
nbbrick = 27
deb:
LINE (2, 0)-(615, 0), 1: LINE (615, 0)-(615, 460), 1
LINE (2, 460)-(2, 0), 1
xpalet = 220: ypalet = 450
m = -2: n = 2
vitesse = 2
t = TIMER
FOR i = 1 TO 1000
xball = xpalet + 60
yball = 439
PUT (xball, yball), ball, PSET
a$ = INKEY$
IF a$ <> "" THEN
IF a$ = "6" THEN xpalet = xpalet + 16
IF a$ = "4" THEN xpalet = xpalet - 16
IF a$ = CHR$(32) THEN EXIT FOR
END IF
' IF STICK(0) > xjoy + 2 THEN xpalet = xpalet + 16
' IF STICK(0) < xjoy - 2 THEN xpalet = xpalet - 16
' IF STRIG(0) = -1 THEN EXIT FOR
IF xpalet > 490 THEN xpalet = 490
IF xpalet < 5 THEN xpalet = 5
PUT (xpalet, ypalet), palet, PSET
PUT (xball, yball), nulball, PSET
NEXT i
DO
IF xpalet > 490 THEN xpalet = 490
IF xpalet < 5 THEN xpalet = 10
PUT (xpalet, ypalet), palet, PSET
k$ = INKEY$
IF k$ <> "" THEN
IF k$ = CHR$(27) THEN END
IF k$ = "e" OR k$ = "E" THEN GOTO brickedit
IF k$ = "l" THEN GOTO gagne
IF k$ = "6" THEN xpalet = xpalet + 26
IF k$ = "4" THEN xpalet = xpalet - 26
END IF
'IF STICK(0) > xjoy + 5 THEN xpalet = xpalet + 26
'IF STICK(0) < xjoy - 5 THEN xpalet = xpalet - 26
IF yball < 10 THEN m = vitesse
IF xball <= 16 THEN n = RND * vitesse
IF xball > 595 THEN n = -RND * vitesse
PUT (xball, yball), nulball, PSET
xball = xball + n
yball = yball + m
IF yball > 460 THEN GOTO perdu
PUT (xball, yball), ball, PSET
IF xball > xpalet AND xball < xpalet + 110 AND yball >= 440 THEN
m = -m: pt = pt + 500
SOUND 50, .5
END IF
test = 0
FOR i = 1 TO nbbrick
xbrick = position(i, 1): ybrick = position(i, 2)
IF xball > xbrick - 8 AND xball < xbrick + 30 AND yball > ybrick - 10 AND yball < ybrick + 20 AND etat(i) = 1 THEN
PUT (xbrick, ybrick), nul, PSET
m = -m: pt = pt + 1000
etat(i) = etat(i) - 1
SOUND RND * 700 + 50, .5
END IF
IF (xball > xbrick - 10 AND xball < xbrick - 5 AND yball > ybrick + 1 AND yball < ybrick + 17 OR xball > xbrick + 28 AND xball < xbrick + 32 AND yball > ybrick + 1 AND yball < ybrick + 17) AND etat(i) = 1 THEN
PUT (xbrick, ybrick), nul, PSET
n = -n: pt = pt + 1000
etat(i) = etat(i) - 1
SOUND RND * 700 + 50, .5
END IF
IF etat(i) = 0 THEN test = test + 1
IF test = nbbrick THEN GOTO gagne
NEXT i
LOCATE 1, 1: PRINT pt
IF TIMER - t >= 5 THEN
jeremy = INT(RND * 5)
IF jeremy = 3 THEN
PUT (xbonus, ybonus), nul, PSET
xbonus = INT(RND * 600): ybonus = 450
PUT (xbonus, ybonus), bonus, PSET
END IF
FOR i = 1 TO nbbrick
IF etat(i) > 0 THEN PUT (position(i, 1), position(i, 2)), brick, PSET
t = TIMER
NEXT i
END IF
IF jeremy = 3 AND TIMER - t > 2 THEN jeremy = 0: PUT (xbonus, ybonus), nul, PSET
IF xpalet < xbonus + 30 AND xpalet > xbonus - 100 AND jeremy = 3 THEN
PUT (xbonus, ybonus), nul, PSET
jeremy = 0
pt = pt + 2000
END IF
vitesse = vitesse + .0005
LOOP
perdu:
PRINT "PERDU !!!"
OPEN "cscore.dat" FOR RANDOM AS #1
INPUT "Entrez votre nom : "; name$
CLS
FOR i = 1 TO 10
GET #1, i, nom$
GET #1, i + 10, score
score(i) = score
nom$(i) = nom$
NEXT i
FOR i = 1 TO 10
IF pt > score(i) THEN
score(i) = pt
nom$(i) = name$
EXIT FOR
END IF
NEXT i
FOR i = 1 TO 10
PUT #1, i, nom$(i)
PUT #1, i + 10, score(i)
NEXT i
FOR i = 1 TO 10
GET #1, i, nom$
GET #1, i + 10, score
LOCATE i, 1: PRINT nom$
LOCATE i, 20: PRINT score
NEXT i
CLOSE #1
END
gagne:
PRINT "GAGNE !!!"
CLS
niveau = niveau + 1
PRINT "Niveau : "; niveau
IF niveau > 10 THEN GOTO suit
SLEEP
IF niveau = 2 THEN
OPEN "niveau02.dat" FOR RANDOM AS #1
nbbrick = 25
END IF
IF niveau = 3 THEN
OPEN "niveau03.dat" FOR RANDOM AS #1
nbbrick = 32
END IF
IF niveau = 4 THEN
OPEN "niveau04.dat" FOR RANDOM AS #1
nbbrick = 25
END IF
IF niveau = 5 THEN
OPEN "niveau05.dat" FOR RANDOM AS #1
nbbrick = 24
END IF
IF niveau = 6 THEN
OPEN "niveau06.dat" FOR RANDOM AS #1
nbbrick = 40
END IF
IF niveau = 7 THEN
OPEN "niveau07.dat" FOR RANDOM AS #1
nbbrick = 28
END IF
IF niveau = 8 THEN
OPEN "niveau08.dat" FOR RANDOM AS #1
nbbrick = 18
END IF
IF niveau = 9 THEN
OPEN "niveau09.dat" FOR RANDOM AS #1
nbbrick = 34
END IF
IF niveau = 10 THEN
OPEN "niveau10.dat" FOR RANDOM AS #1
nbbrick = 50
END IF
REDIM position(nbbrick, 2)
REDIM etat(nbbrick)
FOR i = 1 TO nbbrick
GET #1, i * 2 - 1, position(i, 1)
GET #1, i * 2, position(i, 2)
PUT (position(i, 1), position(i, 2)), brick, PSET
etat(i) = 1
NEXT i
CLOSE #1
GOTO deb
suit:
OPEN "cscore.dat" FOR RANDOM AS #1
INPUT "Entrez votre nom : "; name$
FOR i = 1 TO 10
GET #1, i, nom$
GET #1, i + 10, score
score(i) = score
nom$(i) = nom$
NEXT i
FOR i = 1 TO 10
IF pt > score(i) THEN
score(i) = pt
nom$(i) = name$
EXIT FOR
END IF
NEXT i
FOR i = 1 TO 10
PUT #1, i, nom$(i)
PUT #1, i + 10, score(i)
NEXT i
FOR i = 1 TO 10
GET #1, i, nom$
GET #1, i + 10, score
LOCATE i, 1: PRINT nom$
LOCATE i, 20: PRINT score
NEXT i
CLOSE #1
END
brickedit:
INPUT "Nombre de briques maxi : "; nbbrick
CLS
nb = 1
DIM brickpos(nbbrick, 2)
DO
FOR i = 1 TO nbbrick
PUT (xbrick, ybrick), brick, PSET
k$ = INKEY$
IF k$ = "6" THEN
PUT (xbrick, ybrick), nul, PSET
xbrick = xbrick + 36
END IF
IF k$ = "4" THEN
PUT (xbrick, ybrick), nul, PSET
xbrick = xbrick - 36
END IF
IF k$ = "5" THEN
PUT (xbrick, ybrick), nul, PSET
ybrick = ybrick + 25
END IF
IF k$ = "8" THEN
PUT (xbrick, ybrick), nul, PSET
ybrick = ybrick - 25
END IF
IF k$ = CHR$(32) THEN
brickpos(nb, 1) = xbrick
brickpos(nb, 2) = ybrick
nb = nb + 1
IF nb > nbbrick + 1 THEN PRINT "Trop de briques !!!": END
END IF
IF k$ = "s" THEN GOTO savelevel
PUT (brickpos(i, 1), brickpos(i, 2)), brick, PSET
NEXT i
LOOP
savelevel:
INPUT "Nom du niveau (*.dat) : "; nomniveau$
OPEN nomniveau$ FOR RANDOM AS #1
FOR i = 1 TO nbbrick
PUT #1, i * 2 - 1, brickpos(i, 1)
PUT #1, i * 2, brickpos(i, 2)
NEXT i
CLS
FOR i = 1 TO nbbrick
GET #1, i * 2 - 1, brickpos(i, 1)
GET #1, i * 2, brickpos(i, 2)
PUT (brickpos(i, 1), brickpos(i, 2)), brick, PSET
NEXT i
CLOSE #1