Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Raycasting problems

This thread is locked; no one can reply to it. rss feed Print
Raycasting problems
MiquelFire
Member #3,110
January 2003
avatar

You forgot the image TF

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Thomas Fjellstrom
Member #476
June 2000
avatar

:o crap :(

sory ;)

and by green, almost teal, the two blocks, one at the top, and one at the bottom...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

Yikes O_o I see nothing like that when I'm playing ... just nice gray walls ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

aybabtu
Member #2,891
November 2002

23 said:

Sweet mother, aybabtu, why does your code run at 0 FPS?!?

Um...did you run the binary or compile the code? The binary is a DOS binary (DJGPP, remember?), so if you have winXP or 2000 or something, it probly won't work.:P

23yrold3yrold
Member #1,134
March 2001
avatar

I ran the binary, and use Win98.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Peter Hull
Member #1,136
March 2001

Chris, Can you explain what you're doing in DrawSlice? I can't figure it out (my fault :P )
I got similar fps on my system with just

void DrawSlice(BITMAP* buffer, BITMAP* texture, int xoff, int x, int y, int tall)
{
  stretch_blit(texture, buffer, xoff, 0, 1, 64, x, y, 1,tall);
}

but I may not have compiled yours with the correct optimisation. Also it rotated the textures by 90 compared to yours.

Pete

Trezker
Member #1,739
December 2001
avatar

I compared your raycaster with mine.
Wolf, 64 fps max
Me, 400 fps max
I'm a little happy here. :)
BTW, the binary worked fine here, XP.

And my engine has quite a bit of usefull features you might want to have a closer look at.

23yrold3yrold
Member #1,134
March 2001
avatar

I get better fps my way over using stretch_blit() (about 50% better). The rotation is because I treat rows like columns in DrawSlice() due to Bob's suggestion. Otherwise I'm doing evil cache missing or something :P ;)

Anyway, DrawSlice is based off my Bresenham line drawing code to step through the column pixels and get the right texture pixel to draw. It's not too difficult to figure out, methinks. If it still confuses you, post in my "Math help, please" thread since this one's getting a little long :)

Trezker: Yes, I should look at your code closer; thanks for reminding me :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

So, have you figured out whats up with the funky colors? Since you say its supposed to be shaded?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

I took the shading out of that code, TF. I don't see that for the life of me when I run it. Can't duplicate the error at all. Are you using my gray stone texture?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Trezker
Member #1,739
December 2001
avatar

Nice, the stretch_blit is tha main bottleneck in my code. That's why I don't let the player closer than 2 units, each block is 64, from the walls. If I use a better method, it'll do alot.

Thomas Fjellstrom
Member #476
June 2000
avatar

what grey stone texture? :P

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

The one in my last zip (at miran's request)?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

aybabtu
Member #2,891
November 2002

Quote:

I compared your raycaster with mine.
Wolf, 64 fps max
Me, 400 fps max
I'm a little happy here.

Hey...so am I! I know my casting method is far from the best, but 50-64 FPS is fine by me. Wow...400? You're useing the "right" method, huh? I'm gonna check out your source...

23 said:

I ran the binary, and use Win98.

Geez! That's crazy! It runs on both my old 586 (Win95) and my family's computer (Win98SE). Crazy...

Steve Terry
Member #1,989
March 2002
avatar

hey just tested it, looks great, but you may want to actually put a fps limiter on there to make it always run at 60fps or something, because when I'm moving around you don't go forward smoothly, for instance you go around a corner where the fps goes from 60 to 90, you run into it because a sudden change in velocity. Anyway nice little demo :)

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

aybabtu
Member #2,891
November 2002

Holy CRAP! A 30 frame jump! Wow...didn't think I'd see the day...well okay! If it's becomming a problem, I'll put a limit...! YAY!

I think I've coaxed another frame per second out of it. In my raycasting while loop, I had it testing to see if the_x and the_y were hitting a tile, but, if they do, the inside of the loop catches it and breaks out of it. So, I eliminated 2 divisions (well, shifts), and a usless conditional...it runs a little bit faster...I think.

EDIT:
How accurate should PI be? I mean, after the first 10 decimal places...it should be pretty usless, right? Or should I have as many as I can?

Ace
Member #1,781
December 2001
avatar

Pfffft, PI.... round that thing down to 3 and call it a day. ;)

Seriously though, using a long PI will definately give you more precision, there's only show much precision that's going to show up. Ten decimals should be plenty, probably overkill.

Edit: Dear lord... I'm going to have nightmares about pi tonight. In it, I'm going to be traveling through a raycasted dungeon and I'll run into various 2^1/2 enemies and when I finally get to the boss room, PI will be standing in the middle of it, carrying a missle launcher. Too bad I'm out of bullets and I'm done to 5% health.

- Ace

aybabtu
Member #2,891
November 2002

Quote:

Pfffft, PI.... round that thing down to 3 and call it a day.

Heheheheh.
3*10=30
3.14*10=31.4
-OR-
3*100=300
3.14*100=314
Quite a difference...;):P

EDIT: How long with Matthew let a thread go to...I see that Bruce Perry's "My avatar" thread is well over 200...

EDIT2:

Quote:

Dear lord... I'm going to have nightmares about pi tonight.

Yes! How dare you insult teh almighty PI!? Round down to 3...bah!

23yrold3yrold
Member #1,134
March 2001
avatar

Well, this thread is still on-topic :) I'm moving on to Tetris Attack for a while myself; I'll come back to this later ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Harte
Member #33
April 2000
avatar

Quote:

Anyway, DrawSlice is based off my Bresenham line drawing code

Wolfenstein uses the broad equivalent of compiled sprites for every possible sized slice of every possible texture. But I'd dare imagine it uses some super-clever assumptions about run length stuff which Allegro does not with its compiled sprites - or else it couldn't possibly fit all that code into memory.

How many different textures does the average Wolfenstein level have?

And has this thread yet discussed the ways of inserting sprites and doors into the world?

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

And has this thread yet discussed the ways of inserting sprites and doors into the world?

Unfortunately, no.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Zaphos
Member #1,468
August 2001

Well, a very primative technique of drawing a baddie would be to:
1) keep an array of distances to walls
2) Use the x/z, y/z formula to determine the sprite's midpoint location, and the size/z formula to determine how much to scale it -- to do this, of course, you need to rotate the x,y,z so z+ or z- is away from you (pending left or right hand coordinate system)
3) Draw the sprite slice by slice, comparing its z to the wall array's z for each slice
4) For each slice you draw, fill in the corresponding spot in the wall array with the sprite's z so that later sprite draws layer correctly.

Of course, this technique is designed with same-height enemies in mind, and cannot have a taller enemy peeking over a wall or another baddie. But then, it's probably good enough for your average wolfenstein clone.

23yrold3yrold
Member #1,134
March 2001
avatar

Actually, I would just draw the enemies back to front, since you can see one enemy behind another because of transparency. You're keeping an array of distances to walls anyway, just grab all the enemies in your line of sight, get distances, draw back-to-front slice by slice, and I guess you got it.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Karel
Member #3,624
June 2003

I get around 70 fps with 1 frameskip and over 200 fps with 5 frameskips, with and without vync. 'Course, I'm on an Athlon 1800+ ;D

Zaphos
Member #1,468
August 2001

23: Oh, right. Heh, silly me and my rectangular enemies.



Go to: