Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 3.08 KB

README.md

File metadata and controls

34 lines (29 loc) · 3.08 KB

Lua Math

This repository consists of coding examples and demos inspired by Keith Peters' Coding Math YouTube videos.

While Keith's examples are done using the HTML5 <canvas> element and JavaScript, I'm re-creating them (to the best of my ability) using Lua 5.3 and LÖVE 2D.

This is just to help myself learn Lua and math.

To run any of the demos, ensure you have LÖVE 2D and Lua 5.3 installed and in your path, then either enter love episode# where # is the number of the episode you'd like to run, or cd into an Episode's directory and type love . in the console.

  • Episode 1 - Introduction: Draw 100 random black lines on a white background (also, establish boilerplate, which lives in the root directory as main.lua)
  • Episode 2 - Intro to Trigonometry: Draw a black sine wave on a white background
  • Episode 3 - More Trigonometry: Use the sine function to animate a black circle in several ways:
    • moving up and down
    • growing and shrinking
    • fading in and out
  • Episode 4 - Circles, Ellipses and Lissajous Curves: Use the sine and cosine funcitons to:
    • animate objects along a circle, ellipse, or lissajous curve
    • draw n number of objects evenly spaced around a circle
  • Episode 5 - Arctangent: Use atan functions to:
    • make a fixed arrow always point to the position of the mouse cursor
    • make an arrow orbiting the center of the window always point toward the position of the mouse cursor
  • Episode 7 - Vectors Part 2: Write a minimal 2D Vector library containing several methods:
    • create, getX, getY, getAngle, getLength
    • setX, setY, setAngle, setLength (mutating)
    • add, subtract, multiply, divide (return new)
    • addTo, subtractFrom, multiplyBy, divideBy (mutating)
  • Episode 8 - Velocity: Write a basic particle library and animate some particles using vector addition.
  • Episode 9 - Acceleration: Add acceleration to a couple of the animations from Episode 8
    • cause a ball to arc across the screen from bottom left to bottom right, following an acceleration curve.
    • add gravity to the 'fireworks' particle burst, giving it a more realistic appearance. (To run, from root folder, type love episode09/fireworks)
  • Episode 10 - Advanced Acceleration: Draw a space ship that behaves similarly to the player's ship in the classic Asteroids video game:
    • it can be rotated using the right and left arrow keys
    • it will thrust in the direction it's pointing when the up arrow key is pressed