Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Top down zoom question...

Author
Message
Chromehawk
20
Years of Service
User Offline
Joined: 29th Jun 2003
Location:
Posted: 21st Jul 2003 20:30
I'm working on a top-down style game. I want to be able to zoom in and out on the sprites (which stay the same size, btw). The issue is the best way to zoom in. I find that if I find the "delta" for the sprite from my origin and then change that and do a re-draw, it works for a little while, but when I go to reversve that, I apparently get a rounding error because my sprites don't show up at their original positions. Is there a good way to do this? Am I not being clear enough in my explanation?

Thanks.

ChromeHawk
Chromehawk
20
Years of Service
User Offline
Joined: 29th Jun 2003
Location:
Posted: 23rd Jul 2003 06:32
OK, I think I fixed my problem. Here's what I did...

My game has a set number of zoom levels (i.e. 2x, 4x, 8x, etc) so what I did was the following...

TYPE XY
x as integer
y as integer
ENDTYPE

TYPE SP_TABLE_TYPE
num as integer
img as integer
zoom2 as XY
zoom4 as XY
zoom8 as XY
ENDTYPE

dim sprite_table(255) as SP_TABLE_TYPE

Every time a sprite is created, I call a function that calculates the posits of that particular sprite for all zoom levels. As this calculation is only done once, it eliminates the rounding error I was experiencing before. The zoom function simply re-posits the sprite by referencing the zoom level (i.e. sprite sprite_table(z).num, sprite_table(z).zoom2.x, sprite_table(z).zoom2.y, sprite_table(z).img )

I imagine there is a more elegant solution, but I decided that this brute force method would suffice as my project is old school style gfx, etc.

--Chromehawk

Login to post a reply

Server time is: 2024-02-26 20:13:46
Your offset time is: 2024-02-26 20:13:46