StickHero
on Nexys A4 FPGA

Project Overview
StickHero is an FPGA hardware implementation of the popular mobile game where players control a stick figure traversing platforms by extending and retracting a bridge. The objective is to accurately time the bridge's extension to cross the gap between platforms. Overextending or undershooting the gap causes the player to fall into the abyss, triggering a game-over state.
The system is built entirely on a Digilent Nexys A4 FPGA using Verilog, implementing graphics generation, game state control, and user input directly in hardware logic without a CPU.
Technical Architecture
The project is structured modularly with a clear separation between display signals, coordinate control, and the main game logic:
vga_top.v: The top-level design module that wires together the clock, reset, physical buttons, and display outputs.display_controller.v: Manages the VGA display signalshSyncandvSyncto control horizontal and vertical pixel scan positions.block_controller.v: Directs physical user input (buttons) and pixel-generation logic for the game graphics.StickHero.v: The core of our design, which contains the main game loops, coordinates, and rules.
Game State Machine
The game rules and transitions are managed through a 5-state Finite State Machine (FSM) implemented inside the game logic:
1. INIT (Initialization)
- Initializes all active game variables.
- Sets the initial starting coordinates for the starting platform.
2. WAIT
- Sets up the target platform dynamically.
- Platforms are generated with widths ranging from $20\text$ to $200\text$ based on the player’s current score (decreasing in width as score increases)[cite: 1].
- Calculates the horizontal position ($X$) of the next platform relative to the character's coordinate and the next platform's width[cite: 1].
3. PLAY
- Up Button Held: The stick's length increments along the vertical ($Y$) axis, setting a register flag[cite: 1].
- Up Button Released: The vertical stick is instantly rotated (copied) onto the horizontal ($X$) axis to simulate the falling bridge motion[cite: 1].
4. MOVE
- Validates the length of the horizontal stick[cite: 1].
- If the bridge is too short or long, a
gameOverFlagis set[cite: 1]. - If successful, coordinates shift to slide the platforms to the left, creating a smooth camera-scrolling effect, and increments the score[cite: 1].
5. GAMEOVER
- Controls the downward physics animation of the character[cite: 1].
- Both blocks composing the player character decrement their height coordinates to simulate a plummet[cite: 1].
- Triggers a
fallingFlagwhich turns the screen red to signal defeat[cite: 1].
Key Engineering Challenges & Bugs
The Platform Generation Bug
A persistent challenge during development was creating robust procedurally-sized platforms[cite: 1]. Specifically, a mathematical bug was identified where every time the score becomes a multiple of 5, platform generation fails, leaving the stick character "floating" in mid-air[cite: 1].
The bug is traced to coordinate offsets and modulo operations when recalculating boundaries[cite: 1]:
// placement for curr platform inside StickHero.v
if (score == 0) begin
currxpos <= 200;
currypos <= 515;
currWidth <= 200;
currHeight <= 150;
end
else begin // Define currPlatform dimensions as previous nextPlatform dimensions
currWidth <= 200 - (((score - 1) % 5) * 35);
currHeight <= 150;
currxpos <= (guyxpos + 20) - nextWidth - 35; // <-- Platform bug occurs here
currypos <= 515;
end
How to Run It
- Open Xilinx Vivado.
- Create a new project targeting the Nexys A4 (XC7A100T).
- Import all
.vfiles from the stickHero Repository. - Add the nexys4.xdc constraint file to map the VGA pins, clock, and buttons.
- Generate Bitstream and program your FPGA board!
