raycaster games

Uhhh, raycasting, one of my favorites tempting
Yes, stretchy columns for the ouput is easy, not sure if Floblab is fast enough.
Another option (pokes @grazer) could be if our allmighty developer would grant us another image behaviour: Skew

That one works fine for good old Wolfenstein/Doom style 3D faking.
Not sure how Flowlab is built and what libaries it might be using for the gfx, but it is a quite common function, now even in HTML.
Would that be a difficult request @grazer? I can see many uses for it.

And the 3D demos @MagmaDude100 mentioned are propably the ones from @Wizardry . But they seem to be broken now.

thats a cool idea @TinkerSmith I didn’t think of that

Uffff, I think Flowlab’s raycast is not precise enough.

As you can see it seems to pick a nearly random spot within the hit target. To make fake 3D you would need to know the exact wall intersection point.
So it is good enough to identify objects in the view field, but one would have to calculate the details separately pain
Can be done by what I see, I will further tinker around.
Hard without being able to use lookup tables or calculations with more than 2 inputs.
Is a bit sinus/cosinus/whatevernus involved and pushing the results from one expression to the other doesn’t work because the results are turned into integers.
So you have to multiply them by some factor, shove them to the next block, divide … calculate … pain, or maybe I’m just a spoiled little Tinker :slight_smile:
I already asked @grazer if there is a way to get more parameters into the expression block.

ACTUALLY, what I would need in this case is either a multiline expression block (easier to read what you do), OR even better a SCRIPT BLOCK :stuck_out_tongue:

Folks, suggestions please. Anyone came up with a better raycast solution yet?

Very cool @TinkerSmith! Do you mind sending a link for that?

I use to think we need like a laser pointer block and a target block for this idea,
but this looks really nice, well done.

wow @TinkerSmith If we could get your example working even better, we could have a whole other type of game on flowlab.

could this work for other in-game objects too? maybe the way DOOM does it where the objects are always facing towards you but they get bigger and smaller (or offscreen) depending on how close they are.

Update & correction.
I increased the ray count to 80 and realized that the number raycast returns is not random. It seems to calculate the radius from the cast origin to the target center and gives you the point where the ray hits this arc. Easy to see here:

@F3Art , letting the sprites always face you is the easy part, LOL. I have done Wolfenstein clones back in the ages for Amiga Demo reels. The 80 rays already slow down Flowlab, normally you would need to cast at least 200 to 300 … depending on your screen resolution :slight_smile:
But that can be optimized if you have the ‘math power’ behind you. I made one once where I actually only traced the edge points of the targets, that’s all you need to place your 3D fake.
Yeah, would be nice if we could achieve this:

P.S. actually. Since we work with a fixed cell map here it should be easy to just shorten the ray to the cell boundaries. Anyone here good with Vector Maths? I’m a bit rusty, haven’t done that for ages.

2 Likes

@“JR 01” , could you elaborate your laser/target block ideas?
Let’s start a brainstorm session :slight_smile:

how are you making your raycasts visible?

I use my Vector Line demo and give it the raycast angle and result as input :slight_smile:

Cool!

Another update, this time I wanted to see how Flowlab can handle to transform a sprite into fake 3D space (Skew style).

I am surprised, it seems to handle it rather well.
https://flowlab.io/game/play/1449889

In the demo you can also zoom in and out. Biggest flaw is the FOV error you see, but I expected that with my simplified routine. I leave it as it is and hope someone else will finish it :slight_smile:

If so I will continue with the raycast routine. Any takers?

One has to figure out a way how we can have multiple independent ones on the screen and how to push the information to them. By default possible, just tricky.

P.S. The Field Of View error shows because I did not implement perspective correction for the depth. I would have to change the scale ratio to make the back shorter and the front longer towards the view plane.

Tinker is on a whole new level of genius

Nah, just a lot of tinker experience @MagmaDude100

When I grew up the world was still black and white :slight_smile:

hey @TinkerSmith wow that skew thing is amazing!
also Calvin and Hobbes is great.

@TinkerSmith do you have a link for the “Update and Correction” example game?

@TinkerSmith @MagmaDude100
this game is basically the only time I’ve done a decently good 3d effect. you can only walk forwards and backwards though.
https://flowlab.io/game/play/1431918

Yes @F3Art , sure I have a link. How else would I get back in to edit it :slight_smile:

Ohhh, or do you mean if I would share it? ROFL
Nope … normally I don’t like to share links of demos that have a high tendency to crash, are unsorted and just a mess in general.

OK, OK, OK, … stop twisting my arm, here it is: Raycast Test

DISCLAIMER :
I take no responsibility for computer crashes and the mental damage it might cause when you loose your favorite files. I also take no responsibility for any radiation damage caused by the extensive use of rays. Wear proper safety equipment and keep a minimum distance of 2 arms length to the computer!
Actually I’m working on a different version, so have fun. The way I approached it might give you ideas for your own game development. Basically I did the same as I did for the ‘Skew’ demo, I gave each spawn it’s own ID and made them independent smart units.

Note to @grazer, any chance of being able to identify and address spawns by their ID? Like with the raycast, if it would also hand back the target ID … I would give you one big hug :slight_smile: … maybe TWO

P.S. … before I get the question, YES, part of the routines can be used to make a grapple hook :tongue:

Now that I released the link, what about a little coding challenge?
It’s always a good exercise to challenge yourself :slight_smile:

Task 1:
Change the ray length calculation so that it stops at the target wall.
The part to change is in the ray behavior, see here:
ray_length
Hint: Remember it is a grid based map with a fixed cell size of 32x32 … ‘mod’ it up folks :slight_smile:

Task 2:
Extend the code so that it highlights the hit targets like so:
ray_02
Yep, that really challenges your Flowlab knowledge :slight_smile:

Any takers?
You like coding challenges like this?

What if you just change the Layer order of the Wall blocks?
This way they would always be above the raycasts Ahah. @TinkerSmith

Shhhhh @PixelPizza , you little cheat :slight_smile: :slight_smile: :tongue: