Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A small library of tweening/easing functions for use in the PICO-8 fantasy console, inspired by Robert Penner's easing functions.

License

NotificationsYou must be signed in to change notification settings

JoebRogers/PICO-Tween

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaintenanceLicenseAsk Me Anything !Twitter FollowMade With PICO-8

PICO-Tween

PICO-Tween is a port of the easing functions developed by Robert Penner. This port was based on the Lua port by EmmanuelOgaand optimised to suit the PICO-8 by refactoring to remove unnecessary tokens and making it compatible with the way the PICO-8handles math functions.

Some important things to note:

  • Despite being optimised, this library as a whole is still huge. It would be in your best interests to grab onlythe functions you plan on using, along with their support functions/variables.

  • The overall token count for the library is1556 2083, with an average of around 40-60 tokens per easing function.

  • This library has had the elastic easing functions removed as they relied on asin and acos, which are notavailable within the PICO-8. My math skills do not extend far enough for me to implement a solution for themthat doesn't rely on those functions.

  • Thanks to the Nvidea CG Toolkit references, the library now comes with implementations of asin and acos. This meansthat elastic easings have been reincluded and should be working as intended.

  • An important thing to note is that in order for the sine easings to work correctly, I've used the radian basedconversion for the base sin and cos functions without the y inversion:

cos1=cosfunctioncos(angle)returncos1(angle/(3.1415*2))endsin1=sinfunctionsin(angle)returnsin1(-angle/(3.1415*2))end

If you rely on sin and cos within your game and don't want to use radian based angles, then you'll need to adapt yourinput to the easing function accordingly to perform these calculations manually.

PICO-TweenMachine

Alongside this library, I've also released an extension library to act as a support for this. It's a lightweight wrapperto help drive and manage all tween objects and related code in order to reduce boilerplate and mess, as well as simplifythe process of creating and using tweens.

You can view the repository here:PICO-TweenMachine.

Setup

Like any PICO-8 library, integrating this library into your cart is as simple as copy/pasting the sourceinto the top of your code (I recommend the top in order to avoid problems with object ordering).

If you only need a small number of easing functions and are planning on using them individually, be sure tocheck for their dependencies. For example, there is a definition of Pi at the top of the library that might need to becopied over, along with radian based sin and cos function redefinitions used within the sine easing functions.

Basic Usage

Any of these functions should be simple to just plug in and play, provided you have a basic knowledge of how to useeasing functions.

Here is a basic example of using the linear function to move across the screen:

functionlinear(t,b,c,d)returnc*t/d+bendlocaldistance=50localduration=1functiondownFunc(v)returnlinear(v,0,distance,duration)endfunctionupFunc(v)returnlinear(v,distance,-distance,duration)endlocaleaseProp=0localtimeElapsed=0localcurrentFunc=downFunclocallastTime=time()localdt=0function_update()t=time()dt=t-lastTimelastTime=ttimeElapsed+=dtiftimeElapsed>durationthentimeElapsed=0ifcurrentFunc==downFuncthencurrentFunc=upFuncelsecurrentFunc=downFuncendendeaseProp=currentFunc(timeElapsed)endfunction_draw()rectfill(0,0,128,128,3)circfill(64,40+easeProp,20,15)end

You should get the following results:

Basic Usage Demo

Examples

You can find a test cart that allows you to cycle through all of the easing functions in thecart folderif you want to load it up into the console and play around with it!

Here are some example gifs:

Bounce Out

Out In Cubic

Credits

This library port wouldn't have been possible without the original easings functions byRobert Penner.

It also wouldn't have been anywhere near as easy without the Lua port for the functions byEmmanuelOga

About

A small library of tweening/easing functions for use in the PICO-8 fantasy console, inspired by Robert Penner's easing functions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp