0Pricing
Lua Academy · Lesson

Drawing Shapes and Images

Put graphics on screen.

The love.graphics Module

All rendering in LÖVE happens through love.graphics. You call its functions inside love.draw, and the engine presents the frame when the callback returns.

It can draw primitive shapes, images, text, and lines, plus manage colors and transforms. Everything is redrawn from scratch every frame.

Drawing Rectangles

love.graphics.rectangle takes a mode then position and size. The mode is either 'fill' for a solid shape or 'line' for just the outline.

Coordinates start at the top-left corner of the window, with x increasing to the right and y increasing downward.

function love.draw()
  love.graphics.rectangle('fill', 50, 50, 120, 80)
  love.graphics.rectangle('line', 200, 50, 120, 80)
end

All lessons in this course

  1. The LOVE Game Loop
  2. Drawing Shapes and Images
  3. Handling Input
  4. Movement and Collisions
← Back to Lua Academy