Author Topic: 3D Tunnel Lines Demonstration  (Read 7582 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #15 on: July 12, 2019, 10:13:49 pm »
Hi Ken,

MOD is the remainder part of a division of two integers:
1/3 = 0 R 1 so 1 MOD 3 = 1
2/3 = 0 R 2 so 2 MOD 3 = 2
3/3 = 1 R 0 so 3 MOD 3 = 0  another way of saying 3 divides 3 exactly, like 3 divides 6, 3 divides 9, 3 divides 12...
4/3 = 1 R 1 so 4 MOD 3 = 1
5/3 = 1 R 2 so 5 MOD 3 = 2, the remainder of m/n is always between 0 and n-1, you can never have a remainder >= n which comes in really handy for allot things in computer programming.

n MOD m
+ it always keeps numbers between 0 and m-1
+ you can test if something divides evenly, if  a mod b = 0,  b divides a as 6 mod 3 = 0 because 3 divides 6
+ toggle = (toggle + 1) MOD 2 always keeps toggle at 0 or 1

offset is just an add on, say you want a box every 10 pixels, but you want to start with a margin of 5 from edge the the x offset is 5:  boxX(i) = i * 10 + xOffset
« Last Edit: July 12, 2019, 10:17:43 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #16 on: July 12, 2019, 11:59:41 pm »
Very cool, thanks B+. I've also been wondering about how I used to use XOR with PUT to make graphics put on top of other graphics and the rest remains, without having to draw it again. Might be something for me to look into if it's still online somewhere.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #17 on: July 13, 2019, 12:05:23 pm »
Very cool, thanks B+. I've also been wondering about how I used to use XOR with PUT to make graphics put on top of other graphics and the rest remains, without having to draw it again. Might be something for me to look into if it's still online somewhere.

I don't know if XOR is used that much unless manipulating bits, you're talking numbers in binary format.

Let's stick to elements this thread brings up. I would spend my time learning _PUTIMAGE over the old way of PUT.

We could practice with the monster image. Can you set up an area to draw the monster using _NEWIMAGE, draw the monster there with the data statements (then you don't need an array to store the colors nor have to redraw from array, just use _PUTIMAGE). This is when you learn _SOURCE and _DEST, specially _DEST for telling QB where images are coming from (_SOURCE) and are to go (_DEST) that's what _PUTIMAGE needs the most.

'set up Monster area to draw it and store image under the handle monster&  << notice type long
Code: QB64: [Select]
  1. monster& = _NEWIMAGE(12, 12, 32) 'the monster is 13 x 13 which is 0 to 12 X 0 to 12
  2. _DEST monster&  '<<< drawing commands will now go to monster& area
  3. FOR my = 0 TO 12 'draw monster in monster& image area
  4.     FOR mx = 0 TO 12
  5.         READ cl
  6.         pset (mx, my), _RGB32(cl * 60, 0, 0)
  7.     NEXT mx
  8. NEXT my
  9. 'we now have a monster image stored under the handle monster&
  10. _DEST 0 ' back to the screen

Use _PUTIMAGE to show monster. Here is the "monster" Swiss army knife of _PUTIMAGE command:
' _PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]]

 dx, dy controls where on screen for top, left corner, bottom right corner, the monster image will stretch or shrink to fit there dx, dy coordinates you specify. d stand for destination which is main screen for our monster&
(dx1, dy1) is top left corner
(dx2, dy2) is bottom left corner
with these you can control how big or small to show the monster on main screen.

Source handle is monster&
Destination handle is 0 for default screen

sx, sy controls what parts to show from source image, we are using whole image so those options remain blank

This code replace load array colors of monster and _PUTIMAGE replaces the GOSUB showMonster:

Still need:
monsterdata:
DATA 0,0,0,4,4,4,4,4,4,4,0,0,0
DATA 0,0,4,4,4,4,4,4,4,4,4,0,0
DATA 0,4,4,4,4,4,4,4,4,4,4,0,0
DATA 0,4,4,4,4,4,4,4,4,4,4,0,0
DATA 4,4,4,1,1,4,4,1,1,4,4,4,0
DATA 4,4,4,4,4,4,4,4,4,4,4,4,0
DATA 4,4,4,4,4,4,1,4,4,4,4,4,0
DATA 4,4,4,4,4,1,1,4,4,4,4,4,0
DATA 0,4,4,4,4,4,4,4,4,4,0,0,0
DATA 0,0,4,4,1,1,1,1,4,4,0,0,0
DATA 0,0,4,4,4,4,4,4,4,4,0,0,0
DATA 0,0,4,4,4,4,4,4,4,4,0,0,0
DATA 0,0,4,4,4,4,4,4,4,0,0,0,0

« Last Edit: July 13, 2019, 12:12:33 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #18 on: July 13, 2019, 01:34:22 pm »
And this is what I worked out for ShowMonster
Code: QB64: [Select]
  1. showMonster:
  2. 'PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&]
  3. _PUTIMAGE (300 - ms * 10, 300 - ms * 10)-(300 + ms * 10, 300 + ms * 10), monsterh&, 0
  4.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: 3D Tunnel Lines Demonstration
« Reply #19 on: July 13, 2019, 02:44:39 pm »
Bplus:  PUT (as the graphical command), was the old school way to store images in an array buffer and place them onto the screen, and XOR was one of the options available to draw (and remove) those images.  The wiki has a description of the PUT options here:  https://www.qb64.org/wiki/PUT_(graphics_statement)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #20 on: July 13, 2019, 03:27:37 pm »
Bplus:  PUT (as the graphical command), was the old school way to store images in an array buffer and place them onto the screen, and XOR was one of the options available to draw (and remove) those images.  The wiki has a description of the PUT options here:  https://www.qb64.org/wiki/PUT_(graphics_statement)

Yes, I did call PUT the "old way", but Steve wouldn't you advise learning new way with _PUTIMAGE, it's so much better!

This works great for resizing demon image:
Code: QB64: [Select]
  1. 'Made by Ken G. on July 11, 2019
  2. 'Thank you to B+ for his example on QB64.org forum!
  3. '2019-07-13 Bplus update with using image techniques
  4. _TITLE "Ken's Tunnel - Use Up and Down Arrow Keys" 'mod B+ 2019-07-12
  5. SCREEN _NEWIMAGE(600, 600, 32)
  6. DIM offset, my, mx, cl, s, sz, a$, monster, ms, monsterh&
  7.  
  8. 'get monster image stored under monsterh&
  9. monsterh& = _NEWIMAGE(12, 12, 32) 'the monster is 13 x 13 which is 0 to 12 X 0 to 12
  10. _DEST monsterh& '<<< drawing commands will now go to monster& area
  11. FOR my = 0 TO 12 'draw monster in monster& image area
  12.     FOR mx = 0 TO 12
  13.         READ cl
  14.         PSET (mx, my), _RGB32(cl * 60, cl * 60, cl * 60)
  15.     NEXT mx
  16. NEXT my
  17. 'we now have a monster image stored under the handle monster&
  18. _DEST 0 ' back to the screen
  19.  
  20. offset = 600000 'track if we are coming or going
  21.  
  22. DO 'go:  DO... LOOP indents main loop and makes it easier to read
  23.     CLS
  24.  
  25.     'handle tunnel
  26.     offset = offset + s
  27.     IF offset = 0 THEN offset = 300000
  28.     IF offset = 600001 THEN offset = 300000
  29.     FOR sz = 0 TO 300
  30.         IF (sz + offset) MOD 40 THEN
  31.             LINE (300 - sz, 300 - sz)-(300 + sz, 300 + sz), _RGB32(0, sz / 2, 0), B
  32.         ELSE
  33.             LINE (300 - sz, 300 - sz)-(300 + sz, 300 + sz), _RGB32(255 * sz / 300, 255 * sz / 300, 255 * sz / 300), B
  34.         END IF
  35.     NEXT sz
  36.  
  37.     'handle keys
  38.     a$ = INKEY$
  39.     IF a$ = CHR$(27) THEN END
  40.     IF a$ = CHR$(0) + CHR$(72) THEN s = s - 1: IF s < -5 THEN s = -5
  41.     IF a$ = CHR$(0) + CHR$(80) THEN s = s + 1: IF s > 5 THEN s = 5
  42.  
  43.     'handle monster
  44.     monster = monster - 1
  45.     IF s > 0 THEN ms = ms - .05
  46.     IF s < 0 THEN ms = ms + .05
  47.     IF ms > 5 THEN ms = 5
  48.     IF ms < 0 THEN ms = 0
  49.     IF monster <= 0 THEN monster = RND * 500 ELSE GOSUB showMonster
  50.  
  51.     _DISPLAY
  52.     _LIMIT 60
  53. LOOP 'goto go
  54.  
  55. showMonster:
  56. 'PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&]
  57. _PUTIMAGE (300 - ms * 10, 300 - ms * 10)-(300 + ms * 10, 300 + ms * 10), monsterh&, 0
  58.  
  59. monsterdata:
  60. DATA 0,0,0,4,4,4,4,4,4,4,0,0,0
  61. DATA 0,0,4,4,4,4,4,4,4,4,4,0,0
  62. DATA 0,0,4,4,4,4,4,4,4,4,4,4,0
  63. DATA 0,4,4,4,4,4,4,4,4,4,4,4,0
  64. DATA 0,4,4,1,1,1,4,4,1,1,1,4,4
  65. DATA 0,4,4,1,1,1,4,4,1,1,1,4,4
  66. DATA 0,4,4,2,2,2,4,4,2,2,2,4,4
  67. DATA 0,4,4,4,4,4,1,1,4,4,4,4,4
  68. DATA 0,0,4,4,4,4,4,4,4,4,4,4,0
  69. DATA 0,0,4,4,4,1,1,1,1,4,4,0,0
  70. DATA 0,0,0,4,4,4,4,4,4,4,4,0,0
  71. DATA 0,0,0,4,4,4,4,4,4,4,0,0,0
  72. DATA 0,0,0,4,4,4,4,4,4,4,0,0,0
  73.  

PS I was screwing around with image data...
« Last Edit: July 13, 2019, 03:30:53 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: 3D Tunnel Lines Demonstration
« Reply #21 on: July 13, 2019, 03:39:29 pm »
Aye.  I’d definitely promote _PUTIMAGE over PUT.  I was mainly just responding to your statement here:

Quote
I don't know if XOR is used that much unless manipulating bits, you're talking numbers in binary format.

It’s not used much nowadays, but you’ll see it in old QBasic programs to do as Ken suggested — drawing on top of various backgrounds.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #22 on: July 13, 2019, 03:59:47 pm »
Thanks guys, but B+ you are doing too much. I pretty much took off on my original code, but I am using your monster. I tried to put your code in mine but it didn't work for some reason and I couldn't figure it out. Here is where I am so far, but unless I ask for certain help on something, there's no need to try to help me with it. I use the Wiki pages a lot and today I learned how to use JPG pictures for doors on the side. For a few days I've just been using boxes for doors on the side but my own JPG pictures look much better. :) I will also do that for monsters too, etc. I'm not certain yet if I will keep that sprite monster, it was pretty much only for testing. Also, I really don't have a plan yet on my game, I just add something when I come up with something. But if you are curious, here is my code so far, but as of right now I don't need anything. I appreciate all the help you have given though. I just don't want you to take off in one direction and me the other. Also, personally, it feels best when I know exactly what all my code does. Back in the 90's I used to toss other people's code in my programs and most of the time I had no idea what it did. I'm a slow learner. lol But of course, feel free to always have suggestions, thanks. Oh, and right now the doors are just for looks, you can't enter them yet, but soon I hope to be able to. The door pictures are attached to this post. Oh also, I removed the way to back up so people just use the up arrow key now to go forward. There wouldn't be much of a need to back up. If I get really good and want people to turn around, they can use the arrow keys. I'm thinking to open the doors, people can just press the O or D keys, but that will be in the _TITLE so people know first.

(Note: There is a much better version below on this forum page.)

Code: QB64: [Select]
  1. 'Made by Ken G.
  2. 'Thank you to B+ for his example on QB64.org forum!
  3. 'Other files needed for this game: doorl.jpg, doorr.jpg
  4.  
  5. _TITLE "Ken's Tunnel - Use Up Arrow Key To Move"
  6.  
  7. begin:
  8. DIM segment(100)
  9. DIM my, mx, cl, s, sz, a$, monster, ms, x, y, t, sz2, seg2, length, rt, tu, doorr, doorl, os, m, mon
  10.  
  11. SCREEN _NEWIMAGE(600, 600, 32)
  12. x = 300: y = 300: t = 50
  13. s = 10
  14. sz2 = 10
  15. seg2 = 1
  16. 'Load tunnel into memory.
  17. length = INT(RND * 60) + 30
  18. tunnel:
  19. rt = INT(RND * 100) + 1
  20. tu = tu + 1
  21. IF rt < 25 THEN
  22.     segment(tu) = 1 'Right Door
  23. IF rt >= 25 AND rt < 50 THEN
  24.     segment(tu) = 2 'Left Door
  25. IF rt >= 50 THEN
  26.     segment(tu) = 3 'No Door
  27. IF tu = length THEN GOTO starttunnel:
  28. GOTO tunnel:
  29.  
  30. starttunnel:
  31. FOR sz = s TO 300
  32.     LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 2, sz / 2, sz / 2), B
  33. NEXT sz
  34.  
  35.  
  36.  
  37. doorl = _LOADIMAGE("doorl.jpg", 32)
  38. doorr = _LOADIMAGE("doorr.jpg", 32)
  39.  
  40. go:
  41.  
  42. a$ = INKEY$
  43. IF a$ = CHR$(27) THEN END
  44. IF a$ = CHR$(0) + CHR$(72) THEN
  45.     os = s
  46.     s = s + 5
  47.     IF s < 10 THEN s = 300: seg2 = seg2 - 1
  48.     IF s > 300 THEN s = 10: seg2 = seg2 + 1
  49.     t = t + 10
  50.     IF t > 255 THEN t = 20
  51.  
  52.     sz2 = sz2 + 1
  53.     IF sz2 < 10 THEN sz2 = 300
  54.     IF sz2 > 300 THEN sz2 = 10
  55.     IF m = 0 THEN
  56.         RANDOMIZE TIMER
  57.         monster = INT(RND * 500) + 1
  58.         IF monster > 498 THEN
  59.             m = 1
  60.             GOSUB monster:
  61.         END IF
  62.     END IF
  63.     IF m = 1 THEN
  64.         mon = mon + 1
  65.         IF mon > 50 THEN
  66.             LINE (290, 284)-(316, 316), _RGB32(0, 0, 0), BF
  67.             m = 0
  68.             mon = 0
  69.         END IF
  70.     END IF
  71. IF segment(seg2) = 1 THEN 'Right Door
  72.  
  73.     _PUTIMAGE (x + 50 + s, y - s - 50)-(x + 70 + s * 1.5, y + s + 50), doorr
  74.     FOR sz = s + 50 TO 10 STEP -1
  75.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 2, sz / 2, sz / 2), B
  76.     NEXT sz
  77.  
  78. IF segment(seg2) = 2 THEN 'Left Door
  79.     _PUTIMAGE (x - 70 - s * 1.5, y - s - 50)-(x - 50 - s, y + s + 50), doorl
  80.  
  81.     FOR sz = s + 50 TO 10 STEP -1
  82.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 2, sz / 2, sz / 2), B
  83.     NEXT sz
  84.  
  85. IF segment(seg2) = 3 THEN 'No Door
  86.     LINE (x - s, y - s)-(x + s, y + s), _RGB32(127, 255, 127), B
  87.     FOR sz = s - 1 TO 10 STEP -1
  88.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 2, sz / 2, sz / 2), B
  89.     NEXT sz
  90.  
  91. IF segment(seg2) = 0 THEN
  92.     LOCATE 30, 30: PRINT "You Beat The Tunnel!"
  93.     LOCATE 35, 30: INPUT "Press enter to end.", a$
  94.     END
  95.  
  96.  
  97.  
  98. GOTO go:
  99.  
  100. monster:
  101. RESTORE monsterdata:
  102. FOR my = 1 TO 13
  103.     FOR mx = 1 TO 13
  104.         READ cl
  105.         PSET (mx + 290, my + 290), _RGB32(0, cl * 100, 0)
  106.     NEXT mx
  107. NEXT my
  108.  
  109.  
  110.  
  111.  
  112. monsterdata:
  113. DATA 0,0,0,4,4,4,4,4,4,4,0,0,0
  114. DATA 0,0,4,4,4,4,4,4,4,4,4,0,0
  115. DATA 0,4,4,4,4,4,4,4,4,4,4,0,0
  116. DATA 0,4,4,4,4,4,4,4,4,4,4,0,0
  117. DATA 4,4,4,1,1,4,4,1,1,4,4,4,0
  118. DATA 4,4,4,4,4,4,4,4,4,4,4,4,0
  119. DATA 4,4,4,4,4,4,1,4,4,4,4,4,0
  120. DATA 4,4,4,4,4,1,1,4,4,4,4,4,0
  121. DATA 0,4,4,4,4,4,4,4,4,4,0,0,0
  122. DATA 0,0,4,4,1,1,1,1,4,4,0,0,0
  123. DATA 0,0,4,4,4,4,4,4,4,4,0,0,0
  124. DATA 0,0,4,4,4,4,4,4,4,4,0,0,0
  125. DATA 0,0,4,4,4,4,4,4,4,0,0,0,0
  126.  
  127.  
doorr.jpg
* doorr.jpg (Filesize: 5.16 KB, Dimensions: 70x359, Views: 298)
doorl.jpg
* doorl.jpg (Filesize: 5.18 KB, Dimensions: 70x359, Views: 321)
« Last Edit: July 19, 2019, 07:44:22 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #23 on: July 19, 2019, 02:19:35 pm »
I'm back at working with this game. This morning I was able to add the ability to go through the doors :). It doesn't show the doors opening or anything but you use the left and right arrow keys to go to a different tunnel by going through them when you see them. The tunnels also change colors as you go through the doors so you know you are in a different tunnel. I think I'm going to make this into a little 3d shooter game of some kind. Maybe have the monster shoot at you or something. Or shooter / RPG dungeon game. Now that I got the doors out of the way, I can add pretty much anything! :))

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #24 on: July 19, 2019, 07:36:19 pm »
I finished the game! It's self explanatory on the front page. Tell me what you think everyone :).
You also have to use the 2 door picture files I will put again as attachments to this post. So I suggest putting the game and 2 door pictures in its own folder. I did decide to make a different monster to make him larger and easier to see.
It's mostly another random game, except you have to shoot the monster before he shoots you. You also can run from the monster by entering any of the doors to another tunnel.
Have fun!

Code: QB64: [Select]
  1. 'Ken's Tunnels
  2. 'Made by Ken G.
  3. 'Thank you to B+ for his example on QB64.org forum!
  4. 'Other files needed for this game: doorl.jpg, doorr.jpg
  5. '
  6. 'This game makes a rnadom dungeon before you start, so every game will be different.
  7. 'Use the up arrow key and the left and right arrow key to move forward and through the doors on the sides.
  8.  
  9. _TITLE "Ken's Tunnel - Use Up and Left and Right Arrow Keys To Move and Space Bar."
  10.  
  11. begin:
  12. DIM segment(500)
  13. SCREEN _NEWIMAGE(600, 600, 32)
  14. PRINT "                           K e n ' s   T u n n e l s"
  15. PRINT "                                 By Ken G."
  16. PRINT "Use the arrow keys up, left, and right to move forward and into the next"
  17. PRINT "tunnels on the left or right doors."
  18. PRINT "Use the Space Bar to fire at the monster ahead of you."
  19. PRINT "You can dodge the monster by going into any of the doors."
  20. PRINT "If you see a door anywhere on your screen, you can use it."
  21. PRINT "The object of the game is to finish the tunnels without losing the game."
  22. PRINT "To end anytime, press the Esc key."
  23. PRINT "Every game is different!"
  24. PRINT "Be ready as soon as it starts!"
  25. INPUT "Press Enter to start game.", a$
  26.  
  27. x = 300: y = 300: t = 50
  28. s = 20
  29. sz2 = 10
  30. seg2 = 1
  31. lives = 10
  32. m = 0
  33. mon = 0
  34. points = 0
  35. tu = 0
  36. 'Load tunnel into memory.
  37. length = INT(RND * 15) + 25
  38. tunnel:
  39. rt = INT(RND * 100) + 1
  40. tu = tu + 1
  41. IF rt < 25 THEN
  42.     segment(tu) = 1 'Right Door
  43. IF rt >= 25 AND rt < 50 THEN
  44.     segment(tu) = 2 'Left Door
  45. IF rt >= 50 THEN
  46.     segment(tu) = 3 'No Door
  47. IF tu = length THEN GOTO starttunnel:
  48. GOTO tunnel:
  49.  
  50. starttunnel:
  51. GOSUB drawtunnel:
  52.  
  53.  
  54. doorl = _LOADIMAGE("doorl.jpg", 32)
  55. doorr = _LOADIMAGE("doorr.jpg", 32)
  56.  
  57. go:
  58. _LIMIT 400
  59. a$ = INKEY$
  60. IF a$ = CHR$(27) THEN END
  61. IF a$ = CHR$(0) + CHR$(72) THEN
  62.     os = s
  63.     s = s + 5
  64.     IF s < 10 THEN s = 300: seg2 = seg2 - 1
  65.     IF s > 300 THEN s = 20: seg2 = seg2 + 1
  66.     t = t + 10
  67.     IF t > 255 THEN t = 20
  68.  
  69.     sz2 = sz2 + 1
  70.     IF sz2 < 10 THEN sz2 = 300
  71.     IF sz2 > 300 THEN sz2 = 10
  72.     IF m = 0 THEN
  73.         RANDOMIZE TIMER
  74.         monster = INT(RND * 500) + 1
  75.         IF monster > 495 THEN
  76.             m = 1
  77.             GOSUB monster:
  78.         END IF
  79.     END IF
  80.     IF m = 1 THEN
  81.         mon = mon + 1
  82.         IF mon > 50 THEN
  83.             LINE (285, 284)-(316, 316), _RGB32(0, 0, 0), BF
  84.             m = 0
  85.             mon = 0
  86.         END IF
  87.     END IF
  88.  
  89. IF m = 1 THEN
  90.     monstershoot = INT(RND * 1000) + 1
  91.     IF monstershoot > 998 THEN
  92.         SOUND 800, 1
  93.         FOR blast = 3 TO 26 STEP 1
  94.             CIRCLE (300, 300), blast, _RGB32(127, 255, 127)
  95.             _DELAY .01
  96.             CIRCLE (300, 300), blast, _RGB32(0, 0, 0)
  97.         NEXT blast
  98.         lives = lives - 1
  99.         GOSUB monster:
  100.         SOUND 400, 1
  101.         SOUND 300, 2
  102.         SOUND 200, 2
  103.         SOUND 100, 3
  104.         points$ = STR$(points)
  105.         lives$ = STR$(lives)
  106.         _TITLE "Ken's Tunnels            Score:" + points$ + "             Lives: " + lives$
  107.         IF lives < 1 THEN
  108.             LOCATE 20, 30: PRINT "G A M E     O V E R"
  109.             LOCATE 23, 30: PRINT "Score:"; points
  110.             LOCATE 25, 30: INPUT "Play Again (Yes/No)?", ag$
  111.             IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "yes" THEN GOTO begin:
  112.             END
  113.         END IF
  114.     END IF
  115.     points$ = STR$(points)
  116.     lives$ = STR$(lives)
  117.     _TITLE "Ken's Tunnels            Score:" + points$ + "             Lives: " + lives$
  118.  
  119.  
  120. IF a$ = CHR$(0) + CHR$(77) AND segment(seg2) = 1 THEN
  121.     cl = INT(RND * 200) + 1
  122.     cl2 = INT(RND * 200) + 1
  123.     cl3 = INT(RND * 200) + 1
  124.     LINE (285, 284)-(316, 316), _RGB32(0, 0, 0), BF
  125.     m = 0
  126.     mon = 0
  127.     GOSUB drawtunnel:
  128.  
  129. IF a$ = CHR$(0) + CHR$(75) AND segment(seg2) = 2 THEN
  130.     cl = INT(RND * 200) + 1
  131.     cl2 = INT(RND * 200) + 1
  132.     cl3 = INT(RND * 200) + 1
  133.     LINE (285, 284)-(316, 316), _RGB32(0, 0, 0), BF
  134.     m = 0
  135.     mon = 0
  136.     GOSUB drawtunnel:
  137.  
  138. IF a$ = " " THEN
  139.     SOUND 100, 1
  140.     FOR blast = 25 TO 3 STEP -1
  141.         CIRCLE (300, 300), blast, _RGB32(255, 6, 0)
  142.         _DELAY .01
  143.         CIRCLE (300, 300), blast, _RGB32(0, 0, 0)
  144.     NEXT blast
  145.     IF m = 1 THEN
  146.         SOUND 100, 1
  147.         SOUND 200, 2
  148.         SOUND 300, 2
  149.         SOUND 400, 3
  150.         LINE (285, 284)-(316, 316), _RGB32(0, 0, 0), BF
  151.         m = 0
  152.         mon = 0
  153.         points = points + 100
  154.         points$ = STR$(points)
  155.         lives$ = STR$(lives)
  156.         _TITLE "Ken's Tunnels            Score:" + points$ + "             Lives: " + lives$
  157.     END IF
  158.  
  159. nex:
  160.  
  161. IF segment(seg2) = 1 THEN 'Right Door
  162.  
  163.     _PUTIMAGE (x + 50 + s, y - s - 50)-(x + 70 + s * 1.5, y + s + 50), doorr
  164.     FOR sz = s + 50 TO 20 STEP -1
  165.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 5 + cl, sz / 6 + cl2, sz / 7 + cl3), B
  166.     NEXT sz
  167.  
  168. IF segment(seg2) = 2 THEN 'Left Door
  169.     _PUTIMAGE (x - 70 - s * 1.5, y - s - 50)-(x - 50 - s, y + s + 50), doorl
  170.  
  171.     FOR sz = s + 50 TO 20 STEP -1
  172.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 5 + cl, sz / 6 + cl2, sz / 7 + cl3), B
  173.     NEXT sz
  174.  
  175. IF segment(seg2) = 3 THEN 'No Door
  176.     LINE (x - s, y - s)-(x + s, y + s), _RGB32(127, 255, 127), B
  177.     FOR sz = s - 1 TO 20 STEP -1
  178.         LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 5 + cl, sz / 6 + cl2, sz / 7 + cl3), B
  179.     NEXT sz
  180.  
  181. IF segment(seg2) = 0 THEN
  182.     LOCATE 21, 30: PRINT "You Beat The Tunnels!"
  183.     LOCATE 23, 30: PRINT "Score:"; points
  184.     LOCATE 25, 30: INPUT "Play Again (Yes/No)?", ag$
  185.     IF ag$ = "y" OR ag$ = "Y" OR ag$ = "YES" OR ag$ = "yes" OR ag$ = "yes" OR ag$ = "yES" OR ag$ = "yeS" OR ag$ = "yes" THEN GOTO begin:
  186.     END
  187.  
  188.  
  189.  
  190. GOTO go:
  191.  
  192. monster:
  193. RESTORE monsterdata:
  194. FOR my = 1 TO 16
  195.     FOR mx = 1 TO 30
  196.         READ cll
  197.         PSET (mx + 285, my + 290), _RGB32(0, cll * 250, 0)
  198.     NEXT mx
  199. NEXT my
  200.  
  201.  
  202. drawtunnel:
  203. FOR sz = s TO 300
  204.     LINE (x - sz, y - sz)-(x + sz, y + sz), _RGB32(sz / 5 + cl, sz / 6 + cl2, sz / 7 + cl3), B
  205. NEXT sz
  206. segment(seg2) = 3
  207.  
  208.  
  209.  
  210.  
  211. monsterdata:
  212. DATA 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
  213. DATA 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
  214. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0
  215. DATA 0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0
  216. DATA 0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0
  217. DATA 0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0
  218. DATA 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
  219. DATA 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0
  220. DATA 0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0
  221. DATA 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0
  222. DATA 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0
  223. DATA 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0
  224. DATA 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0
  225. DATA 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0
  226. DATA 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
  227. DATA 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
  228.  
  229.  
  230.  
doorr.jpg
* doorr.jpg (Filesize: 5.16 KB, Dimensions: 70x359, Views: 304)
doorl.jpg
* doorl.jpg (Filesize: 5.18 KB, Dimensions: 70x359, Views: 294)
« Last Edit: July 19, 2019, 07:43:10 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #25 on: July 20, 2019, 06:18:12 pm »
It's been a little over 1 month now since I started using QB64. June 20 was when I completed Ping Pong 2 which was my first game on QB64. So I want to thank you all for encouraging me to keep programming and making apps and games with this language. It has been a wild ride and has kept me busy. Thank you!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #26 on: July 20, 2019, 06:43:39 pm »
It's been a little over 1 month now since I started using QB64. June 20 was when I completed Ping Pong 2 which was my first game on QB64. So I want to thank you all for encouraging me to keep programming and making apps and games with this language. It has been a wild ride and has kept me busy. Thank you!

I like your enthusiasm and your ability to turn even this little bit of tunnel code into a game, excellent start!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #27 on: July 20, 2019, 06:59:28 pm »
Thanks B+! Maybe soon I'll think of something else to make. lol

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #28 on: July 21, 2019, 01:12:35 pm »
It's been a little over 1 month now since I started using QB64. June 20 was when I completed Ping Pong 2 which was my first game on QB64. So I want to thank you all for encouraging me to keep programming and making apps and games with this language. It has been a wild ride and has kept me busy. Thank you!

Just like you, I joined (relatively) recently; last year about this time, and have been like a kid in a candy store with QB64. There's so much more power at your fingertips than QuickBasic 4.5 could muster, and no more DOS emulators, as fine as they were. It's cool to see someone else discovering it.

I note that you mentioned MOD earlier. That's one that I never paid attention to before, but recently discovered wields a lot of utility once you get to know it, it greatly simplified several display tools in my space vector plotter. A 20+ year old program which was DOA until QB64 brought some bigger variable ranges to the table.

Great job on the game, keep 'em comin'.

PS... I was thinking that you could _PUTIMAGE the monsters face and have it grow in perspective size as it comes down the tunnel...just a thought to challenge you with. ;)

PPS  You know, you never really "finish" a game. You just put out there and let it roll until you can come back with new and better tools to upgrade it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: 3D Tunnel Lines Demonstration
« Reply #29 on: July 21, 2019, 04:44:16 pm »
LOL That's true about games or programs, you never really finish them. I haven't used this version of MOD yet, but it's funny you bring that up because right now I'm working on a VERY simple Space Invaders like game, which I am converting from an ASIC 5.0 language one I did back in the 90's and I used MOD in a different way back then, with RND, but I still don't know exactly why, I can't remember why I used it. Had something to do with the range of random numbers to pick from. Maybe ASIC's MOD was different than QBasic, or maybe not, I can't tell, but it's not important. Actually, the more I think about it, I think it used RND with MOD by picking a random number between 0 and 1 and then getting the MOD of that and then I timed that by the number I wanted the range to be in. I think that's what I did.