I’ve been interested recently by a method of game making called raycasters. it’s a top down game that fires raycasts, and creates shapes on screen by measuring the distance between the player and an object. a good example of this is wolfenstein 3d. I’m wondering if this is possible with flowlab. measuring the distance from something with a raycast, or maybe proximity?
Hey @F3Art - I’m really fond of raycasters like Doom and Comanche.
That being said, I think it would be pretty tricky to try and do this inside of Flowlab currently. The casting/calculation part would probably be possible, but I think it’s the rendering that would be tricky. Raycasting engines typically draw one vertical pixel column at a time to fill the screen. There isn’t an obvious way that I see to do that within Flowlab, since it doesn’t provide a way to draw every pixel of the screen.
If you really wanted to try it, maybe you could do it with tall thin sprites that stretch to be used for the columns? I dunno, it would be tricky
or maybe using an emmitable object and tracking how long it takes to hit something?
let me know what you think.
I’ve seen it be done before but i don’t remember the link nor the name of the game
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
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
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
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.
@“JR 01” , could you elaborate your laser/target block ideas?
Let’s start a brainstorm session
how are you making your raycasts visible?
I use my Vector Line demo and give it the raycast angle and result as input
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
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
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