Author Topic: Moon Lander  (Read 2529 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Moon Lander
« on: January 31, 2019, 10:57:30 pm »
Nov 29, 2020
Forgot to put the icon in the zip.  Added.

Updated Nov 28,2020
Found/fixed bug that crashed program at Warp 9.  Only updated the attachment,
not the long listing below.

Updated July 5, 2020
1) option to regenerate ground at startup with the parameter "regen"
2) files f1.dat and f2.dat included in the upper/lowercase filename check for Linux

Updated June 1, 2020

Error at  line 1302
a2 = (z2 + tao * 5 + tsix0) MOD tsix
should be:
a2 = (z2 + tao * 5 + tsix * t) MOD tsix

Error only appears if shields are turned on with F8, but it does crash the program.
Source file in attachment has this change.
---------------------------------------------------------------------------------------------------------
Updated May 15, 2020.  More effects (at warp speeds) and cookies!

Initially written in QB4.5, hence the convoluted code to save space, upgraded to use some QB64 features.
* L64.ZIP (Filesize: 1.52 MB, Downloads: 215)
« Last Edit: November 29, 2020, 04:56:09 am by Richard Frost »
It works better if you plug it in.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Moon Lander
« Reply #1 on: January 31, 2019, 11:13:25 pm »
im not sure why but i get
Code: QB64: [Select]
  1. $ ./L64
  2. [xcb] Unknown request in queue while dequeuing
  3. [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
  4. [xcb] Aborting, sorry about that.
  5. L64: xcb_io.c:165: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
  6. Aborted (core dumped)
  7.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moon Lander
« Reply #2 on: February 01, 2019, 12:08:49 am »
Haven't found the kitchen sink yet, but I think it has everything else. ;-))

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Moon Lander
« Reply #3 on: February 01, 2019, 09:21:25 am »
This game is beautiful and whimsical. Give it some time to compile folks, it's worth it!

I still don't think I've seen every quirky little thing yet... and that includes landing properly, haha.

As one of QB64's toughest customers, I have this to say: "Bravo Sir"

EDIT:

Finally landed. I love that JFK's grave is on the moon, and Halle Berry is floating around up there too. The pseudo-3d stuff is top notch - looks very convincing for a side-scroller. I'm nowhere near done trying this out.
« Last Edit: February 01, 2019, 09:26:52 am by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Moon Lander
« Reply #4 on: February 04, 2019, 05:10:19 am »
Wow!  This is a piece of coding.  DECLARE FUNCTION & DECLARE SUB are not required in QB64 (and DIM SHARED would be "better" (?) than COMMON SHARED as we're not using external modules): small nick-picking comments & I expect that you knew this in any case.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Moon Lander
« Reply #5 on: February 04, 2019, 05:56:17 am »
No, I didn't know that the DECLAREs are optional. I'm rather new to QB64 - less than
a month at it.  Is that why the editor didn't move the comments on those lines?  The entire line is just ignored, eh?   

Might be good to keep them for the documention rather than move all the comments to the SUBs. I'll think about it. 

Thanks for the info!

It works better if you plug it in.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Moon Lander
« Reply #6 on: February 04, 2019, 09:03:03 am »
Might be good to keep them for the documention rather than move all the comments to the SUBs. I'll think about it. 

Richard, I had assumed that you had left in the DECLARE lines because of the explanatory comments, so yes keep them in.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Moon Lander
« Reply #7 on: July 05, 2020, 05:33:43 am »
Hi Richard,

Just downloaded your lander. I'm running with Linux Mint 19.3. Linux is very 'picky' about the case of variables and filenames. I am impressed that only 2 filenames caused an issue. (F1 and F2.dat) - fixed by using '.DAT'

I only have one other issue. When the game starts, a screen with the title of "Puncture Damage" with a particle 'explosion', displays over and over until I exit the game. No error message. Just the loop.
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moon Lander
« Reply #8 on: July 05, 2020, 11:28:08 am »
Hi Richard,

Just downloaded your lander. I'm running with Linux Mint 19.3. Linux is very 'picky' about the case of variables and filenames. I am impressed that only 2 filenames caused an issue. (F1 and F2.dat) - fixed by using '.DAT'

I only have one other issue. When the game starts, a screen with the title of "Puncture Damage" with a particle 'explosion', displays over and over until I exit the game. No error message. Just the loop.

Could search source code and see what generates that phrase "Puncture Damage". My guess is another thing has run afoul with Linux.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Moon Lander
« Reply #9 on: July 05, 2020, 12:22:03 pm »
If this is a Linux thing, I wonder if we ought to amend all the Games/Samples posts to show which Operating Sytems are compatible.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moon Lander
« Reply #10 on: July 05, 2020, 12:30:16 pm »
If this is a Linux thing, I wonder if we ought to amend all the Games/Samples posts to show which Operating Sytems are compatible.


Or just mention which OS the code was developed in.

Oh, and maybe which version QB64.
« Last Edit: July 05, 2020, 12:31:44 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Moon Lander
« Reply #11 on: July 05, 2020, 12:32:52 pm »
As the game was posted last year, and there has not been any reported 'bugs', I too would conclude that it is probably a "Linux thing". I figured that someone would know... Don't give it another thought... Only wanted to see the game run... Not a big deal. I'll move on to something else... Many thanks.
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moon Lander
« Reply #12 on: July 05, 2020, 12:50:17 pm »
You know I checked myself where in code "Puncture Damage" comes up. It is when code is checking if the lander hit anything.

@johnno56 this is such a delightful program to watch! It would be good thing if we could get it going in Linux.
But it would take some digging to find the cause of problem. We might all benefit from finding problems when porting to Linux.

Here is the GOSUB that contains the code for Puncture Damage
Code: QB64: [Select]
  1. CheckHit: '                                                           contact with ground
  2. cc1 = ((sy1 + 1) >= gety(-sx1)) '                                     left pad
  3. cc2 = ((sy2 + 1) >= gety(-sx2)) '                                     right pad
  4. mingx = 0
  5. mingy = q1
  6. FOR zx = sx1 TO sx2 '                                                 check between pads
  7.     p = POINT(zx, sy1 - 2)
  8.     IF p = gray THEN '                                                got 1
  9.         ty = gety(-zx)
  10.         IF ty < mingy THEN mingx = zx: mingy = ty
  11.     END IF
  12. NEXT zx
  13.  
  14. IF mingx THEN
  15.     i = mingx - sx1
  16.     j = sx2 - mingx
  17.     IF i < j THEN cc1 = -1 ELSE cc2 = -1
  18.  
  19. GOSUB CWceiling '                                                     car wash
  20. IF vy! < 0 THEN RETURN '                                              going UP
  21.  
  22. IF cc1 OR cc2 THEN '                                                  pad(s) on ground
  23.     contact = 1
  24.     tmt! = 0
  25.     py! = py! + rfy '                                                 no time to correct jitter
  26.     TexOnLM$ = ""
  27.     warp! = 0
  28.     GOSUB CutOrOutOfFuel
  29.  
  30.     IF (vy! > 0) AND ABS(sy1 - (ey(2) - 40)) < t THEN
  31.         lob = 1 '                                                     landed on Borg
  32.         vx! = vx! - exv(2)
  33.     END IF
  34.  
  35.     IF (ABS(vx!) > t) OR (vy! > 20) THEN
  36.         dead$ = "HIGH SPEED IMPACT!"
  37.         RETURN
  38.     END IF
  39.  
  40.     dp = 8 + (h - fuel!) \ 25 '                                       8 - 12
  41.     IF (vy! > dp) OR (ABS(vx!) > 8) THEN '                            too fast given load
  42.  
  43.         crash = 1
  44.         panelinit = 0
  45.         shield = 0
  46.         dead$ = "CRASHED"
  47.         z = vx! * t + vy! * t
  48.         FOR i = 1 TO rp '                                             create layer of debris
  49.             LMrx(i) = LMrx(i) + RND * z - (z \ 2)
  50.             LMry(i) = gety(LMrx(i)) - RND * 2 - 1
  51.         NEXT i
  52.         PALETTE green, 0 '                                            blank instruments
  53.         PALETTE red, 32
  54.         PALETTE yellow, 0
  55.         RETURN
  56.     END IF
  57.  
  58.     IF (vy! > 3) OR (ABS(vx!) > 3) THEN fb$ = "vehicle damaged"
  59.  
  60.     IF (vy! > 4) OR (ABS(vx!) > 4) THEN
  61.         fb$ = "vehicle severely damaged"
  62.         LMdistort '                                                   randomly vary structure
  63.         vsd = 1 '                                                     vehicle severely damaged
  64.     END IF
  65.  
  66.     savea = a + ma
  67.  
  68.     IF lob THEN '                                                     landed on Borg
  69.         a = 0
  70.         IF sx1 < borgl THEN a = 45
  71.         IF sx2 > borgr THEN a = -45
  72.         py! = py! - t * (ABS(a) = 45)
  73.         RETURN
  74.     END IF
  75.  
  76.     '                                                                 optional, allow ANY part of pad
  77.     IF cc1 THEN cd = -1: cpx = sx2: cpy = sy2 + 1
  78.     IF cc2 THEN cd = 1: cpx = sx1: cpy = sy1 + 1
  79.     FOR i = 1 TO 4
  80.         cpx = cpx + cd
  81.         IF (cpy >= gety(-cpx)) THEN
  82.             IF cc1 THEN cc2 = 1 ELSE cc1 = 1
  83.         END IF
  84.     NEXT i
  85.  
  86.     IF NOT (cc1 AND cc2) THEN '                                       only 1 pad down
  87.         npass = 0
  88.         DO: _LIMIT mdelay * 2 '                                       settle LM
  89.             a = a + (cc1 - cc2)
  90.             pa:
  91.             npass = npass + 1
  92.             IF npass > 150 THEN EXIT DO
  93.             GOSUB Plotscreen '                                        show change
  94.             IF LEN(dead$) THEN EXIT DO
  95.             IF ABS(a) > 40 THEN
  96.                 a = 180 '                                             upside down
  97.                 py! = glmax - ny
  98.                 LMdistort '                                           optional
  99.                 EXIT DO
  100.             END IF
  101.             IF cc1 AND (sy1 < gety(-sx1)) THEN py! = py! + 1: GOTO pa
  102.             IF cc2 AND (sy2 < gety(-sx2)) THEN py! = py! + 1: GOTO pa
  103.             cc3 = ((sy1 + 1) >= gety(-sx1))
  104.             cc4 = ((sy2 + 1) >= gety(-sx2))
  105.             IF ABS(a) > 80 THEN py! = glmax - wi2
  106.  
  107.             z = gety(INT(px!)) - py! - ny + 5
  108.             IF (z < 0) AND (paraf = 0) THEN
  109.                 dead$ = "PUNCTURE DAMAGE"
  110.                 ' dead$ = "PUNCTURE" + STR$(-z)
  111.                 RETURN
  112.             END IF
  113.  
  114.         LOOP UNTIL (cc1 AND cc4) OR (cc2 AND cc3)
  115.     END IF
  116.  

Here is the code block that sets up the "Puncture Damage" crash
Code: QB64: [Select]
  1.             z = gety(INT(px!)) - py! - ny + 5
  2.             IF (z < 0) AND (paraf = 0) THEN
  3. cls  ' >>>>>>>>>>>>>>>>>>>>>>>>> debug
  4. print "z and paraf";z, paraf    '>>>>>>>>>>>>>>>>> start debug
  5.                 dead$ = "PUNCTURE DAMAGE"
  6.                 ' dead$ = "PUNCTURE" + STR$(-z)
  7. sleep ' more debug session
  8. end ' no sense continuing
  9.                 RETURN
  10.             END IF
  11.  

So which is it (z<0) or (paraf = 0) or both?

If z here is your lead on that from line above:
Code: QB64: [Select]
  1.  z = gety(INT(px!)) - py! - ny + 5
  2.  


« Last Edit: July 05, 2020, 12:54:50 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Moon Lander
« Reply #13 on: July 06, 2020, 03:40:53 am »
The program was developed with QB4.5 under Windows XP, and upgraded to QB64 version 1.3 late in the game.  It now uses some QB64 features and cannot run under 4.5.   I know nothing about Linux, except the filename difference.

f1 and f2.dat are fonts.  Sorry I missed checking them with the FUNCTION FileCheck which looks for upper or lowercase filenames.

That the program generates Puncture Damage right away is an odd one, for which I have 2 fixes, either of which should work:
1) unzip the original files
2) download and compile the current version, and fire up the program with the parameter "regen".  This will generate new
ground files.

Puncture damage is supposed to occur when trying to land on a peak instead of flat ground, but such a landing is possible if
one uses the parachute (shift p). The variable paraf is a flag indicating that the parachute has been deployed.  Does a
parachute work on the Moon?  Of course not!  It wouldn't even open without an atmosphere.  I include it as another example
of silliness, and because it's fun to include another pointless graphic (the parachute).
 
A major pain someone noted are the star files.  If one activates stars (1-4), this setting is saved.  Then, at each start, a random
star view is selected and if that star file doesn't exist, it is created.  It's a small but annoying delay.  The solution is to  generate all the star files at once with | (ASCII 124).  It's about 4100 files, 1368 files for 3 levels of quantity.  These stars
are not random - they're from some database I found.  The display is far from realistic with the lines of declination not curving
towards the top, but the Big Dipper is still recognizable.  Or one could disable stars by changing the code to "starstatus = 0"
twice in the init1 section.  I could have included all these star files in the zip, but.....many might consider it a bit much to have
so many support files, even in subdirectories. 

A sad side effect of posting an update is that the download counter is reset.  It'd be nice to know how many times the zip has been downloaded without having to remember and count up previous numbers.  Shucks.
« Last Edit: July 06, 2020, 03:48:50 am by Richard Frost »
It works better if you plug it in.