Coder Social home page Coder Social logo

joebrogers / pico-tween Goto Github PK

View Code? Open in Web Editor NEW
74.0 3.0 2.0 243 KB

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

License: MIT License

Lua 100.00%
pico-8 pico8 lua lua-library game game-development game-engine game-2d gamedev games

pico-tween's People

Contributors

assisrmatheus avatar joebrogers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pico-tween's Issues

Tween instances interfering with each other

I'm having an issue with this library. When I create multiple instances of a tween, they seem to be interfering with each other. Lets say I have a tween for the player in the player class:

pl={
 x=0,
 y=0,
 sprite=0
}
pl.tween=tween_machine:add_tween({
 func=inback,
 duration=0.45
})
pl.tween:register_step_callback(pl_update_y)
pl.tween:register_finished_callback(pl_tween_end)

That works as expected. However, when I try to update tweens created for enemy objects, the enemy movement (processed by the enemy tween) is causing the player to move erratically. When I remove the enemy tween the player tween works fine again. Here's how I create enemy objects:

enemy_group1={}
for i=1,max_group_enemies do
  enemy={
   etype=1,
   width=0,
   height=0,
   edir=⬅️,
   tween=tween_machine:add_tween({})
  }
add(enemy_group1,enemy)

Basically, each enemy has its own tween, and is updated each frame like this:

if e.state==1 then
  e.tween.v_start=135
  e.tween.v_end=-15
  e.tween.duration=4.27
  e.tween.func=linear
  e.state=2
 else
  e.x=e.tween.value
  if e.x<-8 then
   e.alive=false
   enemies_alive-=1
  end
end

The only difference between the two (player/enemy) tweens is that I use a callback for the player tween to update player position, but access the tween's value directly to update enemy positions.

I'm new to pico-8 development, so it's quite possible I'm misunderstanding something on the Lua side of things. Any help much appreciated, and thanks for the library!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.