Menu controls
The game starts with a main menu screen showing the Pacman logo and ghost characters.Main menu
| Key | Action |
|---|---|
SPACE | Start the game |
ESC | Exit to system |
The menu features animated ghosts moving across the screen. Wait for them to complete their animation or press SPACE to begin immediately.
Game controls
Once in the game, use arrow keys to navigate Pacman through the maze.Movement keys
- Arrow keys
- System keys
| Key | Direction | Code |
|---|---|---|
↑ | Move up | SDLK_UP |
↓ | Move down | SDLK_DOWN |
→ | Move right | SDLK_RIGHT |
← | Move left | SDLK_LEFT |
Movement mechanics
The control system has several important characteristics:Movement validation
The game checks if the desired direction is valid (not a wall):
- If valid: Pacman moves in that direction
- If blocked: Input is buffered until the next valid position
Understanding the movement code
Understanding the movement code
The game uses a grid-based movement system:Position updates occur at:
- Grid size: 32x26 cells (MAXX_A x MAXY_A)
- Cell spacing: 8 pixels (ESCALA)
- Movement speed: Variable based on level (0.4 to 0.7)
Gameplay mechanics
Understanding the core game elements and how they interact.Maze elements
The maze contains several types of elements:| Element | Symbol | Description |
|---|---|---|
| Walls | 0 | Impassable barriers |
| Paths | C | Paths with dots to collect |
| Empty | N | Empty spaces (ghost house) |
| Visited | J | Paths where dots were collected |
| Door | P | Ghost house door (closed) |
| Power pellets | B | Large dots that frighten ghosts |
Collecting dots
The primary objective is collecting all dots in the maze.Track progress
Total dots to collect: 226 (NUM_PUNTOS)Points per dot: 10Your score increases as you collect each dot.
Power pellets
Four large power pellets are positioned at the maze corners. Locations:- Top-left corner: (7, 1)
- Top-right corner: (27, 1)
- Bottom-left corner: (7, 24)
- Bottom-right corner: (27, 24)
- Scoring
- Ghost behavior
- Duration
Power pellet value: 50 points
Ghost mechanics
Four ghosts chase Pacman through the maze, each with distinct behavior.Ghost types
The four ghosts have different AI patterns:- Blue (Azul)
- Red (Rojo)
- Yellow (Amarillo)
- Gray (Gris)
Index: 0Strategy: Follows Pacman’s previous positionBehavior: Trails behind where Pacman was, attempting to cut off escape routes.
Ghost states
Ghosts can be in three different states:Normal state (0)
Normal state (0)
Appearance: Colored sprites (red, blue, yellow, gray)Behavior:
- Chase Pacman according to AI pattern
- Deadly on contact
- Move at level-specific speed
Frightened state (1)
Frightened state (1)
Appearance: Blue ghosts (vulnerable)Triggered by: Collecting a power pelletBehavior:
- Flee from Pacman
- Move to random locations
- Can be eaten
Dead state (2)
Dead state (2)
Appearance: Just eyesBehavior:
- Return to ghost house
- Cannot harm Pacman
- Target position (16, 12) - ghost house center
Eating ghosts
When you catch a frightened ghost, you earn points:- 1st ghost: 50 points
- 2nd ghost: 100 points
- 3rd ghost: 150 points
- 4th ghost: 200 points
Eating all four ghosts during one power pellet gives you a total of 500 bonus points (50+100+150+200).
Special features
Advanced mechanics that affect gameplay.Tunnels
The maze has vertical tunnels for quick travel:Ghost house
Ghosts start in the central ghost house and are released in sequence: Release timing:- Blue ghost: Ticks 50-100 (leaves first)
- Red ghost: Ticks 100-150
- Yellow ghost: Ticks 150-200
- Gray ghost: Ticks 200-240
Collision detection
The game uses distance-based collision detection:Scoring system
Understand how points are awarded.Point values
| Item | Points |
|---|---|
| Dot | 10 |
| Power pellet | 50 |
| 1st ghost | 50 |
| 2nd ghost | 100 |
| 3rd ghost | 150 |
| 4th ghost | 200 |
Score calculation
Maximum points per level:Game progression
How the game difficulty increases.Level system
Starting configuration:Speed progression
Ghost speed increases with each level:Lives system
You start with 2 lives (3 total including current):num_vidas < 0 (all lives lost)
Strategy tips
Master the game with these proven strategies.Dot collection strategy
Clear corners first
Start by clearing dots near power pellets, saving the pellets for when ghosts get close.
Ghost evasion
Know your enemies
Know your enemies
- Red ghost is most dangerous - always knows your position
- Blue ghost follows where you were - change direction frequently
- Yellow and gray ghosts only chase when close - keep distance
Cornering technique
Cornering technique
When a ghost is approaching:
- Wait at a junction
- Let the ghost commit to a direction
- Quickly turn perpendicular to escape
Power pellet timing
Optimal usage
Optimal usage
Best times to grab a power pellet:
- When multiple ghosts are nearby
- When trapped with limited escape routes
- When you can position yourself to catch multiple ghosts
Ghost hunting
Ghost hunting
After eating a power pellet:
- Red ghost - Easiest to catch (always coming toward you)
- Chase other ghosts quickly before effect wears off
- Remember: 4 ghosts = 500 bonus points
Advanced techniques
Ghost house timing
Ghost house timing
Remember ghost release timing:
- Early game: Fewer ghosts active
- Wait for ghosts to exit before entering central area
- Use this time to clear nearby dots safely
Speed advantage
Speed advantage
Early levels (0-12): You’re faster or equal to ghosts
- Use your speed to your advantage
- Circle back on slower ghosts
- Create distance when needed
- Rely more on strategy than speed
- Use walls and turns to break line of sight
- Power pellets become essential
Animation and visuals
Understanding the visual feedback.Pacman animation
Pacman has 3 animation frames per direction:Ghost animation
Ghosts alternate between 2 frames:Visual states
- Normal gameplay
- Frightened mode
- Death
- Colored ghosts (red, blue, yellow, gray)
- Pacman chomping in movement direction
- Dots and power pellets visible
Next steps
Now that you understand the controls and mechanics:- Review the building guide to compile the game
- Check the running guide for launch options
- Explore
src/teclado.cfor input handling details - Study
src/mov_fig.cfor movement mechanics