Author Topic: Animating an 8x8 sprite with facing  (Read 6194 times)

0 Members and 1 Guest are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Animating an 8x8 sprite with facing
« on: September 09, 2010, 10:50:21 am »
What would be the best way to make an animated sprite move with regards to facing?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Animating an 8x8 sprite with facing
« Reply #1 on: September 09, 2010, 01:07:00 pm »
I don't understand what you mean.
« Last Edit: September 09, 2010, 01:07:17 pm by Runer112 »

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Animating an 8x8 sprite with facing
« Reply #2 on: September 09, 2010, 01:36:58 pm »
If you press left, he runs left. If you press right, he runs right.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Animating an 8x8 sprite with facing
« Reply #3 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.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Animating an 8x8 sprite with facing
« Reply #4 on: September 09, 2010, 01:57:56 pm »
Uhm... Any other opinions?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Animating an 8x8 sprite with facing
« Reply #5 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?

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Animating an 8x8 sprite with facing
« Reply #6 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?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Animating an 8x8 sprite with facing
« Reply #7 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Animating an 8x8 sprite with facing
« Reply #8 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

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Animating an 8x8 sprite with facing
« Reply #9 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.
___Axe_Parser___
Today the calculator, tomorrow the world!