Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on September 09, 2010, 10:50:21 am

Title: Animating an 8x8 sprite with facing
Post by: Raylin on September 09, 2010, 10:50:21 am
What would be the best way to make an animated sprite move with regards to facing?
Title: Re: Animating an 8x8 sprite with facing
Post by: Runer112 on September 09, 2010, 01:07:00 pm
I don't understand what you mean.
Title: Re: Animating an 8x8 sprite with facing
Post by: Raylin on September 09, 2010, 01:36:58 pm
If you press left, he runs left. If you press right, he runs right.
Title: Re: Animating an 8x8 sprite with facing
Post by: Runer112 on September 09, 2010, 01:39:11 pm
Give the sprite both position and diretion/velocity variables. Design the sprites to face one way, but when drawing, check the velocity/direction and display either the sprite or flipH() of the sprite accordingly.
Title: Re: Animating an 8x8 sprite with facing
Post by: Raylin on September 09, 2010, 01:57:56 pm
Uhm... Any other opinions?
Title: Re: Animating an 8x8 sprite with facing
Post by: Builderboy on September 09, 2010, 02:01:23 pm
What runner said is pretty much the way to do it.  Are you confused with his explanation or do you want to do something else?
Title: Re: Animating an 8x8 sprite with facing
Post by: Raylin on September 09, 2010, 02:02:29 pm
Well, won't I have to use an If conditional to flipH() the sprite while trying to display the thing?
Won't that slow it down?
Title: Re: Animating an 8x8 sprite with facing
Post by: calc84maniac on September 09, 2010, 02:04:23 pm
I think you are overestimating the delay caused by things in Axe. This is nowhere close to TI-Basic slowness.
Title: Re: Animating an 8x8 sprite with facing
Post by: Builderboy on September 09, 2010, 02:10:30 pm
An If conditional probably could execute hundreds of times before it took the amount of time it takes to draw a single sprite.  You might be able to get around this with some boolean trickery, but unless a way is figured out, the if statement is a viable option
Title: Re: Animating an 8x8 sprite with facing
Post by: Quigibo on September 09, 2010, 02:33:59 pm
If you have like 100 sprites doing this it will definitely slow down, but with a single sprite, there will be no slowdown.  If you want a super speed optimized method instead of a convenient one, you need a 16 sprite array.  4 for each direction and 4 frames per animation.  Then, you can just look up the correct sprite with Pt-On(X,Y,D*4+(T^4)+Pic1) where D is direction (0,1,2, or 3) and T is the "step timer".  Usually, you can just replace T with X+Y or something similar, it depends on the speed of animation and other factors you might want.  The downside of this though is that even though the total amount of size in the executable will be around the same, its a hassle to have to draw 16 individual sprites for each character.