Log In  

Cart #14153 | 2015-09-14 | Code ▽ | Embed ▽ | No License
6

HOW TO:
Press Z to make spaceship move to another position
Cart uses ease_in_out_cubic (but feel free to edit and change to another included easing function).
Animation is locked at 0.5 seconds per move (feel free to edit this, too)

ABOUT:
Here is my attempt at providing tweening/easing functions in PICO-8.
They are based on existing work done by many other people.
These functions help you animate sprites smoothly from one position to another, with different types of acceleration and/or deceleration.
I am using them to animate cards around the screen in my Hanafuda Koi-Koi game.
To read more about Easings, go here: http://easings.net

Working:
Linear
Quadratic
Cubic
Quartic
Quintic
Sinusoidal
Exponential

Circular *

  • partially working

Maybe these are broken because I'm not familiar enough with how PICO-8 maths functions work?

Any help appreciated getting those last few working is appreciated!

Thanks,
matt

P#14136 2015-09-14 11:34 ( Edited 2015-09-15 09:23)

The sin and cos functions work from 0 to 1 instead of 0 to 2pi. That might be the issue there. It's worth looking up all the math fcns in the pico8.txt reference file, because there's some weirdness there. =)

P#14141 2015-09-14 15:16 ( Edited 2015-09-14 19:16)

Ah! Thanks, will do.

P#14142 2015-09-14 15:18 ( Edited 2015-09-14 19:18)

still broken:
ease_in_sine
ease_in_expo
ease_in_circ

not enough precision for:
ease_out_expo
ease_in_out_expo
ease_out_circ
ease_in_out_circ

I tested the cart in picolove, which has no math limitations, and this showed me that the calculations work. So they are too much for standard pico8 maths. Any way around this?

P#14151 2015-09-14 19:03 ( Edited 2015-09-15 08:31)

Could this have to do with the fixed point 16.16 numbers in PICO-8? If the precision is off, try using the full 32 bits for calculation (shl() and shr() will help here).

P#14175 2015-09-15 05:19 ( Edited 2015-09-15 09:19)

Most likely it does.

I'll have to look into shl() and shr() it's been a long time since I've used those

P#14176 2015-09-15 05:23 ( Edited 2015-09-15 09:23)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 14:33:35 | 0.011s | Q:19