Getting Sprite Clip Coords from an ID

Go down

Getting Sprite Clip Coords from an ID

Post  WSPSNIPER on Tue Oct 26, 2010 5:14 pm

ok nico showed me this algorithm for taking an id and finding the clipping coords and after working it backwards to use coords to get an id i understand it fully and would like to share it with you guys

Code:

int id = 5;
int sheetW = 512;
int sheetH = 512;
int frameW = 32;
int frameH = 32;

vec clip(id%(sheetW/frameW)*32, id/(sheetH/frameH)*32);

// and to get the id from the clip you go
Code:

// it took me a while to come up with this lol :P
int x = 130;
int y = 46;
int sheetW = 512;
int sheetH = 512;
int frameW = 32;
int frameH = 32;

x -= x%frameW;
y -= y%frameH;

int id = ((y/frameH)*(sheetH/frameH))+(x/frameW)

so now you can use an id to represent a clip on a sheet, it is much more efficent than iterating and checking for collision

oh and i just used variables so you could see what the numbers represented Very Happy
avatar
WSPSNIPER
Admin

Posts : 149
Join date : 2010-10-19
Age : 24
Location : MN

View user profile http://www.theeternalquest.comze.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  Admin on Wed Oct 27, 2010 4:09 am

I would just like to add that my previous method was shit and I was introduced to this algorithm by Ginto8 from the moosader board so you can thank him Wink
avatar
Admin
Admin

Posts : 279
Join date : 2010-10-19

View user profile http://eternalquest.forumotion.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  WSPSNIPER on Wed Oct 27, 2010 7:25 am

Admin wrote:I would just like to add that my previous method was shit and I was introduced to this algorithm by Ginto8 from the moosader board so you can thank him Wink

ok ill be sure to thank him Very Happy
avatar
WSPSNIPER
Admin

Posts : 149
Join date : 2010-10-19
Age : 24
Location : MN

View user profile http://www.theeternalquest.comze.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  eatcomics on Wed Oct 27, 2010 8:09 pm

Ginto is awesome... I think he deserves a medal... Darn 13 y/o geniuses

I swear to god he's going to invent interplanetary space travel one of these days, or maybe immortalitiy IDK but it will be big
avatar
eatcomics
God

Posts : 153
Join date : 2010-10-21

View user profile

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  WSPSNIPER on Wed Oct 27, 2010 8:19 pm

eatcomics wrote:Ginto is awesome... I think he deserves a medal... Darn 13 y/o geniuses

I swear to god he's going to invent interplanetary space travel one of these days, or maybe immortalitiy IDK but it will be big

i think he will find a way to divide by zero and it will cause a black hole and the end of the world lol!
avatar
WSPSNIPER
Admin

Posts : 149
Join date : 2010-10-19
Age : 24
Location : MN

View user profile http://www.theeternalquest.comze.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  Admin on Thu Oct 28, 2010 6:04 am

WSPSNIPER wrote:
eatcomics wrote:Ginto is awesome... I think he deserves a medal... Darn 13 y/o geniuses

I swear to god he's going to invent interplanetary space travel one of these days, or maybe immortalitiy IDK but it will be big

i think he will find a way to divide by zero and it will cause a black hole and the end of the world lol!

5 / 0 = 0
8 / 0 = 0
44 / 0 = 0

Razz Peice of cake!


EDIT:

0 / 0 = SHIT A BLACK HOLE!!!
avatar
Admin
Admin

Posts : 279
Join date : 2010-10-19

View user profile http://eternalquest.forumotion.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  WSPSNIPER on Thu Oct 28, 2010 6:20 am

Admin wrote:
WSPSNIPER wrote:
eatcomics wrote:Ginto is awesome... I think he deserves a medal... Darn 13 y/o geniuses

I swear to god he's going to invent interplanetary space travel one of these days, or maybe immortalitiy IDK but it will be big

i think he will find a way to divide by zero and it will cause a black hole and the end of the world lol!

5 / 0 = 0
8 / 0 = 0
44 / 0 = 0

Razz Peice of cake!


EDIT:

0 / 0 = SHIT A BLACK HOLE!!!

5/0 is not 0 lol.. it cant be done ... yet!

if you dont believe me just type in 5/0 on in your calculator ... you will get Error
avatar
WSPSNIPER
Admin

Posts : 149
Join date : 2010-10-19
Age : 24
Location : MN

View user profile http://www.theeternalquest.comze.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  eatcomics on Thu Oct 28, 2010 1:16 pm

It can't be done because its actually infinity... because there is an infinite number of zeros in every number... because zero added to itself is always still zero, so it goes on forever....

Its not so much you can't divide by zero as the fact you can't express the number that you get when dividing by zero... and its useless to divide by zero...

so if (!n == 0) n/0 = ∞

0 divided by zero though is 1 I do believe... there is exactly 1 nothing in nothing
avatar
eatcomics
God

Posts : 153
Join date : 2010-10-21

View user profile

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  Admin on Thu Oct 28, 2010 1:43 pm

My head hurts.... Sad
avatar
Admin
Admin

Posts : 279
Join date : 2010-10-19

View user profile http://eternalquest.forumotion.com

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  eatcomics on Thu Oct 28, 2010 2:28 pm

Admin wrote:My head hurts.... Sad
That's good, it just means I'm right
avatar
eatcomics
God

Posts : 153
Join date : 2010-10-21

View user profile

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  dandymcgee on Fri Dec 10, 2010 1:18 pm

eatcomics wrote:
Admin wrote:My head hurts.... Sad
That's good, it just means I'm right
Actually when trying to find a limit you're usually happy to see 0/0 or inf/inf because then you can just use L'Hopital's Rule to substitute and solve.

dandymcgee
New comer

Posts : 5
Join date : 2010-10-19

View user profile

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  eatcomics on Fri Dec 10, 2010 6:20 pm

dandymcgee wrote:
eatcomics wrote:
Admin wrote:My head hurts.... Sad
That's good, it just means I'm right
Actually when trying to find a limit you're usually happy to see 0/0 or inf/inf because then you can just use L'Hopital's Rule to substitute and solve.
I uh... knew that, was uh, just going to say that right now, you just beat me to it lol

^that was all theoretical and I basically wrote it on the fly, no thought required xD
avatar
eatcomics
God

Posts : 153
Join date : 2010-10-21

View user profile

Back to top Go down

Re: Getting Sprite Clip Coords from an ID

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum