Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: aeTIos on March 28, 2011, 06:49:40 am

Title: Perspective?
Post by: aeTIos on March 28, 2011, 06:49:40 am
Hello,

How can you draw sprites with perspective (e.g., they are smaller if they are farther away and bigger if they are closer to you) ?

thanks!

--aeTIos
Title: Re: Perspective?
Post by: ZippyDee on March 28, 2011, 06:52:48 am
Erm...there are a few ways. One way would be to scale the sprites dynamically every time they are redrawn. Scaling sprites is very slow and probably not the best approach. The easiest way would be to just make a bunch of different sprites for different depth ranges, and just display the one that corresponds to the current depth.
Title: Re: Perspective?
Post by: Deep Toaster on March 28, 2011, 09:11:13 am
Yep. squidgetx's Cuberunner for instance has sprites for every size and rotation angle. Then you just pick the one to draw.
Title: Re: Perspective?
Post by: Munchor on March 28, 2011, 09:12:24 am
Hello,

How can you draw sprites with perspective (e.g., they are smaller if they are farther away and bigger if they are closer to you) ?

thanks!

--aeTIos

You can use greyscale, or size to get perspective, I guess.
Title: Re: Perspective?
Post by: aeTIos on March 28, 2011, 09:22:01 am
But I want to make a 2.5 D (non-rotating) "raycaster". How do you resize sprites dynamically?
Title: Re: Perspective?
Post by: DJ Omnimaga on March 28, 2011, 12:56:45 pm
I do not remember how, but one thing I must tell you is to not resize them on the fly. Resizing one 8x8 sprite takes 0.1 seconds, meaning resizing 10 8x8 sprites would reduce your frame rate to 1 frame per second. Before your level is loaded, you must pre-render each possible resizing of the sprites you need then store them into a ram area or arbitraty buffer, then recall the appropriate sprite when needed. This would be much faster, although before the level loads there would be a small loading delay.
Title: Re: Perspective?
Post by: aeTIos on March 28, 2011, 12:58:39 pm
aha. I think I will go with different-sized sprites, then. Will be tons of work, though...
Title: Re: Perspective?
Post by: Ashbad on March 28, 2011, 01:07:43 pm
true, but drawing prerendered stuff is MUCH faster.  And I should probably bold it, capitalize it, turn it blue and give it lobster claws...

(http://img.removedfromgame.com/imgs/WIP.bmp)

Like I said, a bit faster ;) it's a pain to pre-render, but it's better than going at 0.2 FPS :P
Title: Re: Perspective?
Post by: aeTIos on March 28, 2011, 02:38:48 pm
lol. I see. yes. Its a pain.
/end spammish section
Yeah, thats true. I would like to see some code for scaling sprites, though...
Title: Re: Perspective?
Post by: Freyaday on March 28, 2011, 04:54:14 pm
It depends on the kind of sprite, but in general, at this scale, it'd probably be best just to do it by hand.
Title: Re: Perspective?
Post by: FloppusMaximus on March 28, 2011, 10:53:28 pm
Resizing one 8x8 sprite takes 0.1 seconds, meaning resizing 10 8x8 sprites would reduce your frame rate to 1 frame per second.
I'm not sure what exactly you mean - the time taken depends greatly on the size of the output, and less on the size of the input - but I don't think it's anywhere near as bad as you're suggesting.  I wrote a scaled sprite routine a while ago, which takes about that long to draw a sprite at 64x64 (masked, with both X and Y clipping.)  This, of course, is an extreme case.