Back to Set 3

Code Challenge: Constellation

Difficulty  

divider

The Brief

What they asked for
Draw a named constellation. Real or invented. The stars are
different brightnesses, the lines join the ones that belong
together, and the name is on the screen.

Write your requirements list before you write any code. This set also asks you to name the table and the function before you start — what is in the table, and what your function takes and does.


Notes

  • The hardest one in this set and the closest to the creative artifact.
  • Two parallel tables for the positions, at least. A third for brightness or size.
  • The lines are the interesting part: a line joins star i to star i + 1, which means a loop that stops one early. Work out why before you write it.
  • A function that draws one star, taking position and brightness, is what makes the whole thing readable. Write it first.
  • love.graphics.line takes four numbers: two points. Nothing else on this page is new.

What Success Looks Like

  • Every star is drawn by one function, called in a loop
  • The lines connect the right stars and there is no line off the end
  • Stars differ visibly, from data rather than from separate code
  • Moving the whole constellation is a small change, not a rewrite

Add a star to the tables and run it. A new star and a new line should both appear with no other edit.


Submit

Your requirements list and your program folder, named cc-constellation.

Commence Challenge