-
Notifications
You must be signed in to change notification settings - Fork 0
/
BATTLERM.BAS
340 lines (285 loc) · 9.82 KB
/
BATTLERM.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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
SCREEN 12: CLS
RANDOMIZE TIMER
DIM troufion(52): DIM tank(166)
DIM nul52(52): DIM nulTank(166)
DIM Atom(52)
DIM batPrinc(344): DIM usine(344): DIM camp(344): DIM port(344)
DIM nulBatiment(344)
DIM grilleEnn(27, 19) 'une case a la valeur 0 si elle est vide,
'1 si elle contient un troufion, etc.
DIM grilleJoueur(27, 19)
REM DIM dejaJouee(27, 19) 'une case prend la valeur 1 si elle a deja ete
'jouee
OPEN "troufion.spr" FOR INPUT AS #1
FOR x% = 1 TO 15
FOR y% = 1 TO 15
i = i + 1
INPUT #1, i, a
PSET (x%, y%), a
NEXT y%
NEXT x%
CLOSE #1
OPEN "atom.spr" FOR INPUT AS #1
FOR x% = 1 TO 15
FOR y% = 1 TO 15
i = i + 1
INPUT #1, i, a
PSET (x% + 20, y%), a
NEXT y%
NEXT x%
CLOSE #1
GET (0, 0)-(16, 16), troufion
GET (20, 0)-(36, 16), Atom
GET (50, 50)-(66, 66), nul52
INPUT "Nombre de troufions par equipe ? ", nbTrouf
numCol = 1
troufionsEnn = nbTrouf
troufionsJoueur = nbTrouf
FOR i% = 1 TO nbTrouf
ligne% = INT(RND * 27)
colonne% = INT(RND * 19)
IF grilleEnn(ligne%, colonne%) = 0 THEN
grilleEnn(ligne%, colonne%) = 1
ELSE
i% = i% - 1
END IF
NEXT i%
FOR i% = 1 TO 1
ligne% = INT(RND * 27)
colonne% = INT(RND * 19)
IF grilleEnn(ligne%, colonne%) = 0 THEN
grilleEnn(ligne%, colonne%) = 2
ELSE
i% = i% - 1
END IF
NEXT i%
CLS
LINE (0, 0)-(639, 448), 7, B
LINE (320, 0)-(320, 448), 7
lettre% = 41
FOR i% = 41 TO 78 STEP 2
LOCATE 28, i%
PRINT CHR$(lettre% + 24)
lettre% = lettre% + 1
NEXT i%
FOR i% = 1 TO 9
LOCATE i%, 78
PRINT i%
NEXT i%
FOR i% = 10 TO 27
LOCATE i%, 77
PRINT i%
NEXT i%
FOR i% = 0 TO 448 STEP 16
FOR j% = 320 TO 639 STEP 16
LINE (320, i%)-(639, i%), 7
LINE (j%, 0)-(j%, 448), 7
NEXT j%
NEXT i%
LOCATE 28, 2: PRINT "Positionnez votre bombe atomique "
xAtom = 1: yAtom = 1
nbAtom% = 1
AtomJoueur% = nbAtom%
atomEnn% = nbAtom%
PUT (xAtom, yAtom), Atom, PSET
WHILE nbAtom% > 0
k$ = INKEY$
IF k$ <> "" THEN
SELECT CASE k$
CASE "6"
IF grilleJoueur(yAtom / 16, xAtom / 16) = 0 THEN PUT (xAtom, yAtom), nul52, PSET
IF xAtom < 288 THEN xAtom = xAtom + 16
PUT (xAtom, yAtom), Atom, PSET
CASE "4"
IF grilleJoueur(yAtom / 16, xAtom / 16) = 0 THEN PUT (xAtom, yAtom), nul52, PSET
IF xAtom > 1 THEN xAtom = xAtom - 16
PUT (xAtom, yAtom), Atom, PSET
CASE "8"
IF grilleJoueur(yAtom / 16, xAtom / 16) = 0 THEN PUT (xAtom, yAtom), nul52, PSET
IF yAtom > 1 THEN yAtom = yAtom - 16
PUT (xAtom, yAtom), Atom, PSET
CASE "5"
IF grilleJoueur(yAtom / 16, xAtom / 16) = 0 THEN PUT (xAtom, yAtom), nul52, PSET
IF yAtom < 416 THEN yAtom = yAtom + 16
PUT (xAtom, yAtom), Atom, PSET
CASE CHR$(32)
grilleJoueur(yAtom / 16, xAtom / 16) = 2
nbAtom% = nbAtom% - 1
END SELECT
END IF
WEND
LOCATE 28, 2: PRINT "Positionnez vos troufions "
IF xAtom = 1 AND yAtom = 1 THEN
xTrouf = 17: yTrouf = 1
ELSE
xTrouf = 1: yTrouf = 1
END IF
PUT (xTrouf, yTrouf), troufion, PSET
WHILE nbTrouf > 0
k$ = INKEY$
IF k$ <> "" THEN
SELECT CASE k$
CASE "6"
IF grilleJoueur(yTrouf / 16, xTrouf / 16) = 0 THEN PUT (xTrouf, yTrouf), nul52, PSET
FOR i% = (xTrouf / 16 + 1) TO 18
IF grilleJoueur(yTrouf / 16, i%) = 0 THEN
xTrouf = i% * 16 + 1
EXIT FOR
END IF
NEXT i%
PUT (xTrouf, yTrouf), troufion, PSET
CASE "4"
IF grilleJoueur(yTrouf / 16, xTrouf / 16) = 0 THEN PUT (xTrouf, yTrouf), nul52, PSET
FOR i% = (xTrouf / 16 - 1) TO 0 STEP -1
IF grilleJoueur(yTrouf / 16, i%) = 0 THEN
xTrouf = i% * 16 + 1
EXIT FOR
END IF
NEXT i%
PUT (xTrouf, yTrouf), troufion, PSET
CASE "8"
IF grilleJoueur(yTrouf / 16, xTrouf / 16) = 0 THEN PUT (xTrouf, yTrouf), nul52, PSET
FOR i% = (yTrouf / 16 - 1) TO 0 STEP -1
IF grilleJoueur(i%, xTrouf / 16) = 0 THEN
yTrouf = i% * 16 + 1
EXIT FOR
END IF
NEXT i%
PUT (xTrouf, yTrouf), troufion, PSET
CASE "5"
IF grilleJoueur(yTrouf / 16, xTrouf / 16) = 0 THEN PUT (xTrouf, yTrouf), nul52, PSET
FOR i% = (yTrouf / 16 + 1) TO 26
IF grilleJoueur(i%, xTrouf / 16) = 0 THEN
yTrouf = i% * 16 + 1
EXIT FOR
END IF
NEXT i%
PUT (xTrouf, yTrouf), troufion, PSET
CASE CHR$(32)
grilleJoueur(yTrouf / 16, xTrouf / 16) = 1
nbTrouf = nbTrouf - 1
END SELECT
END IF
WEND
choixArme:
LOCATE 28, 2: PRINT SPC(39);
LOCATE 28, 2: INPUT "Choix de l'arme : ", arme$
SELECT CASE arme$
CASE "1":
IF troufionsJoueur <= 0 THEN GOTO choixArme
CASE "2":
IF AtomJoueur% <= 0 THEN GOTO choixArme
CASE ELSE:
GOTO choixArme
END SELECT
k$ = ""
partieA$ = ""
partieB$ = ""
DO UNTIL k$ <> "" AND k$ <> CHR$(32) AND k$ <> "4" AND k$ <> "5" AND k$ <> "6" AND k$ <> "8"
k$ = INKEY$
LOOP
l = ASC(UCASE$(k$)) - 65 'colonne ou l'on joue
DO UNTIL partieA$ <> ""
partieA$ = INKEY$
LOOP
DO UNTIL partieB$ <> ""
partieB$ = INKEY$
LOOP
IF partieA$ = "0" THEN
k = VAL(RIGHT$(partieB$, 1)) 'ligne ou l'on joue
ELSE
nb$ = partieA$ + partieB$
k = VAL(nb$)
END IF
IF l > 19 OR k > 27 OR l < 0 OR k < 0 THEN
LOCATE 28, 2
PRINT "Bad entry, reenter. Press space... "
SLEEP
GOTO choixArme
END IF
SELECT CASE arme$
CASE "1":
IF grilleEnn(k, l) = 1 THEN
IF POINT(321 + l * 16, k * 16 - 1) = 0 THEN PAINT (321 + l * 16, k * 16 - 1), 2, 7
grilleEnn(k, l) = 0
troufionsEnn = troufionsEnn - 1
LOCATE 28, 2: PRINT "Il reste"; troufionsEnn; "troufions ennemis "
SLEEP
GOTO choixArme
ELSE
IF POINT(321 + l * 16, k * 16 - 1) = 0 THEN PAINT (321 + l * 16, k * 16 - 1), 4, 7
END IF
IF troufionsEnn <= 0 THEN PRINT "Gagne !!!": END
CASE "2":
FOR i% = k - 2 TO k + 2
FOR j% = l - 2 TO l + 2
IF grilleEnn(i%, j%) = 1 THEN
IF POINT(321 + j% * 16, i% * 16 - 1) = 0 THEN PAINT (321 + j% * 16, i% * 16 - 1), 2, 7
grilleEnn(i%, j%) = 0
troufionsEnn = troufionsEnn - 1
ELSE
IF POINT(321 + j% * 16, i% * 16 - 1) = 0 THEN PAINT (321 + j% * 16, i% * 16 - 1), 7, 7
END IF
NEXT j%
NEXT i%
LOCATE 28, 2: PRINT "Il reste"; troufionsEnn; "troufions ennemis "
AtomJoueur% = AtomJoueur% - 1
grilleJoueur(k, l) = -1
CIRCLE (xAtom + 8, yAtom + 8), 8, 7
PAINT (xAtom + 8, yAtom + 8), 7, 7
SLEEP
END SELECT
ChoixArmePC:
armePC% = 2
IF armePC% = 2 AND atomEnn% <= 0 THEN GOTO ChoixArmePC
pcRejoue:
SELECT CASE armePC%
CASE 2
i% = INT(RND * 27): j% = INT(RND * 19)
IF grilleJoueur(i%, j%) = -1 THEN
GOTO pcRejoue
ELSE
FOR ligne% = i% - 2 TO i% + 2
FOR colonne% = j% - 2 TO j% + 2
IF ligne% >= 0 AND colonne% >= 0 AND ligne% <= 27 AND colonne% <= 19 THEN
IF grilleJoueur(ligne%, colonne%) = 1 THEN
CIRCLE (colonne% * 16 + 8, ligne% * 16 + 8), 8, 4
PAINT (colonne% * 16 + 8, ligne% * 16 + 8), 4, 4
grilleJoueur(ligne%, colonne%) = -1
troufionsJoueur = troufionsJoueur - 1
grilleJoueur(ligne%, colonne%) = -1
ELSE
CIRCLE (colonne% * 16 + 8, ligne% * 16 + 8), 8, 7
PAINT (colonne% * 16 + 8, ligne% * 16 + 8), 7, 7
grilleJoueur(ligne%, colonne%) = -1
END IF
END IF
NEXT colonne%
NEXT ligne%
END IF
LOCATE 28, 2: PRINT "Il vous reste "; troufionsJoueur; "troufions "
SLEEP
GOTO choixArme
CASE ELSE
i% = INT(RND * 27): j% = INT(RND * 19)
IF grilleJoueur(i%, j%) = -1 THEN
GOTO pcRejoue
ELSE
IF grilleJoueur(i%, j%) = 1 THEN
CIRCLE (j% * 16 + 8, i% * 16 + 8), 8, 4
PAINT (j% * 16 + 8, i% * 16 + 8), 4, 4
grilleJoueur(i%, j%) = -1
troufionsJoueur = troufionsJoueur - 1
grilleJoueur(i%, j%) = -1
LOCATE 28, 2: PRINT "Il vous reste "; troufionsJoueur; "troufions "
SLEEP
GOTO pcRejoue
ELSE
CIRCLE (j% * 16 + 8, i% * 16 + 8), 8, 2
PAINT (j% * 16 + 8, i% * 16 + 8), 2, 2
grilleJoueur(i%, j%) = -1
END IF
END IF
IF troufionsJoueur <= 0 THEN PRINT "Perdu !!": END
GOTO choixArme
END SELECT