Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions about old games
#21
(04-01-2024, 12:06 AM)1micha.elok Wrote:
(03-30-2024, 08:25 PM)johnno56 Wrote: When you are right, you are right!

But, think how much more challenging a simple game can be... Moo Ha Ha Ha...

Let us try this dance again. Shall we?



J

Do you have any cheat code so that I can land it safely in the first attempt ? .... Big Grin

Oh, let me see... I think I stored it with my Chrystal Ball and my Wizard's wand... lol  Nah... I haven't even got the mechanics of the game sorted out yet... I am working on another version... Hopefully, if I can figure out how integrate Tilemap, then it should be a little easier to play. I have a hard copy of the Tilemap Editor document. It lists all the commands and provides an explanation, but there are no code samples... I am going to have to pick apart some of the N6 and N7 examples to try and figure out how to get it to work... Now, where did I put that Chrystal Ball?...
Logic is the beginning of wisdom.
Reply
#22
If you define the ground as a couple of connected lines, you can quite easily calculate the height at any x:

Code:
set window "test", 640, 480
set redraw off

' Create an array of connected lines that cover the width of the window.
lines = []
x0 = 0
y0 = 400
while x0 < 640
    x1 = x1 + 16 + rnd(64); y1 = 400 + rnd(80) - 40
    lines[sizeof(lines)] = [x0, y0, x1, y1]
    x0 = x1; y0 = y1
wend

' Loop until excape is pressed.
while not keydown(KEY_ESCAPE, true)
    set color 0, 0, 0
    cls
   
    ' Draw the lines.
    set color 255, 255, 255
    for i = 0 to sizeof(lines) - 1
        draw line lines[i][0], lines[i][1], lines[i][2], lines[i][3]
    next
   
    ' Mark the y coordinate of the ground at mouse x.
    x = mousex()
    y = GetY(lines, x)
    set color 0, 255, 0
    draw line x, y - 16, x, y
   
    redraw
    fwait 60
wend

function GetY(lines, x)
    y = 480
    for i = 0 to sizeof(lines) - 1
        if x >= lines[i][0] and x < lines[i][2]
            k = (x - lines[i][0])/(lines[i][2] - lines[i][0])
            y = lines[i][1] + k*(lines[i][3] - lines[i][1])
            break
        endif
    next
    return y
endfunc

I still haven't read through this thread yet, sorry. Maybe this is similar to what kevin did?
Reply
#23
(04-01-2024, 11:44 AM)Marcus Wrote: If you define the ground as a couple of connected lines, you can quite easily calculate the height at any x:

Code:
set window "test", 640, 480
set redraw off

' Create an array of connected lines that cover the width of the window.
lines = []
x0 = 0
y0 = 400
while x0 < 640
    x1 = x1 + 16 + rnd(64); y1 = 400 + rnd(80) - 40
    lines[sizeof(lines)] = [x0, y0, x1, y1]
    x0 = x1; y0 = y1
wend

' Loop until excape is pressed.
while not keydown(KEY_ESCAPE, true)
    set color 0, 0, 0
    cls
   
    ' Draw the lines.
    set color 255, 255, 255
    for i = 0 to sizeof(lines) - 1
        draw line lines[i][0], lines[i][1], lines[i][2], lines[i][3]
    next
   
    ' Mark the y coordinate of the ground at mouse x.
    x = mousex()
    y = GetY(lines, x)
    set color 0, 255, 0
    draw line x, y - 16, x, y
   
    redraw
    fwait 60
wend

function GetY(lines, x)
    y = 480
    for i = 0 to sizeof(lines) - 1
        if x >= lines[i][0] and x < lines[i][2]
            k = (x - lines[i][0])/(lines[i][2] - lines[i][0])
            y = lines[i][1] + k*(lines[i][3] - lines[i][1])
            break
        endif
    next
    return y
endfunc

I still haven't read through this thread yet, sorry. Maybe this is similar to what kevin did?

Great example - I will be keeping this with other collision routines that I have. 
It's similar to the one I posted - it is checking for the Y value for any given X value. The main difference is that I was demonstrating one way to check for collisions against a freehand landscape that has been drawn as a .png image file. I've used the routine in the past for a "defender" type game, and it seems to work well in that type of thing.
Reply
#24
(04-01-2024, 05:11 AM)johnno56 Wrote: ...
Oh, let me see... I think I stored it with my Chrystal Ball and my Wizard's wand... lol ... Now, where did I put that Chrystal Ball?...

My On-Board computer had failed (line 50) ... but the code on line 110 said "Good Luck"  ....Whaaaat
Help .... I need the Chrystal Ball ....

Quote:10 PRINT TAB(33);"LUNAR"
20 PRINT TAB(l5);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
25 PRINT: PRINT: PRINT
30 PRINT "THIS IS A COMPUTER SIMULATION OF AN APOLLO LUNAR"
40 PRINT "LANDING CAPSULE.": PRINT: PRINT
50 PRINT "THE ON-BOARD COMPUTER HAS FAILED (IT WAS MADE BY"
60 PRINT "XEROX) SO YOU HAVE TO LAND THE CAPSULE MANUALLY."
70 PRINT: PRINT "SET BURN RATE OF RETRO ROCKETS TO ANY VALUE BETWEEN"
80 PRINT "0 (FREE FALL) AND 200 (MAXIMUM BURN) POUNDS PER SECOND."
90 PRINT "SET NEW BURN RATE EVERY 10 SECONDS.": PRINT
100 PRINT "CAPSULE WEIGHT 32,500 LBS; FUEL WEIGHT 16,500 LBS."
110 PRINT: PRINT: PRINT: PRINT "GOOD LUCK"
http://www.vintage-basic.net/bcg/lunar.bas
Reply
#25
I know how to make the levels using the Tilemap Editor... I am really struggling with how and when to use the appropriate commands. The document that I have gives a summary of the Editor and a list of all the Library functions but there are no examples... A tutorial for the Editor would be a good idea....

In the meantime, I have used the "old school" method to create the level, using a text file of the "map" layout. Using a simple Axial Aligned Bounding Box function, for collision detection, I have managed to land the ship on the pad successfully and also managed to test the crashing as well... At the moment, the collision detection, is only working for the landing pad... Not much point if I can only land and crash on one tile... lol

The game is still to short and a bit difficult to land... but it does land (and crash) on the red pad just fine... lol


.zip   lander3.zip (Size: 51.4 KB / Downloads: 4)

I am slowly going nuts with this one... maybe a nice game of Pong?... *sigh*
Logic is the beginning of wisdom.
Reply
#26
(04-02-2024, 09:45 AM)johnno56 Wrote: I know how to make the levels using the Tilemap Editor... I am really struggling with how and when to use the appropriate commands. The document that I have gives a summary of the Editor and a list of all the Library functions but there are no examples... A tutorial for the Editor would be a good idea....

In the meantime, I have used the "old school" method to create the level, using a text file of the "map" layout. Using a simple Axial Aligned Bounding Box function, for collision detection, I have managed to land the ship on the pad successfully and also managed to test the crashing as well... At the moment, the collision detection, is only working for the landing pad... Not much point if I can only land and crash on one tile... lol

The game is still to short and a bit difficult to land... but it does land (and crash) on the red pad just fine... lol



I am slowly going nuts with this one... maybe a nice game of Pong?... *sigh*

There should be some tilemap examples in n7/examples/tilemap_library. But I'll see if I can make a video for the editor and code Smile
Reply
#27
Thanks Marcus. I will certainly go over the examples again and see what I may be missing... I appreciate any effort that you are willing to do... Thank you...
Logic is the beginning of wisdom.
Reply
#28
(04-02-2024, 11:17 AM)johnno56 Wrote: Thanks Marcus. I will certainly go over the examples again and see what I may be missing... I appreciate any effort that you are willing to do... Thank you...

I tried the game, and it's a fun one. Add some lunar storms to mess with the player and it'll be a hit!
Reply
#29
I have already setup another 8 maps... But, the current method of game play, is not what I am aiming for... The orbiter idea came from a Scratch game I saw many moons (mo pun intended) ago... Originally, the Lander will start from the green pad, take off and land on the red pad, using a limited amount of fuel. (this will be added once everything is working... lol) As I had not quite figured out the collision issues, I figured that the Lander, would "drop" to the surface....

It's just gone 5am and I need to get the coffees made before my wife heads off to work...
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)