gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfxgfx
 
Members, please note that our guidelines are located here.
 
gfx gfx
gfx
484586 Posts in 28410 Topics by 2464 Members - Latest Member: austinrobert July 10, 2020, 04:19:54 PM
*
gfx* Home | Help | Calendar | Login | Register | gfx
gfx
The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Aligning forumula for different sizes
gfx
gfxgfx
 

Author Topic: Aligning forumula for different sizes  (Read 739 times)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Aligning forumula for different sizes
« on: August 28, 2010, 10:32:23 PM »
I'm doing a little experiment but first I need to align some sprites at different sizes. I outputted the numbers to make it aligned (top-left corner) but not sure of the formula at this point. So here's the results.

The width and height is 16.
DrawAnim(Anim,160 + 32,120 + 32,1,0,255,255,255,255,360,500);
DrawAnim(Anim,160 + 24,120 + 36,1,0,255,255,255,255,360,400);
DrawAnim(Anim,160 + 16,120 + 16,1,0,255,255,255,255,360,300);
DrawAnim(Anim,160 + 8,120 + 8,1,0,255,255,255,255,360,200);
DrawAnim(Anim,160,120,1,0,255,255,255,255,360,100);

The width and height is 24

DrawAnim(Anim,160 + 48,120 + 48,1,0,255,255,255,255,360,500);
DrawAnim(Anim,160 + 36,120 + 36,1,0,255,255,255,255,360,400);
DrawAnim(Anim,160 + 24,120 + 24,1,0,255,255,255,255,360,300);
DrawAnim(Anim,160 + 12,120 + 12,1,0,255,255,255,255,360,200);
DrawAnim(Anim,160,120,1,0,255,255,255,255,360,100);

So based on the width and height of the object and the size(100,200,300,...) what's this formula?

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Aligning forumula for different sizes
« Reply #1 on: August 30, 2010, 01:59:31 PM »
Im on a public pc in a hotel atm, so I cant test it.
Assuming that the 36 in the second DrawAnim in your post should be 24...:

//a = width or height

for(new n; n <= 4; n++)
    DrawAnim(Anim, 160 + (n*a), 120 + (n*a), 1, 0, 255, 255, 255, 255, 360, (n + 1)*100)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Re: Aligning forumula for different sizes
« Reply #2 on: August 30, 2010, 07:24:28 PM »
Oh sorry that I was not clear enough.

I listed four as an example to help you figure out a formula.
When you change the size of a sprite it shifts the image a bit (I think it's center aligning).
Anyways in each of the example I got it to align at the top left corner.

Create an Anim of a sprite that is 16x16 and 24x24. It will draw the chest at each size properly aligned.

So if an image is different size(not talking with and height)

DrawAnim(Anim,160 + 48,120 + 48,1,0,255,255,255,255,360,500);
DrawAnim(Anim,160 + 36,120 + 36,1,0,255,255,255,255,360,400);

So I need a formula like this.

Code: [Select]
DrawImg(x,y,size)
{
new width = GetAnimWidth(anim);
new height = GetAnimHeight(anim);
new xadj = floatround(width * 0.25) * size;
new yadj = floatround(height * 0.25) * size;

if(isVisible("this"))
{
DrawAnimNoInc(anim,x + xadj,y + yadj,1,1,255,255,255,255,0,size);
}
}

Unless if the xadj and yadj came out correct, then I answered my own question. If not, then it needs some tweaking.

Offline Luke

  • Regimental
  • ****
  • Posts: 1,823
    • View Profile
Re: Aligning forumula for different sizes
« Reply #3 on: August 30, 2010, 07:47:35 PM »
oh, your talking about scale. off the top of my head (d being width or height)
d/2 * ('size\scale'/100)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Re: Aligning forumula for different sizes
« Reply #4 on: September 01, 2010, 01:23:00 PM »
At first it looked like it wasn't working. Then I changed the rotation and it worked fine.

Code: [Select]
DrawImg(x,y,size)
{
new width = GetAnimWidth(Anim);
new height = GetAnimHeight(Anim);
new xadj = (width / 2) * (size / 100);
new yadj = (height / 2) * (size / 100);

if(isVisible("this"))
{
DrawAnimNoInc(Anim,x + xadj,y + yadj,1,1,255,255,255,255,360,size);
}
}

If you use a 0 instead of a 360 it goofs it up for the 100 size. (small little OZ bug)

The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Aligning forumula for different sizes
 

gfxgfx
gfx
SMF 2.0.17 | SMF © 2019, Simple Machines Page created in 0.227 seconds with 21 queries.
Helios Multi © Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!