Excellent!!!
I found mine, but is far away from yours.
After finishing the sprites, please implement floor casting... as far as I remember I couldn' make it.
Best regards
JF
Working Raycasting example! WolfenLöve 3D if you will...
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Working Raycasting example?
What's floor casting? I assume it means put textures on the floor. I don't know how easy that would be since Löve can't manipulate (warp) an image's corners to an odd non-parallelogram shape. If it could, we'd be able to do so much more 3D stuff. For now the floor will have to be solid colored. (Static that is. In that it never changes)
Also, yours looks pretty good too. What's wrong with it?
Anyway, a few bugs right now. But thankfully nothing seriously extreme like a Cool Ranch Dorito.
Also, yours looks pretty good too. What's wrong with it?
Anyway, a few bugs right now. But thankfully nothing seriously extreme like a Cool Ranch Dorito.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Working Raycasting example?
Oh, like that.Jasoco wrote:The ONLY way to get sprites to show up in the right order is to have them sort themselves by how far they are. And in order to make them also sort behind walls you need to add every strip of the wall to the same table. Then sort the table so the far wall strips, far sprites all draw in order from far to near.
How did you end up implementing it?
I would have either made a table of indices and sort that or change the indices to 1 to n.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Working Raycasting example?
It all fell into place when I figured out certain things. Right now, each sprite and each strip is placed into a table with a Z value of their distance from the player. The wall pieces are added first. This fills up 0 through the number of strips - 1, then the sprites are added at the end. Next they're sorted by Z. Then it draws each "object" in the "drawPool" in the order they are sorted into.
Then I use a simple:
It works for me. I know you say it's not trustworthy or reliable, but why would it exist if it isn't?
Knock on wood that I don't find a speed bump that totally ruins it.
I want to experiment with lighting. Maybe figure out a way to actually put lighting on the floors and draw the floor as a grid at least so I can make each one a different light level. Maybe get some pseudo lighting effects.
Then I use a simple:
Code: Select all
table.sort(T, function(a, b) return a.z < b.z end)
Knock on wood that I don't find a speed bump that totally ruins it.
I want to experiment with lighting. Maybe figure out a way to actually put lighting on the floors and draw the floor as a grid at least so I can make each one a different light level. Maybe get some pseudo lighting effects.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Working Raycasting example?
Huh? The only problem I have with that is that table.sort only looks from index 1 to #T, so T[0] stays at the zeroth index, no matter its z-index.Jasoco wrote:It works for me. I know you say it's not trustworthy or reliable, but why would it exist if it isn't?
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Working Raycasting example?
Okay. Good. That's probably why it works. I made sure to throw everything into the pool in order without gaps. Hooray for me!Robin wrote:Huh? The only problem I have with that is that table.sort only looks from index 1 to #T, so T[0] stays at the zeroth index, no matter its z-index.Jasoco wrote:It works for me. I know you say it's not trustworthy or reliable, but why would it exist if it isn't?
Here's a new shot.
> In this one you can see a sort of lighting effect. I made it so you can set an ambient "fog" for distant objects where the further away the darker they are. If you set the light high, it's barely noticable. Set it low and things get dark fast.
> I also made it so sprites have an "illumination" flag that causes them to be 100% bright no matter how far they are. I set it to the lamp in this shot.
> I also made it so textures can be much bigger. I resized the walls to 128x128 pixels, but kept them nearest neighbor just so I could put a double-resolution image of Kate there. OBEY HER! (Yes, I am aware I am technically making Kate Hitler here given the context of the graphics used. Pure coincidence, I swear. It was either her or me.)
Still TODO:
> Make it so blocks can have different images on each wall. Wolfenstein didn't even have this. But it would be nice. Note that Kate's block only has her on one side, this is because she only shows up on the Horizontally facing walls, but not the Vertical because each wall texture is split into two parts. One being darker than the other. I simply removed the painting from the darker part.
> Enemies of course. Need to make sure moving objects that aren't on a whole tile still index correctly. They're also going to be harder since currently the game uses a Sprite Grid and only one Sprite can be in a square at once. I'll have to do some fidgeting to figure out how to change it so sprites can overlap.
> More lighting. I want to make it so once I have a hand with a gun or weapon showing, it becomes darker or lighter if I step over a non-solid sprite with the illumination flag set. Also make it so map grid can have lighting flags too that would affect the walls touching it and the objects inside.
> DOORS and SWITCHES and SCRIPTS POSSIBLY!
> Give the player and enemies a radius. Right now the collision detection thinks the player is 1 pixel in size. That make it so you can move right up against a wall or sprite and makes things look weird. Gotta give it a radius of maybe .4 so it takes up 80% of a tile and can still move around. Maybe .3. We'll see.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Working Raycasting example?
As a suggestion for your z-ordering, it's probably easier to keep a sorted list around and insert in the right place than to sort the same list over and over every frame. Or do a full sort, but only in frames in which something changed, should help a lot.
Re: Working Raycasting example?
When will you make LÖVECraft?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Working Raycasting example?
There's a big difference between Wolfenstein and MineCraft. In that Wolfenstein is very simple in comparison to the hundreds of thousands of blocks you have to process on every screen every frame in MC. Löve isn't that fast. At least not right now. Plus it doesn't have the right image manipulation functions to do it like Java does. (I wish it did. I want to warp an image to my will!)Nixola wrote:When will you make LÖVECraft?
Things change every frame if you move even a pixel. So it's not really as useful as it would be in a game where the map is static.bartbes wrote:As a suggestion for your z-ordering, it's probably easier to keep a sorted list around and insert in the right place than to sort the same list over and over every frame. Or do a full sort, but only in frames in which something changed, should help a lot.
Right now I get a pretty good framerate even with 640 wall slices.
Semi-related note: Here's a neat video of the original Wolfenstein running on an Apple IIGS: http://www.youtube.com/watch?v=E3uHip1Qr-4
Re: Working Raycasting example?
Can you send me the .love file? I want to see how many FPS can I get, on a netbook...
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests