'F' → Fullscreen
Copy template-game to 1-07-move and start from what you already know:
local x = 100
function love.draw() love.graphics.circle("fill", x, 300, 40)endRun it. Nothing surprising — but that circle is being drawn about 3,600 times a minute.
Put love.update above love.draw:
local x = 100
function love.update(dt) x = x + 2end
function love.draw() love.graphics.circle("fill", x, 300, 40)endRun it. Then change the 2 and run again — try 10, then 0.5, then -2. Write down what each one does.
local x = 100 inside the update box and run it. The circle stops dead. Work out why before you move it back — this is the session-3 rule finally earning its keep.print still works in a graphics program. The output goes to the terminal panel while the window is open:
function love.update(dt) x = x + speed * dt print(x)end103.33333333333106.66666666667110...796.66666666667800803.33333333334The circle left the window and the number kept going. Let it run past 800 and write down what it says. Nothing is wrong; nothing told it to stop.
Take the print line back out before the next task. Sixty lines a second fills a terminal fast.
Replace the moving line with the honest version:
local x = 100local speed = 200
function love.update(dt) x = x + speed * dtendspeed is now measured in pixels per second. Set it to 800 and the circle crosses the window in one second. Time it.
Then set it to 50, then -200. Write down how long each crossing takes.
Give it a second speed and move both coordinates:
local x = 100local y = 100local speedX = 200local speedY = 120
function love.update(dt) x = x + speedX * dt y = y + speedY * dtendThen make it move up and to the left instead, without changing anything except two numbers.
Nothing says the changing variable has to be a position. Make the radius grow instead: radius = radius + 30 * dt, with the circle standing still.
Then try growing and moving at the same time, and try a negative growth rate. Watch what the circle does as the radius passes zero, and write down whether Lua complains about it.
1-07-move has a circle that crosses the window and leavesx = x + speed * dt, not x = x + 2x and speed are declared above both boxesx was moved inside the boxAnswer the following questions before submitting your work.
local x = 100 inside love.update stopped the circle. Describe what happens to x on each of the sixty frames in that version.x = x + 2 and x = x + 200 * dt look about the same on your computer. Describe a situation where they behave completely differently, and say which one you would rather have written.Submit the required files to the appropriate dropbox.