MaxCoderz

for your 1 bit pleasure!

All times are UTC




Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 9  Next
Author Message
 Post subject:
PostPosted: Tue 27 Jun, 2006 9:14 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
For the signed division/multiplication routines to work, it must first fix the sign of the operands so both are positive. The S24S16 division routine divides abc by de, and the negation of de used a.

With this, and a couple of other minor fixes, I get a lot closer:

Image

Still broken, though. :\


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 27 Jun, 2006 10:55 am 
Offline
Calc Master

Joined: Fri 17 Dec, 2004 3:22 pm
Posts: 1064
Location: Probably playing DDR
If you use collission detection it'd be okay right? Because it seems like it freaks out when you go THROUGH the wall, which you normally can't do in a game anyway.

_________________
Image
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 27 Jun, 2006 11:53 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Sadly, it's not that easy (or that at all). It's worst when you're near a wall, as you noticed, but also goes wonky at odd moments when you can be quite a distance from the wall. :\


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 27 Jun, 2006 1:24 pm 
Offline
Calc King
User avatar

Joined: Sun 23 Jan, 2005 12:37 am
Posts: 1727
Location: Netherlands
Nevertheless, it looks good and it's surprisingly fast imho.

_________________
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 27 Jun, 2006 1:44 pm 
Offline
Calc Wizard

Joined: Sun 19 Dec, 2004 9:02 pm
Posts: 585
Location: Sweden
I wouldn't say surprisingly fast, expectedly fast is better :wink:

Ben, you mentioned clipping to Y=0 "first", do you clip again?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 27 Jun, 2006 2:01 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Actually, the currently rewritten code doesn't bother clipping to Y=0 first, which might be part of the bugginess.

There is a reason to clip to Y=0 first - consider the following:

Image

When performing the clipping, I need to know which boundary - y=+x or y=-x - I need to clip to.
The easiest check is whether the X coordinate of the out-of-bounds point is > 0 or < 0. As you can see with the red and blue lines, this works fine. If you look at the green line, however, the X < 0 but you'd want to clip it as if it was > 0. Therefore, it is neccessary to clip it to Y=0 first, then check the X coordinate and clip to y=+x or y=-x as normal, based on that decision.

(Just thought of one quick optimisation - this extra clip-to-y step is only required if the sign of end[0].x != the sign of end[1].x)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 28 Jun, 2006 10:19 am 
Offline
Calc Wizard

Joined: Sun 19 Dec, 2004 9:02 pm
Posts: 585
Location: Sweden
What would the Y=0-clip look like? I guess it would be cheaper than the origin-test (1 mul compared to 2 ?), since the line is to be clipped anyway.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu 29 Jun, 2006 10:43 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Have another screenshot - I stuck the 'check for Y < 0' code back in, tidied up a few things and optimised a few silly repeated calculations...

Image

Note that when I walk through a wall now, rather than have a few frames of dancing junk lines, you (fairly) smoothly 'snap' through to the other side.

Here are the formulae I currently use.

I derived them by lots of scribbling and fudging the equation of a line 'y = mx + c'. They're as simple as I can make them.
m is held as signed 8.8 fixed-point value. c is held as a signed 16.8 fixed-point value.
The following hold for when the difference in X is greater than the difference in Y.

m = (Y1 - Y0) ÷ (X0 - X1) ; m is negative gradient.
c = Y0 + m Ãâ€â€


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu 29 Jun, 2006 1:45 pm 
Offline
Calc Wizard

Joined: Sun 19 Dec, 2004 9:02 pm
Posts: 585
Location: Sweden
Good stuff, one of the more "inspiring" threads around here lately :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu 29 Jun, 2006 1:55 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Thanks. :) Did you ever get much done with converting your variable-height raycaster to Z80 assembly?

Something I didn't mention - in the screenshot above, sometimes there are two little dots in the left/right most column. This seems to be a bug where completely off-screen walls are clipped but both to the left or right side, rather than being discarded completely.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon 03 Jul, 2006 9:53 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Image

Only problem now is when the camera is directly 'inside' a wall, but seeing as clipping (in the collision detection sense) would stop that it isn't much of a concern.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon 03 Jul, 2006 6:40 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 4095
Location: I cant seem to get out of this cryogenic chamber!
Niiiiiiiice ben! I dont really see any problems at all. Will you be implementing some kind of line removal?

_________________
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 04 Jul, 2006 11:03 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
With any luck, yes. I'll probably start with some ugly brute-force thing (just transform all the walls, sort from back-to-front then draw them all) but it should be enough to start with. Then it's more a case of working out the best way to sort things - possibly BSP tree?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 04 Jul, 2006 11:16 am 
Offline
Maxcoderz Staff
User avatar

Joined: Wed 15 Dec, 2004 7:26 pm
Posts: 2735
Location: The Hague, Netherlands
I see you are trying your hands on Vista? :)

Will you use this for anything besides "for fun" (like a game)?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 04 Jul, 2006 12:08 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Not quite, XP Visual Style ;)

As for a game, it depends whether I can get it to be fast enough to be game-worthy. If so, a DOOM-esque shooter would be the obvious step to take.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 9  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB ® Forum Software © phpBB Group | DVGFX2 by: Matt