Getting Sprite Clip Coords from an ID
4 posters
Page 1 of 1
Getting Sprite Clip Coords from an ID
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
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
- 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);
- 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
Re: Getting Sprite Clip Coords from an ID
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
Re: Getting Sprite Clip Coords from an ID
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
ok ill be sure to thank him
Re: Getting Sprite Clip Coords from an ID
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 swear to god he's going to invent interplanetary space travel one of these days, or maybe immortalitiy IDK but it will be big
eatcomics- God
- Posts : 153
Join date : 2010-10-21
Re: Getting Sprite Clip Coords from an ID
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
Re: Getting Sprite Clip Coords from an ID
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
5 / 0 = 0
8 / 0 = 0
44 / 0 = 0
Peice of cake!
EDIT:
0 / 0 = SHIT A BLACK HOLE!!!
Re: Getting Sprite Clip Coords from an ID
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
5 / 0 = 0
8 / 0 = 0
44 / 0 = 0
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
Re: Getting Sprite Clip Coords from an ID
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
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
eatcomics- God
- Posts : 153
Join date : 2010-10-21
Re: Getting Sprite Clip Coords from an ID
That's good, it just means I'm rightAdmin wrote:My head hurts....
eatcomics- God
- Posts : 153
Join date : 2010-10-21
Re: Getting Sprite Clip Coords from an ID
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.eatcomics wrote:That's good, it just means I'm rightAdmin wrote:My head hurts....
dandymcgee- New comer
- Posts : 5
Join date : 2010-10-19
Re: Getting Sprite Clip Coords from an ID
I uh... knew that, was uh, just going to say that right now, you just beat me to it loldandymcgee wrote: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.eatcomics wrote:That's good, it just means I'm rightAdmin wrote:My head hurts....
^that was all theoretical and I basically wrote it on the fly, no thought required xD
eatcomics- God
- Posts : 153
Join date : 2010-10-21
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum