Raycasting

A forum to share your demonstrations stacks, fun stacks, games, etc.
Post Reply
User avatar
OpenXTalkPaul
Posts: 1657
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Raycasting

Post by OpenXTalkPaul »

Here's an interesting article about raycasting (not to be confused with raytracing).
This is fake 3D method behind early first person shooters, Wolfenstein, Doom, etc.
https://lodev.org/cgtutor/raycasting.html
And another:
https://permadi.com/1996/05/ray-casting ... -contents/

I think something like that could be rendered by libSkia in a Widget.
Writing it would be a bit of work.

It's also an exercise a bit like reinventing the wheel.
We could probably use Doom engine itself since that was open sourced like 27 years ago.
https://www.chocolate-doom.org/wiki/ind ... evelopment
Here's an article with a breakdown on an HTML5 version (which maybe we could use inside a Browser Widget)

Probably a better use of time would be finding a small game engine or parts of one, that's available in a shared library form, preferably has a basic C APIs, that wouldn't be a huge task to get at least some of it working using FFI binding strings and either rendered in a Widget or use FFI to make a new window for game engine to render to.

I think we should build up our own collection wrapped-up extension libraries and generic template game assets and such that we can use. OXT should have the capabilities of something like PyGame (actually we already have some of PyGames features available for our xTalk. or with The OXT HIDAPI extension for joystick stuff. Get a GameJam sort of thing going.
xAction
Posts: 285
Joined: Thu Sep 16, 2021 1:40 pm
Contact:

Re: Recasting

Post by xAction »

Funny you should mention it, I just read that part of the 9 games book, after all these years, only to be let down by zero explanation on how the whole thing works. So I sat down with chatGPT and commented as much of the stack's card script as I could.
xTalk_Raycasting_101_02_2024_NewMap.oxtStack
(79.27 KiB) Downloaded 21 times
RayCast.png
RayCast.png (7.14 KiB) Viewed 120 times
Removed the starting screen/card. Gameplay stops on escape key (sometimes) and will switch to pointer tool.

I removed the spiders and goofy spray can so I could focus fixing or cloning the ray cast stuff.
Then I realized I'd need the 'spray can' later for weapons...it's in the script just all commented out with ---IMAGE--- to let you know the images are turned off.

Was going to post the comments to a thread, like this one, but wow, those got LONG.
How can we script-o-matically change the style of the comments in the IDE to focus on reading comments when we want to.
They are so "ignore me I'm just a comment" now.

I redid the map to try to figure out what is going on in that thing. The 'rendering engine" hates big rooms and tight turns.

I agree, finding at way to fire up another 'game engine' or library from xTalk would work better than trying to reinvent everything in xTalk. If we were 10,000 typing monkeys maybe it would work, but we maybe 10, if that.

Interesting idea to port DOOM...it runs on absolutely everything, so it should totally be doable.
User avatar
OpenXTalkPaul
Posts: 1657
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Recasting

Post by OpenXTalkPaul »

xAction wrote: Wed Feb 21, 2024 7:42 am I redid the map to try to figure out what is going on in that thing. The 'rendering engine" hates big rooms and tight turns.

I agree, finding at way to fire up another 'game engine' or library from xTalk would work better than trying to reinvent everything in xTalk. If we were 10,000 typing monkeys maybe it would work, but we maybe 10, if that.
Cool thanks, I was meaning to go back and look at that stacks to see how they worked it out.

Yeah, I think it would be a lot of work and hours tweaking scripts to make a decent game, even a 2D game , that has lots of sprites, with our current Engine as it is now. I mean beyond simple 2D graphics like Wordle or Tetris.

The Cairo graphics used to render card/stack surfaces is old and kind of slow, but libSkia used as the rendering engine for widgets seems to be significantly;y faster for some things, perhaps because its doesn't need to create bunches of large graphic controls that are scriptObjects with lots of properties vs. using a Widget extension with the script engine where it's a single scriptObject.

The Engine has two threads one that is for running scripts and the main loop thread that is used for rendering user interface.
IIRC Widgets run on the UI thread, so that probably helps prevent the Engine lagging out from too many messages being passed around.

I'm not trying t port Wolfenstein or Doom to OXT (although that would be cool), I just was curious about how they manage it on much more limited hardware then what's commonly around today. What I might try to do is that port is Tunnel Runner, because it's simple maze game (and fun IMO). Someone did make a computer port version of that a long time ago.
xAction
Posts: 285
Joined: Thu Sep 16, 2021 1:40 pm
Contact:

Re: Recasting

Post by xAction »

Ugh...auto log out, you are the bane of me!
Lost my whole post again. ...bla bla bla.
Yeah there's a decent Tunnel Runner clone on ZX80 Spectrum, with a giant custom ascii art t-rex like the Dungeon Master boss. Looks amazing in screenshots, plays like..oh, like an 8 bit computer with plastic membrane keyboard.

Tunnel Runner benefits from a static camera, you won't run into clipping planes or distorting geometry beyond the ability to see it. Very probably you can predefine views like:
Tunnel_leads_left_3_units_from_player since there are only so many variations in the static camera tunnel.
Maybe wouldn't even have to specify the units, just do some math an a preset graphic.

What if we changed the current ray cast method of using x number of objects for each grid point of depth in the tunnel to combining them into one object and faking the depth with gradients?

Probably not. But I always wanted to make a game in Illustrator using Postscript, or QuarkXpress using ...ew.javascript. lol.
Fake3DwithGradient_2.oxtStack
(2.81 KiB) Downloaded 18 times
gradienttunnel.png
gradienttunnel.png (8.37 KiB) Viewed 94 times
User avatar
OpenXTalkPaul
Posts: 1657
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Recasting

Post by OpenXTalkPaul »

xAction wrote: Fri Feb 23, 2024 3:46 am Tunnel Runner benefits from a static camera, you won't run into clipping planes or distorting geometry beyond the ability to see it. Very probably you can predefine views like:
Tunnel_leads_left_3_units_from_player since there are only so many variations in the static camera tunnel.
Maybe wouldn't even have to specify the units, just do some math an a preset graphic.
Exactly, it's very simple single point perspective drawing, and that's the way I was planing to approach it, with predefined shapes to make up the walls of the hallways.
SinglePointPerspective.jpg
SinglePointPerspective.jpg (36.82 KiB) Viewed 73 times
I've already mocked it up in illustrator with vector shapes on layers.
AllWalls.jpg
AllWalls.jpg (32.96 KiB) Viewed 73 times
Then from there, with the help of vector editing skills (and Illustrator's Pathfinder palette), you can get to shapes on layers which can then be exported to SVG to get the path strings for those shapes into our IDE.
Openings&Walls.jpg
Openings&Walls.jpg (50 KiB) Viewed 73 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest