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.

DarkBASIC Professional Discussion / Help with sprite scaling issue

Author
Message
Ratty Rat
23
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 2nd Feb 2011 11:10
Hi all,
I have got an odd problem when scaling sprites and hope you can help.

In the program I am writing the sprites need to act as wall sections and butt up against each other, scaling can occur and they need to stay right next to each other with no gaps. When scaling up I noticed some gaps appearing, so I wrote the following little program to investigate this:



Use the scroll wheel to scale up and down, you can click the LMB to delete the sprites.

Notice that at some point while scaling up a gap appears, this is not altogether unexpected and I was working on fixing it when I noticed something odd - when scaling back down again the gap remains, even at scales where no gap appeared before and often even at scale 1 which is back where we started from (and even if the sprites are deleted and recreated).

So I think I have two problems :-
1) can anyone explain why a gap sometimes remains at scale 1?
2) Does anyone have some way of making the sprites continue to show no gap when scaled up?

Thanks for reading,
RR.

"Don`t try to engage my enthusiasm, I don`t have one"
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 2nd Feb 2011 12:39
Use integer numbers when scaling sprites because floats will pop between two round numbers quite undeterminably...

It's not a limitation you need to do that, because sprites are already limited by pixels, they are not antialiased. At least that i know of.
Ratty Rat
23
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 2nd Feb 2011 13:12
Thanks Quel, that pushed me in the right direction, below is a revised version that scales using integers, the disturbing thing is what values end up in those integers:


I noticed here that, when the gap appears at scale 1, although the printed scale shows as 1, doing an int on it gives zero, suggesting it is actually 0.9999999999....

Below is a fix, for this example at least, it keeps the SCALE to 2 decimal places, and resets it to 1 exactly when the scale is passing 1:


RR

"Don`t try to engage my enthusiasm, I don`t have one"

Login to post a reply

Server time is: 2026-07-18 02:37:58
Your offset time is: 2026-07-18 02:37:58