Log In  
Follow
PixcelDev
[ :: Read More :: ]

To all of you users maintaining public Github repositories of either your games or supporting libraries for other PICO-8 users, I've just put up a repository containing PICO-8 badges.

This way you can add a Made With PICO-8 badge to your readme, alongside any other repo related badges you generally use!

Show your support for the tool and enjoy!

Link: https://github.com/JoebRogers/MadeWithPICO-8Badges

P#58569 2018-10-31 11:42 ( Edited 2018-10-31 15:42)

[ :: Read More :: ]

Cart #52473 | 2018-05-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

The demo cart for my tweening/easings library PICO-Tween.

You can see the thread for the library here: https://www.lexaloffle.com/bbs/?tid=31241

Alternately you can view the repository here: https://github.com/JoebRogers/PICO-Tween


The cart just demonstrates all the available easing functions provided with the library (all easing functions from the traditional Robert Penner easing libraries are ported).

Left Arrow and Right Arrow to cycle through the different easings.

Enjoy!

P#52475 2018-05-06 20:08 ( Edited 2018-05-07 13:28)

[ :: Read More :: ]

Hey all!

I've recently worked on a couple of different libraries for the PICO-8, which are available on Github. I've posted them around on the subreddit and Discord server to good responses, however have held back from posting here until now!

So without further adieu..

PICO-Tween - Repository

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

It comes packaged with some various sourced and ported additional math functions to make some things work, such as asin and acos.

It comes with a pretty hefty token count if using every tween, at 2083 tokens, however on average each easing function is only around 40-60 tokens so can just be picked out and slotted in where appropriate along with any math dependencies.

It should come pretty easy to use, if you have any experience with tweens, particularly of the Penner variety, in any other language or framework. Here's a small code example that you can paste directly into a cart to see how to get set up with something basic like linear tween:

function linear(t, b, c, d)
  return c * t / d + b
end

local distance = 50
local duration = 1

function downFunc(v)
  return linear(v, 0, distance, duration)
end

function upFunc(v)
  return linear(v, distance, -distance, duration)
end

local easeProp = 0
local timeElapsed = 0
local currentFunc = downFunc
local lastTime = time()
local dt = 0

function _update()
  t = time()
  dt = t - lastTime
  lastTime = t
  timeElapsed += dt

  if timeElapsed > duration then
    timeElapsed = 0
    if currentFunc == downFunc then currentFunc = upFunc else currentFunc = downFunc end
  end

  easeProp = currentFunc(timeElapsed)
end

function _draw()
  rectfill(0, 0, 128, 128, 3)
  circfill(64, 40 + easeProp, 20, 15)
end

Which should net you the following results on screen:

For more example gifs, a demo cart which allows you to cycle through all available tweening functions, and of course the source code, please check out the repository here: Repository

PICO-TweenMachine - Repository

However, whilst that's all well and good, it can get quite cumbersome to keep track of and add tween code. There's a lot of increasingly painful boilerplate and it can introduce mess into your codebase pretty quickly.

Not to mention that it can be a bit confusing to both read and write for those less experienced!

That's where PICO-TweenMachine comes in! PICO-TweenMachine is a small wrapper extension library intended to support the PICO-Tween library by removing the excess noise of writing tweens and driving them from a centralized place.

Instead of the traditional approach, that's all taken care of by the tween_machine object, leaving you to simply set up your tween object with the values you want, such as start and end point, duration and tween type, then leave the wrapper to drive the rest.

All you need to do is add your object to the wrapper, set up any callbacks you may like to occur during step events or upon tween completion and then call it in your update function.

Here's a code example taking the earlier sample and porting it for use with the new library (this sample assumes the PICO-TweenMachine library is pasted to the top of the cart and won't run just by pasting in this sample):

function linear(t, b, c, d)
  return c * t / d + b
end

local move_distance = 30
local move_duration = 1
local easeprop = 0

function set_ball_position(position)
    easeprop = position
end

function reverse_ball_direction(tween)
    tween.v_start = tween.v_end
    tween.v_end = -tween.v_end
    tween:restart()
end

function _init()
    ball_tween = tween_machine:add_tween({
        func = linear,
        v_start = -move_distance,
        v_end = move_distance,
        duration = move_duration
    })
    ball_tween:register_step_callback(set_ball_position)
    ball_tween:register_finished_callback(reverse_ball_direction)
end

function _update()
  tween_machine:update()
end

function _draw()
  rectfill(0, 0, 128, 128, 3)
  circfill(64, 60 + easeprop, 20, 15)
end

As you can see, this approach is much clearer and easy to both understand and extend.

The library is both simple to set up and use, as well as very light at only 239 tokens.

Example Images

Links

Hopefully some of you will appreciate this, if so, please go ahead and test out the demo carts, download the sources and use these libraries in your own projects! I would also appreciate the stars on Github. ;)

PICO-Tween - Repository
PICO-TweenMachine - Repository

Thank you all for reading, I appreciate it!

P#52433 2018-05-05 21:00 ( Edited 2018-05-06 01:00)

Follow Lexaloffle:          
Generated 2024-04-19 08:54:37 | 0.068s | Q:10