joebrogers / pico-tween Goto Github PK
View Code? Open in Web Editor NEWA small library of tweening/easing functions for use in the PICO-8 fantasy console, inspired by Robert Penner's easing functions.
License: MIT License
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
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.