/Pong_lua24

Pong replicated in Lua. An Assignment in the year 2024 by Harvard's Educational program. Leveraging LOVE V11.5 [Mysterious Mysteries]. Class URL { https://cs50.harvard.edu/games/2018/notes/0/ }

Primary LanguageLua

Lesson 1 Notes: Pong By: BinaryBitBytes

Lua Notes

Env & Global Variables Types

There are eight basic types in Lua:

  1. nil
  2. boolean
  3. number
  4. string
  1. function
  2. userdata
  3. thread
  4. table

Love2d

Framework

-- Load some default values for our rectangle.
function love.load() --[LOAD]
  x, y, w, h = 20, 20, 60, 20
end
-- Increase the size of the rectangle every frame.
function love.update(dt) --[UPDATE]
  w = w + 1
  h = h + 1
end
-- Draw a coloured rectangle.
function love.draw() --[DRAW]
   -- In versions prior to 11.0, color component values are (0, 102, 102)
  love.graphics.setColor(0, 0.4, 0.4)
  love.graphics.rectangle("fill", x, y, w, h)
end

Technologies

  1. love.load = This function is called exactly once at the beginning of the game.

love.load( arg, unfilteredArg )

table arg -Command-line arguments given to the game

  1. love.update = Callback function used to update the state of the game every frame.

love.update( dt )

number dt -Time since the last update in seconds.

  1. love.draw = Callback function used to draw on the screen every frame.

love.draw( )

No Arguments

  1. love.graphics = Drawing of shapes and images, management of screen geometry.

LÖVE's 2D Cordinate System

  • love.run = The main function, containing the main loop. A sensible default is used when left out.

mainLoop = love.run ( )