Author Topic: Perspective?  (Read 14099 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Perspective?
« 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
I'm not a nerd but I pretend:

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Perspective?
« Reply #1 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.
There's something about Tuesday...


Pushpins 'n' stuff...


Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Perspective?
« Reply #2 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.




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Perspective?
« Reply #3 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.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Perspective?
« Reply #4 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?
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Perspective?
« Reply #5 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.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Perspective?
« Reply #6 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...
I'm not a nerd but I pretend:

Ashbad

  • Guest
Re: Perspective?
« Reply #7 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...



Like I said, a bit faster ;) it's a pain to pre-render, but it's better than going at 0.2 FPS :P

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Perspective?
« Reply #8 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...
I'm not a nerd but I pretend:

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Perspective?
« Reply #9 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.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Perspective?
« Reply #10 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.