Author Topic: Lander (my version)  (Read 4675 times)

0 Members and 1 Guest are viewing this topic.

Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
Lander (my version)
« on: November 12, 2020, 04:04:01 pm »
decided to try my attempt at a Lander game.
i'm sure its not as pretty (or just simply as good) as others, but this is my attemp/version
the main menu allows you to make lots of modifications to the game play
the config file includes text to hopefully explain what the settings affect
Lander-gameplay.jpg
* Lander-gameplay.jpg (Filesize: 9.58 KB, Dimensions: 986x501, Views: 209)
Lander-gameOptions.jpg
* Lander-gameOptions.jpg (Filesize: 20.59 KB, Dimensions: 198x272, Views: 210)
* Lander.zip (Filesize: 12.82 KB, Downloads: 163)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Lander (my version)
« Reply #1 on: November 12, 2020, 05:39:26 pm »
That's really fun! If you want, you could add exhaust shooting out the bottom when you press the arrow keys. Really good game-play, makes me want to make one. :)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Lander (my version)
« Reply #2 on: November 12, 2020, 06:29:14 pm »
Gotta love the landers!
Logic is the beginning of wisdom.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Lander (my version)
« Reply #3 on: November 13, 2020, 01:07:18 am »
Can you land it?    I tried a couple times and hit a rock.  Why are there rocks orbiting
at low altitude? Where's the McDonalds?   Why doesn't it smell like cheese?
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Lander (my version)
« Reply #4 on: November 13, 2020, 11:17:45 am »
Quote
Where's the McDonalds?

Oh, that's what my Lander is missing! LOL

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Lander (my version)
« Reply #5 on: November 13, 2020, 06:59:54 pm »
Piece of cake to land:
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 640, 32) ' Lander 30 LOC  2020-11-13
  2. g& = _NEWIMAGE(800, 640, 32)
  3. REDIM g(100)
  4.     CLS: _KEYCLEAR
  5.     h = 30: dx = 1: x = 3: y = 2
  6.     FOR i = 0 TO 99
  7.         IF RND < .5 THEN h = h + INT(RND * 3) - 1 ELSE h = h
  8.         IF h > 39 THEN h = 39
  9.         IF h < 25 THEN h = 25
  10.         LINE (i * 8, h * 16)-(i * 8 + 8, _HEIGHT), _RGB32(128), BF
  11.         g(i) = h
  12.         _PUTIMAGE , 0, g&
  13.     NEXT
  14.     WHILE 1
  15.         _PUTIMAGE , g&, 0
  16.         CIRCLE (x * 8 + 4, y * 16 + 8), 4, &HFF00FFFF
  17.         CIRCLE (x * 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  18.         CIRCLE (x * 8 + 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  19.         IF y >= g(x - 1) OR y >= g(x + 1) OR y >= g(x) OR y >= 40 THEN _PRINTSTRING (46 * 8, 2 * 16), "Crash": EXIT WHILE
  20.         IF y = g(x - 1) - 1 AND y = g(x + 1) - 1 THEN _PRINTSTRING (46 * 8, 2 * 16), "Landed": EXIT WHILE
  21.         kh& = _KEYHIT
  22.         IF kh& = 19200 THEN dx = dx - 1
  23.         IF kh& = 19712 THEN dx = dx + 1
  24.         IF kh& = 18432 THEN y = y - 5
  25.         x = x + dx: y = y + 1
  26.         _LIMIT 2
  27.     WEND
  28.     _DELAY 2
  29.  
  30.  

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Lander (my version)
« Reply #6 on: November 15, 2020, 03:58:40 am »
Yo Mark

you have in LINE 20 -> Subscript out of range !
by the way simple and nice progi...

but i am too stupid to figure which keys i must use
i figure that kh is a keyhit and looks like
move left  ?
move right ?
up ?

i see just a numbers ??
« Last Edit: November 15, 2020, 04:04:25 am by Aurel »
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Lander (my version)
« Reply #7 on: November 15, 2020, 05:33:07 am »
Nope. Not stupid.

Einstein said that he didn't have to remember anything that he could look up.

 I too had difficulty with the key numbers. Check out "_KEYHIT" in the help files.. All shall be revealed...

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Lander (my version)
« Reply #8 on: November 15, 2020, 11:23:21 am »
Use arrow keys left, right and up, now wad keys added. Off-sides x problem now = Crash!
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 640, 32) ' b+ Lander 30 LOC (double parking cheat) 2020-11-13
  2. g& = _NEWIMAGE(800, 640, 32)
  3. REDIM g(-100 TO 200)
  4.     CLS: _KEYCLEAR
  5.     h = 30: dx = 1: x = 3: y = 2
  6.     FOR i = -10 TO 110
  7.         IF RND < .5 THEN h = h + INT(RND * 3) - 1 ELSE h = h
  8.         IF h > 39 THEN h = 39
  9.         IF h < 25 THEN h = 25
  10.         LINE (i * 8, h * 16)-(i * 8 + 8, _HEIGHT), _RGB32(128), BF
  11.         g(i) = h
  12.         _PUTIMAGE , 0, g&
  13.     NEXT
  14.     WHILE 1
  15.         _PUTIMAGE , g&, 0
  16.         CIRCLE (x * 8 + 4, y * 16 + 8), 4, &HFF00FFFF
  17.         CIRCLE (x * 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  18.         CIRCLE (x * 8 + 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  19.         IF y >= g(x - 1) OR y >= g(x + 1) OR y >= g(x) OR y >= 40 OR x < -5 OR x > 105 THEN _PRINTSTRING (46 * 8, 2 * 16), "Crash": EXIT WHILE
  20.         IF y = g(x - 1) - 1 AND y = g(x + 1) - 1 THEN _PRINTSTRING (46 * 8, 2 * 16), "Landed": EXIT WHILE
  21.         kh& = _KEYHIT
  22.         IF kh& = 19200 OR kh& = 97 THEN dx = dx - 1
  23.         IF kh& = 19712 OR kh& = 100 THEN dx = dx + 1
  24.         IF kh& = 18432 OR kh& = 119 THEN y = y - 5
  25.         x = x + dx: y = y + 1
  26.         _LIMIT 2
  27.     WEND
  28.     _DELAY 2
  29. ' 2020-11-15 fix off-sides x, add alternate keys: a=left d=right w=up  so now arrow keys or WAD system works
  30.  

BTW this was originally ASCII with LOCATE: PRINT but cant draw or print off screen so if thrust Lander over top edge of screen it also use to error out with LOCATE. Now you can wait for it to drift back in screen, cool! (If you dont drift too far off sides also.) This is why _PRINTSTRING is superior to LOCATE and PRINT.

Really should be able to set down Lander anywhere you desire except McD's.

« Last Edit: November 15, 2020, 11:36:58 am by bplus »

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Lander (my version)
« Reply #9 on: November 15, 2020, 03:44:05 pm »
Mark
I want to say that i cannot control lander
when i press
LEFT arrow key ....leander not respond
same for others arrow keys
with
wasd only W respond and lander little bit jump
my question is can i use virtual key codes like i use in
o2 compiler with

% vk_LEFT     = &H25
% vk_UP       = &H26
% vk_RIGHT    = &H27
% vk_DOWN     = &H28

//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Lander (my version)
« Reply #10 on: November 15, 2020, 03:48:42 pm »
well i tried and not work i dont know why

 IF kh& = &H25  THEN dx = dx - 1   'it should be left arrow key
 IF kh& = &H27  THEN dx = dx + 1  'it should be right arrow key
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Lander (my version)
« Reply #11 on: November 15, 2020, 03:51:18 pm »
@Aurel check your keys with this:
Code: QB64: [Select]
  1. WHILE 1 'find code for keypress
  2.     k$ = INKEY$
  3.     hk& = _KEYHIT
  4.     IF LEN(k$) THEN
  5.         SELECT CASE LEN(k$)
  6.             CASE 1: PRINT "1 char keypress = "; ASC(k$); "  keyhit = "; hk&
  7.             CASE 2: PRINT "2 char keypress = "; ASC(RIGHT$(k$, 1)); "  keyhit = "; hk&
  8.         END SELECT
  9.     END IF
  10.     _DISPLAY
  11.     _LIMIT 60
  12. PRINT "Goodbye."
  13.  
  14. 'findings
  15. '<esc> pressed twice exits this screen! number printed after 2nd press of any
  16.  
  17. 'Alt + letter  -> 2 char keypress numbers seem to jump all around they are QWERTY order?
  18.  
  19. 'Ctrl + letter -> 1 char A = 1, B = 2...
  20. 'Ctrl + m is same as <enter>
  21.  
  22. 'arrows
  23. 'up 72, dowm 80, left 75, right 77
  24.  

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Lander (my version)
« Reply #12 on: November 15, 2020, 04:10:23 pm »
ok!
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Lander (my version)
« Reply #13 on: November 15, 2020, 04:19:56 pm »
well ok
now respond ...let say somehow but moving ship is too hard to control
i put key parts on the start of while loop
like this :
Code: QB64: [Select]
  1.    
  2.    
  3.      SCREEN _NEWIMAGE(800, 640, 32) ' b+ Lander 30 LOC (double parking cheat) 2020-11-13
  4.     g& = _NEWIMAGE(800, 640, 32)
  5.     REDIM g(-100 TO 200)
  6.     DO
  7.         CLS: _KEYCLEAR
  8.         h = 30: dx = 1: x = 3: y = 2
  9.         FOR i = -10 TO 110
  10.             IF RND < .5 THEN h = h + INT(RND * 3) - 1 ELSE h = h
  11.             IF h > 39 THEN h = 39
  12.             IF h < 25 THEN h = 25
  13.             LINE (i * 8, h * 16)-(i * 8 + 8, _HEIGHT), _RGB32(128), BF
  14.             g(i) = h
  15.             _PUTIMAGE , 0, g&
  16.         NEXT
  17.         WHILE 1
  18.             kh& = _KEYHIT
  19.             IF kh& = 19200 THEN dx = dx - 2
  20.             IF kh& = 19712 THEN dx = dx + 2
  21.             IF kh& = 18432 THEN y = y - 5
  22.            
  23.             _PUTIMAGE , g&, 0
  24.             CIRCLE (x * 8 + 4, y * 16 + 8), 4, &HFF00FFFF
  25.             CIRCLE (x * 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  26.             CIRCLE (x * 8 + 8, y * 16 + 16), 4, &HFFFFFF00, 0, _PI
  27.             IF y >= g(x - 1) OR y >= g(x + 1) OR y >= g(x) OR y >= 40 OR x < -5 OR x > 105 THEN _PRINTSTRING (46 * 8, 2 * 16), "Crash": EXIT WHILE
  28.             IF y = g(x - 1) - 1 AND y = g(x + 1) - 1 THEN _PRINTSTRING (46 * 8, 2 * 16), "Landed": EXIT WHILE
  29.             x = x + dx: y = y + 1
  30.             _LIMIT 2
  31.         WEND
  32.         _DELAY 2
  33.     LOOP
  34.     ' 2020-11-15 fix off-sides x, add alternate keys: a=left d=right w=up  so now arrow keys or WAD system works
  35.          
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lander (my version)
« Reply #14 on: November 15, 2020, 04:24:35 pm »
Try a higher limit.  You’re only running at 2 FPS.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!