Mar 3, 2010 at 5:15 AM
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Pronouns: he/him
Alright, throughout my hacking work one thing that's bothered me in creating custom NPC entities is the framerects.
They just take up so much room, so inefficient! That's why today I sat down with a pencil and paper and devised a method
that I think should save tons of space, giving you freedom to use as many frames as you so desire on your entities.
Furthermore, this method is also easier in my opinion since you don't have to manually input each side,
rather the computer calculates most of it for you.
I'm not exactly sure, but I think that takes less room than declaring the rects of a single four-sided frame,
not counting the code at the bottom to put it into the right spots. With this method, you basically generate a
grid of rectangles for your frames. It works easiest with nice numbered widths and heights, but with a little creativity
you could make the frames just about any size rectangle I suppose. As near as I can see, the only downfalls are:
A) You have to have all your sprites aligned in a square/line/rectangle.
However, they oughta be that way anyway if you're doing things in a sensible manner.
B) Every frame must be the same size
C) Odd-sized frames could lead to some more challenging/space consuming calculations.
With this, however, it would take only a very small amount of code to produce an entity with an alphabet's worth of
frames that you could choose a letter from by <ANP the scriptstate and direction. If you wanted something like that :/
So, what are people's thoughts? Does this make sense?
They just take up so much room, so inefficient! That's why today I sat down with a pencil and paper and devised a method
that I think should save tons of space, giving you freedom to use as many frames as you so desire on your entities.
Furthermore, this method is also easier in my opinion since you don't have to manually input each side,
rather the computer calculates most of it for you.
Code:
MOV EAX,[EBP+8] ; C
MOV ECX,0F0 ; 0F0 is the Left boundary of the frameblock
MOV EDX,[EAX+68] ; +68, the frame #, or the column number of the image
SHL EDX,4 ; Here i'm shifting the offset by four because each frame is 16 pixels wide
ADD ECX,EDX ; Add that to the previous to get our new Left side
MOV [EAX+54],ECX ; Put it in it's place
ADD ECX,10 ; Now add the width of the frame, 16 again
MOV [EAX+5C],ECX ; And put that where it goes
XOR ECX,ECX ; Now to determine the up/down boundary. Here I XOR because the TOP is just zero
MOV EDX,[EAX+1C] ; Use something like direction for the row #. +1C is just unused as near as I can tell.
SHL EDX,4 ; And shift again to move the appropriate height
ADD ECX,EDX ; Now we have our top boundary
MOV [EAX+58],ECX ; So it goes here
ADD ECX,10 ; Add another height
MOV [EAX+60],ECX ; to get the bottom boundary
not counting the code at the bottom to put it into the right spots. With this method, you basically generate a
grid of rectangles for your frames. It works easiest with nice numbered widths and heights, but with a little creativity
you could make the frames just about any size rectangle I suppose. As near as I can see, the only downfalls are:
A) You have to have all your sprites aligned in a square/line/rectangle.
However, they oughta be that way anyway if you're doing things in a sensible manner.
B) Every frame must be the same size
C) Odd-sized frames could lead to some more challenging/space consuming calculations.
With this, however, it would take only a very small amount of code to produce an entity with an alphabet's worth of
frames that you could choose a letter from by <ANP the scriptstate and direction. If you wanted something like that :/
So, what are people's thoughts? Does this make sense?