Author Topic: Rat Runner for Maze Maker  (Read 6611 times)

Mike Lobanovsky

  • Guest
Re: Rat Runner for Maze Maker
« Reply #15 on: June 18, 2018, 05:03:05 PM »
I used to experiment with ray casting a lot. It's usually quite easy to implement collision detection in it so that you wouldn't fall through the walls whenever you run into them and thus you wouldn't wander into the areas that aren't defined by the maze. (Fig.1 below).

But the real adventure starts when you disable collision detection (or happen to occasionally fall through due to imperfect emulation of wall solidity in simple collision detection algos) and do go beyond the maze outer wall! Then, depending on whether your BASIC has been compiled with a C (or Asm) compiler that can handle floating-point infinities and NaNs gracefully rather than throw an FPU divide-by-zero exceptions, you can enter the world of objects that really aren't there on your maze map! :D

You can see objects of strange patterns and colors that weren't there in your original palette (Figs.2 and 3), or objects that are mutually orientated at angles different than purely orthogonal (Figs.4 and 5).

And in certain cases, if you have enough free system memory, you can come across wide spaces where your virtual (undefined!) maze extends as far as, and possibly beyond, your visible horizon (Fig.6)! You can't however reach the far distant wall; your app will crash somewhere in the middle of the passageway. :D

B+

  • Guest
Re: Rat Runner for Maze Maker
« Reply #16 on: June 18, 2018, 06:35:37 PM »
Ah Mike! Welcome to the Matrix!  ;D

ScriptBasic

  • Guest
Re: Rat Runner for Maze Maker
« Reply #17 on: June 19, 2018, 01:57:41 AM »
Here is an article that teaches you how to build 3D mazes in JavaScript / CSS.

https://www.sitepoint.com/art-science-javascript/
« Last Edit: June 19, 2018, 02:08:27 AM by John »

B+

  • Guest
Re: Rat Runner for Maze Maker
« Reply #18 on: June 19, 2018, 12:33:45 PM »
SmallBASIC sample is 286 lines, started by Rick:
Code: [Select]
'Raycaster with definekey.bas for SmallBASIC 0.12.6 [B+=MGA] 2016-06-17
' Raycaster maze Ricks copy from SB 2016-06-17
' MGA modified with definekey all inkey stuff removed
' still quits with esc and now q

' uses a simple ray casting technique (see lodev.org for tutorial) to draw
' vertical stripes down the graphics window.

' Each stripe is drawn to a size dependent upon the distance of the wall from the viewer.
' "Rays" are cast across a viewing plane in front of the viewer, from left to right.
' the height of the wall stripe depends on the distance of the wall from the viewer.

'InitialSetup
' set up screen width and height
' values also used to determine the width and height of the "viewing plane"
' "size" is used to determine the width of each vertical line drawn.
' a smaller value makes the walls sharper, but draws slower (there are more lines)
' a larger value makes the walls blockier, but draws more quickly

'these replace INKEY catching
definekey 0xFF04, moveLeft    'press left arrow or ccw
definekey 0xFF05, moveRight   'press right arrow or cw
definekey 0xFF09, moveForward 'press up arrow, forward
definekey 0xFF0A, moveBack    'press down arrow, back
definekey 0x0071, quit        'press q
definekey 0x001B, quit        'press esc

but maze generator was not built into it.
« Last Edit: June 19, 2018, 12:35:19 PM by B+ »