C · Local Linux terminal
Animate a chain of four moving characters
Online version: https://fpga.labsland.com/altera/embedded-systems/lab-05/part-04/
Your computer
Four colored characters move diagonally on a 30-column by 12-row display. Each reverses its horizontal or vertical direction at the corresponding wall. Connect A to B, B to C and C to D. Draw the dotted links first so the colored endpoints remain visible.
Use a Linux terminal of at least 32 columns by 14 rows. Compile the extracted starter and run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal 35 180 24
The arguments are frame count, delay in milliseconds and random seed. Start with the same seed twice. Find a frame in which D is far from the other characters. Which of the three expected links is missing? Examine the bounds of the loop that connects adjacent objects. Repair the code without closing the chain from D back to A.
| Test | What to record |
|---|---|
| Seed 24 repeated | Initial positions and the two ends of the missing link |
| Seed 91 | A different arrangement and the same three connections |
| One vertical and one horizontal bounce | Which coordinate changes direction in each case |
| A run stopped with Ctrl-C | Whether the cursor returns and the color resets |
Try ./terminal 0 100 24 for a continuous run with a repeatable seed. Submit sketches or screenshots of two successive frames and explain why the endpoints are drawn after the links. When two objects occupy one cell, use a later frame to identify them separately.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part IV. Original handout · MIT
