πŸ‡―πŸ‡΅ ζ—₯本θͺž | πŸ‡ΊπŸ‡Έ English
Advertisement

C Game Programming Projects

The phrase "I want to make it more fun" is what grows your coding skills the most.
Build the basic version first, then add your own twist through the extension challenges.

How to proceed: Each game has a "basic implementation" then "incremental extensions". Get the basic version working, then take on the extension challenges however you like. There's no single right answer.
🎯
GAME 1: Number Guessing Game
Beginner Random Loops Conditionals
Guess a secret number chosen by the computer using "higher / lower" hints.
🎯 Guess a number between 1 and 100! Guess> 50 Too low Guess> 75 Too high Guess> 63 πŸŽ‰ Correct! You got it in 3 tries!
1
Pick the answer randomly: use srand(time(NULL)) and rand() % 100 + 1 for a number from 1 to 100
2
Loop to accept input: use while to repeat until correct. Read the guess with scanf
3
Judge and display: if guess > answer print "Too high", if guess < answer print "Too low", equal means "Correct"
4
Count attempts: use an int variable to count tries, print it on correct answer
Extension Challenges
  • Rate the player depending on how many tries it took (<=5 = "Genius!", <=10 = "Not bad", etc.)
  • Add difficulty selection (Easy: 1-50, Normal: 1-100, Hard: 1-1000)
  • Implement a "play again?" feature with do-while
  • Compute and show the max attempts needed with binary search
  • Add an attempt limit and make it game over if exceeded
Skeleton:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {
    srand((unsigned)time(NULL));
    int answer = rand() % 100 + 1;
    int guess, count = 0;

    printf("Guess a number between 1 and 100!\n");
    do {
        printf("Guess> ");
        scanf("%d", &guess);
        count++;
        if (guess > answer) printf("Too high\n");
        else if (guess < answer) printf("Too low\n");
    } while (guess != answer);

    printf("Correct! Got it in %d tries!\n", count);
    return 0;
}
✊
GAME 2: Rock Paper Scissors
Beginner switch Random Arrays
Play rock-paper-scissors against the computer. Record results and display the win/loss record.
βœŠβœŒβœ‹ Rock-Paper-Scissors (0:Rock 1:Scissors 2:Paper -1:Quit) You> 0 You: Rock vs CPU: Scissors πŸŽ‰ You win! You> 2 You: Paper vs CPU: Paper 😐 Draw! You> -1 --- Record --- 3W 1L 1D (win rate 60.0%)
1
Store hand names in an array: char *hands[] = {"Rock","Scissors","Paper"};
2
Judging logic: (player - cpu + 3) % 3 gives 0=draw, 1=lose, 2=win
3
Record-keeping: count 3 variables: wins / losses / draws
4
Exit: break the loop on -1 input, then display the record
Extension Challenges
  • Add best-of-three mode (first to 2 wins)
  • Record player hand frequencies and make the CPU a "learning AI" that counters them
  • Expand to "Rock-Paper-Scissors-Lizard-Spock" (5 choices)
  • Save match history to an array and print the full history at the end
Judging trick:
// 0=Rock, 1=Scissors, 2=Paper
int result = (player - cpu + 3) % 3;
if (result == 0) printf("Draw\n");
else if (result == 2) printf("You win!\n");
else printf("You lose...\n");
🎰
GAME 3: Slot Machine
Beginner Random Arrays Conditionals
Spin three reels to match symbols. Track the player's coin balance as it rises and falls.
🎰 Slot Machine (Coins: 100) Press Enter to spin (10 coins/spin)> | πŸ’ | πŸ‹ | πŸ’ | β†’ No match Coins left: 90 Press Enter> | 7️ | 7️ | 7️ | β†’ πŸŽ‰ JACKPOT! +500 coins! Coins left: 580
1
Symbols in an array: e.g. char *symbols[] = {"πŸ’","πŸ‹","πŸ””","⭐","7"};
2
Randomize three reels: call rand() % num_symbols three times
3
Check wins: three matching = jackpot, two matching = small win, otherwise no match
4
Manage coins: subtract 10 per spin, add winnings on a match. Game over when coins reach 0
Extension Challenges
  • Different payouts per symbol (e.g. three 7's pays the most)
  • Bias the reel probabilities (make 7 rare)
  • Let the player choose their bet amount
  • Save history to a file and reload on startup
β­•
GAME 4: Tic-Tac-Toe
Intermediate 2D Arrays Functions Loops
Alternate placing O and X on a 3x3 board. First to make a line wins. Manage the board with a 2D array.
1 | 2 | 3 ---+---+--- 4 | 5 | 6 ---+---+--- 7 | 8 | 9 O's turn cell#> 5 | | ---+---+--- | O | ---+---+--- | | X's turn cell#> 1 X | | ---+---+--- | O | ---+---+--- | |
1
Represent the board with a 2D array: char board[3][3]. Empty=' ', O='O', X='X'
2
Board print function: void print_board(char board[3][3]) with separator lines
3
Win-check function: check all 8 lines (3 rows, 3 cols, 2 diagonals)
4
Input validation: reject taken cells; non-1-9 inputs trigger re-entry
Extension Challenges
  • Add a CPU opponent (random empty cell)
  • Make the CPU smarter (prefer corners, block reaches)
  • Expand to 4x4 or 5x5 (4-in-a-row)
  • Record stats to a file and display totals
  • Implement a perfect minimax AI (advanced)
Win-check trick:
int check_win(char b[3][3], char c) {
    for (int i = 0; i < 3; i++) {
        if (b[i][0]==c && b[i][1]==c && b[i][2]==c) return 1; // row
        if (b[0][i]==c && b[1][i]==c && b[2][i]==c) return 1; // col
    }
    if (b[0][0]==c && b[1][1]==c && b[2][2]==c) return 1; // diag
    if (b[0][2]==c && b[1][1]==c && b[2][0]==c) return 1; // diag
    return 0;
}
πŸƒ
GAME 5: Maze Escape
Intermediate 2D Arrays Structs Functions
Represent a maze with a 2D array. Move the player with WASD to reach the goal.
################ #P.....#.......# #.####.#.#####.# #......#.#...#.# ######.#.#.#.#.# #......#...#...# #.##########.### #..............G ################ Move (w/a/s/d)> d
1
Maze data: char maze[H][W] where '#'=wall, '.'=path, 'P'=player, 'G'=goal
2
Store the player position in a struct: struct Pos { int x, y; };
3
Movement logic: update the position if the destination isn't a wall; otherwise print "Can't move"
4
Goal check: clear the maze when the player's position matches G
Extension Challenges
  • Count the number of moves as a score
  • Add a locked door that requires picking up a key
  • Add randomly moving enemies β€” touching them is game over
  • Read the maze from a file
  • Try a maze generation algorithm (e.g. recursive backtracker)
  • Limit "vision" to 3 cells around the player
πŸƒ
GAME 6: Blackjack
Intermediate Structs Arrays Functions Random
Classic blackjack. Get as close to 21 as possible without going over. Represent cards with a struct.
πŸƒ Blackjack Your hand: [β™ A] [β™₯K] β†’ Total: 21 Dealer: [♦7] [??] Hit(h) / Stand(s)> s Dealer hand: [♦7] [♣9] β†’ Total: 16 Dealer hits: [β™ 5] β†’ Total: 21 😐 Push!
1
Represent a card as a struct: struct Card { int suit; int rank; };
2
Build a 52-card deck and shuffle: Fisher-Yates shuffle
3
Hand-total function: pick Ace as 1 or 11, whichever keeps you under 22
4
Dealer AI: keep hitting until total is 17 or higher (standard rule)
Extension Challenges
  • Add chips and a betting system
  • Implement double-down, split, and surrender
  • Support multi-deck shoes (6 decks, etc.)
  • Add a card counting practice mode
πŸ“
GAME 7: Hangman (Word Guessing)
Intermediate Strings Arrays Loops
Guess the hidden word one letter at a time. A fixed number of wrong guesses ends the game. Great practice for string manipulation.
Guess the word! (misses left: 6) _ _ _ _ _ _ _ _ _ Letter> e _ _ _ _ _ _ _ _ e β­• Letter> a No match ❌ (left: 5) Letter> r _ r _ _ r _ _ _ e β­•
1
Prepare a word list as an array: char *words[] = {"programming","computer",...};
2
Track revealed letters in an array: int revealed[MAX]
3
Match input against every position: use a for loop, reveal any matching letter
4
End condition: all letters revealed = win; too many misses = lose
Extension Challenges
  • Draw the hangman progressively in ASCII art
  • Word length varies by difficulty
  • Display letters already used
  • Read the word list from a file
  • Multi-language version (e.g. topic categories)
βš”οΈ
GAME 8: Text RPG Battle
Advanced Structs Pointers Functions Random
Turn-based combat between hero and monster. Store stats in a struct and choose attack/defend/magic commands.
βš”οΈ A Slime appears! Hero HP:100/100 MP:30/30 Slime HP:50/50 1:Attack 2:Defend 3:Magic > 1 Hero attacks! Slime takes 15 damage! Slime HP: 35/50 Slime attacks! Hero takes 8 damage! Hero HP: 92/100
1
Character struct: struct Character { char name[20]; int hp, max_hp, mp, atk, def; };
2
Damage function: int calc_damage(int atk, int def) β€” add random variance
3
Command choice: switch between attack/defend/magic
4
Battle loop: repeat until one side's HP drops to 0 or below
Extension Challenges
  • Store multiple enemies in an array for consecutive battles
  • Add experience points and leveling up
  • Item inventory (array of items, potions, etc.)
  • Smarter enemy AI (e.g. heals when low HP)
  • Add boss-fight special effects
  • Save/Load with file I/O
πŸ’£
GAME 9: Minesweeper
Advanced 2D Arrays Recursion Functions
Avoid mines while revealing every safe cell. The core challenge is counting neighboring mines and cascading opens (recursion).
1 2 3 4 5 1 . . . . . 2 . . . . . 3 . . . . . 4 . . . . . 5 . . . . . Open (row col)> 3 3 1 2 3 4 5 1 1 . . . 2 1 2 . . 3 1 . . 4 1 2 . 5 1 .
1
Use two 2D arrays: int mines[H][W] (mine positions) and int visible[H][W] (reveal state)
2
Randomly place mines: place the specified count at random cells (avoiding duplicates)
3
Neighbor count: examine 8 neighbors and count mines
4
Cascade open (recursion): when opening a cell with 0 neighbors, recursively open its neighbors
Extension Challenges
  • Add a flagging feature (mark suspected mines)
  • Make the first click never hit a mine
  • Let the player choose board size and mine count
  • Measure and display the clear time
  • Save high scores to a file
🧱
GAME 10: Falling Block Puzzle (Tetris-like)
Advanced 2D Arrays Structs Timer
Blocks fall from the top and clear when a row fills. The ultimate text-mode Tetris-like challenge.
| | | | | | | ## | | ## | | | | | | # | | ### | | #### ## | +----------+ Score: 100 Level: 1
1
Represent the field with a 2D array: stores locked blocks
2
Define tetrominoes with a struct + arrays: 7 shapes as 4x4 arrays
3
Collision detection: ensure the rotated/moved piece doesn't overlap walls or locked blocks
4
Line clear: remove full rows and drop everything above
Extension Challenges
  • Preview the next piece
  • Increase falling speed with level
  • Hold feature (stash one piece)
  • Save high scores to a file
Hint: For real-time input in a terminal, you'll need non-blocking input via termios.h (Linux/Mac) or conio.h (Windows). It's easiest to start with a turn-based version that waits for each input.

Roadmap

Difficulty increases as you go. Start with GAME 1-3, then once you're confident tackle 4-7.
Beginner
Number Guess
Beginner
RPS
Beginner
Slot Machine
Intermediate
Tic-Tac-Toe
Intermediate
Maze
Intermediate
Blackjack
Intermediate
Hangman
Advanced
RPG Battle
Advanced
Minesweeper
Advanced
Tetris-like
Share this article
Share on X Share on Facebook