Sodapop - sprite and animation library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Sodapop - sprite and animation library

Post by Tesselode » Sun Feb 21, 2016 9:46 pm

GitHub link!

Sodapop is a library that creates sprite objects. You can add different animations with different images to each sprite and switch between them at will. It has a similar use case to kikito's anim8, but it also manages the different states and properties an object in your game might have. Basically, it's a little higher level than something like anim8.

Code example!

Code: Select all

function love.load()
  sodapop = require 'sodapop'

  playerSprite = sodapop.newAnimatedSprite(100, 200)
  playerSprite:addAnimation('walk', {
    image        = love.graphics.newImage 'walk.png',
    frameWidth   = 64,
    frameHeight  = 64,
    frames       = {
      {1, 1, 4, 1, .2},
    },
  })
  playerSprite:addAnimation('burrow', {
    image       = love.graphics.newImage 'burrow.png',
    frameWidth  = 64,
    frameHeight = 64,
    stopAtEnd   = true,
    frames      = {
      {1, 1, 12, 1, .05},
    },
  })
  playerSprite:addAnimation('unburrow', {
    image        = love.graphics.newImage 'burrow.png',
    frameWidth   = 64,
    frameHeight  = 64,
    stopAtEnd    = true,
    reverse      = true,
    onReachedEnd = function() playerSprite:switch 'walk' end,
    frames       = {
      {1, 1, 12, 1, .05},
    },
  })
end

function love.update(dt)
  playerSprite:update(dt)
end

function love.keypressed(key)
  if key == 'left' then playerSprite.flipX = true end
  if key == 'right' then playerSprite.flipX = false end
  if key == 'down' then playerSprite:switch 'burrow' end
  if key == 'up' then playerSprite:switch 'unburrow' end
end

function love.draw()
  playerSprite:draw()
end
It's still in pretty early development, but I'm using it in a game and it's going pretty well so far. Let me know what you think! Give me feedback! Do pull requests! All that good stuff.

User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Sodapop - sprite and animation library

Post by Kingdaro » Mon Feb 22, 2016 12:08 am

This looks really great. Nice work. :awesome:

User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Sodapop - sprite and animation library

Post by Tesselode » Mon Feb 22, 2016 2:16 am

Thanks. :)

User avatar
D0NM
Party member
Posts: 235
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: Sodapop - sprite and animation library

Post by D0NM » Wed Feb 24, 2016 6:47 am

It looks like a nicely improved http://www.buildandgun.com/2014/07/anim ... ove2d.html

^__-
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:

User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Sodapop - sprite and animation library

Post by Tesselode » Thu Feb 25, 2016 5:00 am

D0NM wrote:It looks like a nicely improved http://www.buildandgun.com/2014/07/anim ... ove2d.html

^__-
Hey, so it does! I've never seen that before, but great minds think alike I suppose. :P

Post Reply

Who is online

Users browsing this forum: noahnadai and 16 guests