XLanding Game

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: http://www.swissmicros.com/dm42/decoder/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
IonX
Posts: 9
Joined: Fri Jun 05, 2020 3:38 am

XLanding Game

Post by IonX » Thu Jun 18, 2020 7:48 am

Hello All,

Just got my DM42 3 weeks ago, thankyou SwissMicros.com and Free42. Have Been playing around and getting back to RPN programming again. Just wanted to see if I can build a graphics game.

Games:
This games is called XLanding, try to land the ship on the landing pad while it move left or right. Try to get exact position with Speed=0, Alt=0, and Fuel>0. It is hard, not once I can get the ship to land.
XLanding.bmp
XLanding.bmp (12.31 KiB) Viewed 252 times
Menu:
Left: Move ship left
Boost: Boost ship upward
Speed
Alt
Fuel
Right: Move ship right

So have a play, get a landing if you can...!! Any help with this program is welcome and feel free to modify the game.

Thanks,

Here is the Code listing: Have fun DM42.
XLanding.raw
(1.58 KiB) Downloaded 17 times

Code: Select all

00 { 1613-Byte Prgm }
01▸LBL "LANDING"
02 CLLCD
03 2
04 STO "GrMod"
05 SIZE 100
06 1
07 STO "I"
08 94
09 STO "J"
10 95
11 STO "G"
12 84
13 STO "H"
14 40
15 STO "F"
16 94
17 STO "A"
18 1
19 STO 07
20 0
21 STO "D"

22 XEQ a @Setup Ship,Landing,ALT,Fuel,Speed,UFO

23▸LBL 00 @Main

24 MENU
25 1.005
26 STO 10

27▸LBL 11
28 RAN
29 94
30 ×
31 IP
32 RAN
33 240
34 ×
35 IP
36 PIXEL
37 ISG 10
38 GTO 11
39 -94
40 1
41 PIXEL
42 1.2001
43 STO 10
44▸LBL 12
45 "."
46 89
47 RCL 10
48 IP
49 AGRAPH @Grass
50 ISG 10
51 GTO 12
52 CLA
53 ARCL 01
54 ARCL 02
55 RCL "I"
56 RCL "J"
57 AGRAPH @Ship
58 CLA
59 ARCL 03
60 ARCL 04
61 RCL "H"
62 RCL "G"
63 AGRAPH @Landing Pad
64 CLA
65 ARCL 05
66 39
67 RCL "G"
68 3
69 +
70 AGRAPH @UFO
71 CLA
72 ARCL 11
73 ARCL 12
74 97
75 111
76 AGRAPH @ALT
77 CLA
78 ARCL 13
79 ARCL 14
80 ARCL 15
81 97
82 142
83 AGRAPH @Fuel
84 CLA
85 ARCL 16
86 ARCL 17
87 ARCL 18
88 ARCL 19
89 97
90 75
91 AGRAPH @Speed
92 PSE
93 XEQ 80

94 SF 34
95 CLA
96 ARCL 01
97 ARCL 02
98 RCL "I"
99 RCL "J"
100 AGRAPH @Clear Ship
101 CLA
102 ARCL 03
103 ARCL 04
104 RCL "H"
105 RCL "G"
106 AGRAPH @Clear Pad
107 CLA
108 ARCL 20
109 RCL "I"
110 7
111 +
112 RCL "J"
113 2
114 +
115 AGRAPH @Clear Boost
116 CF 34

117 RCL "I"
118 RCL "D"
119 -
120 X≥0?
121 GTO 08
122 RCL 07
123 1
124 -
125 STO 07
126 GTO 09

127▸LBL 08
128 RCL 07
129 1
130 +
131 STO 07
132▸LBL 09
133 RCL "I"
134 RCL 07
135 +
136 STO "I"
137 RCL "H"
138 RCL "I"
139 8
140 +
141 -
142 STO "A"

143▸LBL 05 @Random Pad movement
144 RAN
145 2
146 ×
147 1
148 +
149 IP
150 1
151 X=Y?
152 GTO 05
153 RCL "G"
154 3
155 +
156 STO "G" @Move 3 right
157 GTO 06
158▸LBL 05
159 RCL "G"
160 3
161 -
162 STO "G" @Move 3 left

163▸LBL 06

164 "LEFT"
165 KEY 1 GTO 10

166 "BOOST"
167 KEY 2 GTO 20
168 CLA

169 RCL 07 @Speed
170 AIP
171 KEY 3 GTO 00
172 CLA

173 RCL "A" @Alt
174 AIP
175 KEY 4 GTO 00
176 CLA

177 RCL "F" @Fuel
178 X≤0?

179 0
180 STO "F"

181 RCL "F"
182 AIP
183 KEY 5 GTO 00

184 "RIGHT"
185 KEY 6 GTO 60


186 XEQ 80
187 XEQ 70
188 GTO 00

189▸LBL 10
190 CLA
191 ARCL 20
192 RCL "I"
193 7
194 +
195 RCL "J"
196 2
197 +
198 AGRAPH @Boost

199 RCL "J"
200 1
201 -
202 STO "J"
203 RCL "F"
204 1
205 -
206 STO "F"
207 GTO 00

208▸LBL 20
209 CLA
210 ARCL 20
211 RCL "I"
212 5
213 +
214 RCL "J"
215 3
216 +
217 AGRAPH @Boost

218 RCL "I"
219 2
220 -
221 STO "I"
222 RCL "F"
223 1
224 -
225 STO "F"
226 RCL "A"
227 3
228 +
229 STO "A"
230 RCL 07
231 2
232 -
233 STO 07
234 GTO 00

235▸LBL 60
236 CLA
237 ARCL 20
238 RCL "I"
239 7
240 +
241 RCL "J"
242 4
243 +
244 AGRAPH @Boost

245 RCL "J"
246 1
247 +
248 STO "J"
249 RCL "F"
250 1
251 -
252 STO "F"
253 XEQ 70
254 GTO 00

255▸LBL a
256 CLA
257 128
258 XTOA
259 184
260 XTOA
261 180
262 XTOA
263 114
264 XTOA
265 53
266 XTOA
267 53
268 XTOA
269 ASTO 01
270 CLA
271 53
272 XTOA
273 53
274 XTOA
275 114
276 XTOA
277 180
278 XTOA
279 184
280 XTOA
281 128
282 XTOA
283 ASTO 02
284 CLA
285 255
286 XTOA
287 255
288 XTOA
289 254
290 XTOA
291 189
292 XTOA
293 219
294 XTOA
295 231
296 XTOA
297 ASTO 03
298 CLA
299 231
300 XTOA
301 219
302 XTOA
303 189
304 XTOA
305 254
306 XTOA
307 255
308 XTOA
309 255
310 XTOA
311 ASTO 04
312 CLA
313 28
314 XTOA
315 62
316 XTOA
317 247
318 XTOA
319 247
320 XTOA
321 62
322 XTOA
323 28
324 XTOA
325 ASTO 05
326 CLA
327 1
328 XTOA
329 1
330 XTOA
331 128
332 XTOA
333 128
334 XTOA
335 1
336 XTOA
337 1
338 XTOA
339 ASTO 06
340 CLA
341 255
342 XTOA
343 9
344 XTOA
345 9
346 XTOA
347 255
348 XTOA
349 0
350 XTOA
351 255
352 XTOA
353 ASTO 11
354 CLA
355 128
356 XTOA
357 128
358 XTOA
359 0
360 XTOA
361 1
362 XTOA
363 255
364 XTOA
365 1
366 XTOA
367 ASTO 12
368 CLA
369 255
370 XTOA
371 9
372 XTOA
373 9
374 XTOA
375 0
376 XTOA
377 255
378 XTOA
379 128
380 XTOA
381 ASTO 13
382 CLA
383 255
384 XTOA
385 0
386 XTOA
387 255
388 XTOA
389 137
390 XTOA
391 137
392 XTOA
393 0
394 XTOA
395 ASTO 14
396 CLA
397 255
398 XTOA
399 128
400 XTOA
401 128
402 XTOA
403 ASTO 15
404 CLA
405 143
406 XTOA
407 137
408 XTOA
409 249
410 XTOA
411 0
412 XTOA
413 255
414 XTOA
415 9
416 XTOA
417 ASTO 16
418 CLA
419 15
420 XTOA
421 0
422 XTOA
423 255
424 XTOA
425 137
426 XTOA
427 137
428 XTOA
429 0
430 XTOA
431 ASTO 17
432 CLA
433 255
434 XTOA
435 137
436 XTOA
437 137
438 XTOA
439 0
440 XTOA
441 255
442 XTOA
443 129
444 XTOA
445 ASTO 18
446 CLA
447 126
448 XTOA
449 ASTO 19
450 CLA
451 3
452 XTOA
453 7
454 XTOA
455 81
456 XTOA
457 81
458 XTOA
459 7
460 XTOA
461 3
462 XTOA
463 ASTO 20
464 RTN

465▸LBL 70 @Landed,Crash,Out of Fuel
466 RCL "F"
467 X<0?
468 GTO 92
469 -1
470 RCL "A"
471 X≤Y?
472 GTO 91
473 RCL "H"
474 RCL "I"
475 8
476 +
477 X≤Y?
478 GTO 71
479 RTN
480▸LBL 71
481 2
482 RCL "A"
483 X≤Y?
484 GTO 72
485 RTN
486▸LBL 72
487 2
488 RCL 07
489 X≤Y?
490 GTO 73
491 RTN
492▸LBL 73
493 RCL "G"
494 RCL "J"
495 X=Y?
496 GTO 90
497 GTO 93
498 RTN

499▸LBL 80 @Crash UFO
500 39
501 RCL "I"
502 7
503 +
504 X≥Y?
505 GTO 81
506 RTN
507▸LBL 81
508 RCL "G"
509 RCL "J"
510 9
511 +
512 X≥Y?
513 GTO 82
514 RTN
515▸LBL 82
516 47
517 RCL "I"
518 X≤Y?
519 GTO 83
520 RTN
521▸LBL 83
522 RCL "G"
523 RCL "J"
524 9
525 -
526 X≤Y?
527 GTO 85
528 RTN

529▸LBL 85
530 "YOU CRASHED"
531 ├" A UFO??"
532 ├" Press R/S"
533 AVIEW
534 EXITALL
535 PROMPT
536 GTO 94

537▸LBL 90
538 "YOU LANDED..!!"
539 AVIEW
540 PSE
541 ├"GOOD JOB..!!"
542 AVIEW
543 EXITALL
544 PROMPT
545 GTO 94

546▸LBL 91
547 RCL 07
548 X>0?
549 "SHIP SPEED TOO "
550 ├"FAST "
551 RCL 07
552 AIP
553 ├" m/s @"
554 ├" GROUND 0"
555 RCL "A"
556 X<0?
557 ├" AND INTO IT"
558 AVIEW
559 PSE
560 PSE
561 EXITALL
562 "CRASHED...!!"
563 ├" Press R/S"
564 AVIEW
565 PSE
566 PROMPT
567 GTO 94

568▸LBL 92
569 "SHIP gone Down"
570 AVIEW
571 PSE
572 "OUT OF FUEL..!!"
573 ├" Press R/S"
574 AVIEW
575 PSE
576 EXITALL
577 PROMPT
578 GTO 94

579▸LBL 93
580 "SHIP missed"
581 ├" the Landing"
582 ├" Pad..!!"
583 AVIEW
584 PSE
585 "CRASHED..!!"
586 ├" Press R/S"
587 AVIEW
588 PSE
589 EXITALL
590 PROMPT
591 GTO 94

592▸LBL 94
593 CLLCD
594 CLMENU
595 CLKEYS
596 "Restart?"
597 AVIEW
598 "Yes"
599 KEY 1 XEQ "LANDING"
600 "No"
601 KEY 6 GTO 95
602 MENU
603 STOP

604▸LBL 95
605 "BYE BYE"
606 AVIEW
607 PSE
608 CLLCD
609 CLMENU
610 CLKEYS
611 CLV "D"
612 CLV "A"
613 CLV "F"
614 CLV "H"
615 CLV "G"
616 CLV "J"
617 CLV "I"
618 EXITALL
619 PROMPT
620 END

IonX
Posts: 9
Joined: Fri Jun 05, 2020 3:38 am

Re: XLanding Game

Post by IonX » Tue Jun 23, 2020 5:32 am

Game Updated:

1. Fixed Landing sequence.
2. Added obstacle. ( Thanks TomL for re: obstacle detection )
3. Added grass...hahaha

Have fun DM42, play it.

Feel free to modify the game and repost.

Thanks,
IonX

whuyse
Posts: 59
Joined: Thu Dec 21, 2017 12:23 pm

Re: XLanding Game

Post by whuyse » Tue Jun 23, 2020 9:48 am

It is indeed hard ;-)
2 suggestions:
- erase the UFO before redrawing it (when you haven't clicked a button)
- use LSTO statements, then you don't have to clean up the variables. Works with REGS, too.

Cheers, Werner
42S #3249S01123
DM42 #00345

IonX
Posts: 9
Joined: Fri Jun 05, 2020 3:38 am

Re: XLanding Game

Post by IonX » Wed Jun 24, 2020 12:12 am

Thanks Werner....

I wanted to regraph the UFO but I like the effect it showed...ie. it ZOOM to its next position. Hahaha... :lol:

Yes, I'll try the LSTO command and will use it soon.

Thanks,
IonX

Post Reply