Love - Drawing shapes

From TRCCompSci - AQA Computer Science
Revision as of 13:33, 4 June 2019 by Admin (talk | contribs) (Created page with "=Requirements= You need to have followed the installation process for the Love engine. You also need to have created a minimal game (ie a new folder, with a 'main.lua' file)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Requirements

You need to have followed the installation process for the Love engine.

You also need to have created a minimal game (ie a new folder, with a 'main.lua' file)

You need to have added this code to 'main.lua':

function love.load()

end

function love.update(dt)

end
 
function love.draw()

end

Drawing shapes

Now in the draw method add the following to draw a rectangle (or square):

love.graphics.rectangle('fill',0,0,100,50) -- 0,0 is the X & Y 100,50 is the Width & Height
love.graphics.rectangle('line', 150,0,200,200) -- 'fill' will fill the shape 'line' just give the outline

Now add the following to draw an circle:

love.graphics.circle('fill',0,250,100,100) -- 0,250 is the X & Y of the center point of the circle 100,100 is the Width & Height
love.graphics.circle('line', 150,250,200,200) -- 'fill' will fill the shape 'line' just give the outline