raycaster games

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:

I might be able to do this but I’m not sure. the most advanced thing I’ve done in flowlab is an auto tile bundle.

@TinkerSmith OK. I saw the words “Amiga Demo Reel” above and now I know we’ve got to get together on something. I cut my teeth on Deluxe Paint 4 and my college “demo reel” is on a VHS tape. LOLOL!

Also, I DO like coding challenges like this (although this one might be a little outside my skill range), but my head it too full of excitement for Flowjam 2020 to focus on anything else for the moment.

LOL @todorrobot , how small is the world :slight_smile:
Ex member of Destiny Seven here, subdivision of RSI.
2 or 3 of our demos are on Youtube, sadly not our best ones :frowning: , but i think you find the rest in the Amiga archives.
BLITTER RULES WHOOP WHOOP

… now you know where I learned to throw text over the screen, HAHA
Maybe we should convert one of the demos to Flowlab and throw in some cool Soundtracker mods :slight_smile:

I’m super excited for flowjam too @todorrobot

hey @TinkerSmith if we have the raycasts ouputting a number, what if we assign each raycast to a sliver of colour on screen and depending on how far the raycast goes, the sliver is shorter or longer. thought it might be a cool test. unless that’s what you’re trying already. I think I know how to do this if the rest is done. (outputting the number) maybe into a global number?

Hiya @F3Art ,
got any visual example about those slithers?
I hav to admit my head is not awake enough yet to follow :slight_smile:

Hey @TinkerSmith I have been fiddling around with these ideas for a while. The best way I can see doing it is exactly what @grazer said, but didnt think was possible. Let me explain.
He said since there was no way to edit every pixel at a synchronized time for your purposes, since they are bundled in blocks, it would be impossible. My solution: Make every block 1 pixel!
Blocks automatically adjust hitbox size to their sprite size. So, if you wanted a rayscast that’s accurate, use a spawn and/or position block to line the sides of walls with 1 pixel wide blocks.

Yes @TinkerSmith I have a bit of a prototype based on your raycast test. Ill send a link later.

Sweet :slight_smile:

The more examples we get the better. Even failed ones help … others to avoid them.
If you know what I’m saying.

@TinkerSmith
I had trouble with getting the protototype to work, but i have an image for the idea.

https://www.pixilart.com/art/3d-idea-10790a9cf423b48?ft=new&ft_id=

i was thinking that every raycast would be assigned to a number and it would output a number based on how close the wall is. only problem is that i"m not sure how i would turn how close the wall is into the y size of the screen blocks/slivers.

Hi there @F3Art

Good on you :slight_smile: … as in, not taking examples as they are, investigate and put your own thoughts to it.
Best way of learning actually. Most things I learn by taking other stuff apart and by trying to follow/recreate the thought process.

Regarding your idea:
If you look closely into the example you will notice that each ray actually has it’s own ID = it has a number assigned. I did that for exactly the same reasons you were thinking of.

Now, about the distance to the wall, here we have a little problem. The RayCast in Flowlab does not work exactly as we would wish for the needs here. It does not give you the distance to the side/wall it hit, it gives you the distance to the center arc of the object hit. Thats why it looks like a fan in the example.
For simple fake 3D that might be good enough. For more accurate results you would need to know at least the 4 corner points of the sides in question. (For example if you would want to do it like in the skew example).

Even so, with a bit of fiddling around, at least one can identify the object hit:
https://flowlab.io/game/play/1450332

So what we got:

  • we know our own (player) position
  • we know the obstacle position
  • as in, we have access to the (center) distance and the angle

What to do with that? You have to consult the mighty gods of Trigonometry, Sinus, Cosinus and sometimes auntie Tangent :slight_smile: Or other related Vector maths.
It all depends on what you try to achieve.

@TinkerSmith Thats cool! Sorry I havent been much help on the coding side of things, but I dont have as much experience that you have.

Ill try to help more with what I can.

So if the vector line changes its x axis based on hitting the center of an object, and the object is able to react to this, could we make (lets say a 2d tree sprite) change its size based on how far the line is stretching? If so what type of calculation would we use? Im guessing this would use a lot of global numbers and expressions.

What I mean is maybe its better to see if we can use what we have already to try to make a single object in a fake 3d space before moving on to full walls. Might be a good start. One thing I cant quite figure out is how to make it move sideways based on where the player is looking.

Hiya @F3Art :slight_smile:

Simplest one would be like the example @murten101 did:
3D World

Move sideways? As in tilted? Like in the skew example?
Skew This

That would be possible, but quite the task :slight_smile:

@TinkerSmith woah i didn’t know somebody had already done something like raycasted walls. I might be able to use that for what i was thinking of making. I’d like to make it a bit better still, but it’s a REALLY good start. what i meant by moving sideways is just the object (like a tree) moving in and out of view based on where the player is looking.

i can probably copy the code of the walls in 3D world and just change a few things.

@murten101’s 3D world is close to what I was thinking from that doodle. I haven’t actually snooped in the code yet but it works on the outside how i was thinking.

Glad we found something that gives you a start and looking forward to see what you are comming up with @F3Art :slight_smile:
Let me know if you get stuck.