--[[ Functions and constants for creating and using circles ]]-- -- It may make more sense to define these global constants in main.lua, -- but this shows that you can define constants in files as well. CIRCLE_DEFAULT_SPEED = 100 -- global constant CIRCLE_DEFAULT_SIZE = 30 -- global constant ---------------------------------------- -- Functions to create circle objects -- ---------------------------------------- --[[ Return a data object that has a circle's properties. ]]-- function createCircle(x_, y_, radius_, hSpeed_) local theCircle = { x = x_, y = y_, radius = radius_, hSpeed = hSpeed_ } return theCircle end -------------------------------------------------- -- Functions for using/modifying circle objects -- -------------------------------------------------- --[[ Move a circle to the right, wrapping it around when necessary. ]]-- function circleMoveHorizWrap(circle, dt) circle.x = circle.x + circle.hSpeed * dt if circle.x > (love.graphics.getWidth() + circle.radius) then circle.x = -circle.radius end end --[[ Render a circle on the screen. ]]-- function circleRender(circle) love.graphics.circle("fill", circle.x, circle.y, circle.radius) end