Omnimaga
Calculator Community => TI Calculators => Axe => Topic started 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?
-
I don't understand what you mean.
-
If you press left, he runs left. If you press right, he runs right.
-
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.
-
Uhm... Any other opinions?
-
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?
-
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?
-
I think you are overestimating the delay caused by things in Axe. This is nowhere close to TI-Basic slowness.
-
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
-
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.