'F' → Fullscreen
Copy template-game to 1-23-fleet:
local function drawShip(x, y, size) love.graphics.setColor(0.75, 0.82, 0.92) love.graphics.polygon("fill", x, y - size, x - size * 0.7, y + size, x + size * 0.7, y + size)
love.graphics.setColor(0.95, 0.55, 0.2) love.graphics.circle("fill", x, y + size * 0.35, size * 0.28)endCall it once at size 40, then 15, then 90. The shape must stay the same shape — only bigger.
love.graphics.polygon is new and it is the last drawing call this quarter. After "fill" it takes any number of x and y pairs and joins them up. Three pairs is a triangle.Put one hardcoded number back:
local function drawShip(x, y, size) love.graphics.polygon("fill", x, y - size, x - size * 0.7, y + size, x + size * 0.7, y + 40)endDraw it at 15, 40 and 90. Describe what happens to the shape at each size, then put the scaling back.
This is session 21's move-it test with one more dimension: it is not enough for the parts to move together, they have to grow together.
Three parallel tables, one loop, one call:
local xs = {140, 330, 520, 680}local ys = {180, 330, 200, 420}local sizes = {30, 70, 45, 25}
function love.draw() for i, x in ipairs(xs) do drawShip(x, ys[i], sizes[i]) endend
Add a fifth ship by adding three numbers. Count what is in your file: how many ships, how many drawShip calls are written out.
Open the file and list every function in it. For each one, write down who calls it:
| Function | Who calls it | Counts as student-developed? |
|---|---|---|
love.draw | ||
love.keypressed | ||
drawShip |
You wrote the body of all three. Only one of them is a procedure you developed, as far as the Create Task is concerned.
Pick one, and it has to work through drawShip rather than around it:
If you find yourself writing drawing code outside drawShip, stop and add a parameter instead.
Call drawShip(400, 300, 0) and then with a negative size.
Neither one is an error. Write down what you see in each case and what you think happened. Then decide whether a real program should let that happen, and say what you would do about it.
1-23-fleet draws four ships at four sizes from one functionAnswer the following questions before submitting your work.
love.draw and the body of drawShip. Explain why the College Board counts one and not the other, and say whether you think that is fair.Submit the required files to the appropriate dropbox.