123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|400|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> maths problem...

Sat, 25 Aug 2007, 13:58
spinal
First of all, I put this in off-topic because there is no 'general coding' topic.

Ok, I'm coding on the DS, but the problem is more related to the maths than the DS, so...

Using sprite scaling the image of the sprite is centered, and is not the actual size of the sprite. I'm using a 32x32 image in a 64x64 sprite. Like I said, the image is centered and there seems to be nothing I can do about that. I would however like to align the image, so I'm trying to figure out how close to the edge of the sprite the image actually is.

I can tell you the zoom/scaling uses the following inputs-
128 = 200%
256 = 100%
512 = 50%

I think any number is valid. So because the image is centered, a 32x32 image on a 64x64 sprite has a border of 16 and a 200% zoom would leave a border or 0.

I would like to know how to figure this out so I can offset my sprite locations to align the images no matter how zoomed. I assume this would be done with percentages or something, but I get my brain tangled up when I try to think about it.

so what I wan is

256 -> [enter some maths here] -> 16
128 -> [enter same maths here] ->0


anyone?

-=-=-
Check out my excellent homepage!
Sat, 25 Aug 2007, 14:32
JL235
So you mean you want the to find the position of the top-left corner of the image, rather then have it centred?

x = spriteX + spriteWidth/2
y = spriteY + spriteHeight/2
Sat, 25 Aug 2007, 14:43
spinal
But I don't know[i/] the size of the sprite after it is zoomed. All I have to go off are the odd values (128,256 etc.)

-=-=-
Check out my excellent homepage!
Sat, 25 Aug 2007, 14:52
JL235
I'm still a little confused as to how this all works.

Are you saying, there is a 32x32 image in a 64x64 sprite. When you zoom the image it fills the sprite, but the zoom is set with 128, 256 and 512 values (or at least they are examples of those values)?

If 256 is when it is at 100%, and you know the zoom, you can calculate the new size of the image. As it's square size refers to both width and height.

(256.0/zoom) * 32 = newSize

Where zoom is 128, 256 or 512.
Sat, 25 Aug 2007, 15:06
spinal
so I then get my border(empty space) size by (64-size)/2

Thanks, that seems about right. I knew it would by far simpler than I thought.

-=-=-
Check out my excellent homepage!
Sat, 25 Aug 2007, 15:08
JL235
I just spent 30 seconds with Ruby and got it all figured out.
Sat, 25 Aug 2007, 15:40
Jayenkai
Baffled over the "No General Programming Section" thing, as I could've sworn I added one a while back..

... Aah, no, wait.. That was the "General Basic" section..
D'oh!
Either way, would've fit into either C, or Handheld Coding... So Nah!

----

I found the rotations to be weird, too.
I think what the rotation is doing is rotating it around the center, but then plonking it back so the top left is still the top left...
Looked really odd, when I was trying to place a rotating sprite.
Weird stuff.

Anyway, back to your issue.

In blitz..



|edit| ... That what happens when you start answering a question, then eat, then post the finished answer! Aw well, never mind.. Plus mine's stupidly complex, next to Diablo's simpler answer!! |edit|


-=-=-
''Load, Next List!''
Sat, 25 Aug 2007, 15:50
JL235
Jayenkai Plus mine's stupidly complex, next to Diablo's simpler answer!!

That's cos you didn't use Ruby!
Sat, 25 Aug 2007, 16:01
Jayenkai
It's not the tool that matters, it's how you figure it out that counts..

And I figured it out not very goodily.

-=-=-
''Load, Next List!''
Sat, 25 Aug 2007, 17:35
spinal
Now now guys, arguing wont get my sprites in the right place.

Hang on, although I haven't tested yet, the numbers seem correct, the sprites should line up properly.

In the gray corner, representing Ruby, the king of deductive reasoning... Columbo... er... DiablosDevil..

And in the blue corner, representing Blitz BASIC, the guy who runs the site, keeps us talking to each other and even found some of the old BlitzCoder members... Jayenkai....



-=-=-
Check out my excellent homepage!