Omnimaga
Calculator Community => TI Calculators => Axe => Topic started 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
-
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.
-
Yep. squidgetx's Cuberunner for instance has sprites for every size and rotation angle. Then you just pick the one to draw.
-
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.
-
But I want to make a 2.5 D (non-rotating) "raycaster". How do you resize sprites dynamically?
-
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.
-
aha. I think I will go with different-sized sprites, then. Will be tons of work, though...
-
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
-
lol. I see. yes. Its a pain.
/end spammish section
Yeah, thats true. I would like to see some code for scaling sprites, though...
-
It depends on the kind of sprite, but in general, at this scale, it'd probably be best just to do it by hand.
-
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.