Part 2 mini-project: ASCII Name Banner
Your first proper project, using only what you have seen so far:
print and comments. The goal: print an ASCII art banner
that welcomes a player by name.
What to build
A program that prints a rectangular banner like this:
+----------------------------------+
| |
| WELCOME, PLAYER |
| |
| KEIKO |
| |
| Press ENTER to begin |
| |
+----------------------------------+
Requirements:
- One
printcall per line of output. - Top and bottom borders use
+at the corners,-along the edges. - Side borders use
|. - Put your own name (or a kid's name) in the middle, centred by eye. Pixel-perfect centring is not required.
- Add a
--[[ ]]multi-line comment at the top with two things: who it is for, and the date.
Files
Starter and finished versions live in
projects/01-name-banner/:
starter.lua— a skeleton with TODO comments. Open it and finish it.finished.lua— a working version. Look after you try yours, not before.
Run your version with:
lua projects/01-name-banner/starter.lua
Hints
- The width is up to you. A 36-character box (34 dashes between the
two
+) reads well on most terminals. - Count characters carefully. Off-by-one errors are common and visible. A crooked side border means your text and border are different lengths.
- Spaces between two
|make a blank row. You need at least two.
What you cannot use yet
- Variables. Type every string out fully on its own
printline. - Loops. There is no
forto repeat the dashes. - Functions of your own. Only the built-in
printis allowed.
These arrive in Part 3 and Part 4 and will make this program shorter and easier to change. For now, the long way is the right way.
Done?
When the banner looks right and the top comment says who it is for, you are done. Move on to Chapter 11 — Variables and types.