Giter Site home page Giter Site logo

playdate-fluid's Introduction

Fluid for Playdate

This library is written in Lua using the Playdate SDK. It provides a way to create, draw, animate, and interact with fluid. The library is a minimal simulation to keep it speedy on device, so it is constrained mostly to wave simulation. However, as this is open source, please feel free to add more functionality if you can keep it snappy.

fluid

Use

Create a fluid box.

local fluid = Fluid.new(0, 180, 400, 240-180)

Update fluid each frame to run simulation.

function playdate.update()
   fluid:update()
end

Draw the fluid using fill() or draw()

graphics.setColor(graphics.kColorBlack)
graphics.setDitherPattern(0.5)
fluid:fill()

Cause waves by providing an x coord along the surface of the fluid and a velocity to interact with. Negative velocity makes the fluid go up, positive makes the fluid go down.

fluid:touch(20, -4)

And some utility functions you can use.

fluid:getPointOnSurface(x) # returns an x,y pair of the x coord on the surface of the fluid polygon.
fluid:getWaveBounds() # returns the rect of the fluid currently taking into account the height of the tallest wave.
fluid:moveTo(x, y) # use to move the fluid rect to another location on screen and update the internal polygon.
fluid:moveBy(dx, dy) # use to move the fluid rect relatively to another location on screen and update the internal polygon.

playdate-fluid's People

Contributors

ericlewis avatar mierau 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

Watchers

 avatar  avatar

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.