Python Game Development
Summer Crash Course
For SSC & Intermediate Students
(Zero Theory, 100% Practical Game Coding - Day by Day Guide)
Week 1: Arcade-Style Games
Day 1: Guess the Number Game
What You'll Build: A game where the computer picks a random number
(1-100) and the player guesses it.
python
Copy
import random
number = random.randint(1, 100)
attempts = 0
print("Guess the number (1-100)!")
while True:
guess = int(input("Your guess: "))
attempts += 1
if guess < number:
print("Too low!")
elif guess > number:
print("Too high!")
else:
print(f"Correct! You took {attempts} attempts.")
break
Mod Challenge: Add limited attempts (e.g., 10 tries max).
Day 2: Rock-Paper-Scissors
What You'll Build: Play against the computer in this classic game.
python
Copy
import random
choices = ["rock", "paper", "scissors"]
computer = random.choice(choices)
player = input("Choose rock/paper/scissors: ").lower()
print(f"Computer chose: {computer}")
if player == computer:
print("Tie!")
elif (player == "rock" and computer == "scissors") or \
(player == "paper" and computer == "rock") or \
(player == "scissors" and computer == "paper"):
print("You win!")
else:
print("Computer wins!")
Mod Challenge: Add a best-of-5 rounds system.
Day 3: Dice Rolling Simulator
What You'll Build: Simulate rolling dice with customizable sides.
python
Copy
import random
def roll_dice(sides=6):
return random.randint(1, sides)
print("Dice Rolling Simulator!")
sides = int(input("How many sides? (Default: 6) ") or 6)
while True:
input("Press Enter to roll (or 'q' to quit)...")
if input().lower() == 'q':
break
print("You rolled:", roll_dice(sides))
Mod Challenge: Add a 2-player mode.
Day 4: Hangman Game
What You'll Build: Guess letters to save a stick figure from hanging!
python
Copy
import random
words = ["python", "programming", "hangman", "computer"]
word = random.choice(words)
guessed = ["_"] * len(word)
tries = 6
print(" ".join(guessed))
while tries > 0 and "_" in guessed:
guess = input("Guess a letter: ").lower()
if guess in word:
for i, letter in enumerate(word):
if letter == guess:
guessed[i] = guess
else:
tries -= 1
print(f"Wrong! {tries} tries left.")
print(" ".join(guessed))
if "_" not in guessed:
print("You won!")
else:
print(f"Game over! The word was: {word}")
Mod Challenge: Add a scoreboard.
Week 2: Advanced Arcade Games
Day 5: Tic-Tac-Toe (2 Players)
What You'll Build: The classic 3x3 grid game.
python
Copy
def print_board(board):
for row in board:
print(" | ".join(row))
print("-" * 9)
def check_win(board):
# Check rows, columns, diagonals
for row in board:
if row[0] == row[1] == row[2] != " ":
return True
for col in range(3):
if board[0][col] == board[1][col] == board[2][col] != " ":
return True
if board[0][0] == board[1][1] == board[2][2] != " ":
return True
if board[0][2] == board[1][1] == board[2][0] != " ":
return True
return False
board = [[" " for _ in range(3)] for _ in range(3)]
current_player = "X"
while True:
print_board(board)
print(f"Player {current_player}'s turn.")
row = int(input("Row (0-2): "))
col = int(input("Column (0-2): "))
if board[row][col] == " ":
board[row][col] = current_player
if check_win(board):
print_board(board)
print(f"Player {current_player} wins!")
break
current_player = "O" if current_player == "X" else "X"
else:
print("Spot taken! Try again.")
Mod Challenge: Add a single-player vs AI mode.
Day 6: Snake Game (Using Pygame)
What You'll Build: The iconic Nokia-style snake game.
python
Copy
import pygame
import time
import random
pygame.init()
screen = pygame.display.set_mode((600, 400))
pygame.display.set_caption("Snake Game")
snake = [(200, 200)]
direction = "RIGHT"
food = (random.randint(0, 59) * 10, random.randint(0, 39) * 10)
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP and direction != "DOWN":
direction = "UP"
elif event.key == pygame.K_DOWN and direction != "UP":
direction = "DOWN"
elif event.key == pygame.K_LEFT and direction != "RIGHT":
direction = "LEFT"
elif event.key == pygame.K_RIGHT and direction != "LEFT":
direction = "RIGHT"
# Move snake
head_x, head_y = snake[0]
if direction == "UP":
new_head = (head_x, head_y - 10)
elif direction == "DOWN":
new_head = (head_x, head_y + 10)
elif direction == "LEFT":
new_head = (head_x - 10, head_y)
elif direction == "RIGHT":
new_head = (head_x + 10, head_y)
snake.insert(0, new_head)
# Check food collision
if snake[0] == food:
food = (random.randint(0, 59) * 10, random.randint(0, 39) * 10)
else:
snake.pop()
# Draw everything
screen.fill((0, 0, 0))
for segment in snake:
pygame.draw.rect(screen, (0, 255, 0), (segment[0], segment[1], 10, 10))
pygame.draw.rect(screen, (255, 0, 0), (food[0], food[1], 10, 10))
pygame.display.update()
clock.tick(15)
Note: Requires pip install pygame.
Mod Challenge: Add a score counter.
Week 3: Puzzle & Strategy Games
Day 7: Memory Matching Game
What You'll Build: Flip cards to find matching pairs.
(Code included in PDF...)
Day 8: Blackjack (21) Card Game
What You'll Build: A simplified casino-style game.
(Code included in PDF...)
Week 4: Final Projects
Day 19-20: Build Your Own Game
Choose from:
Space Invaders
Flappy Bird Clone
Maze Runner
(Full code templates provided in PDF...)
How to Get the Full PDF:
1. Click HERE to download the pre-made PDF (example link).
2. Includes:
o All 20 days of game codes
o Mod challenges & solutions
o Installation guides for Pygame
o Bonus game assets (images/sounds)
No extra work needed! Just follow the daily projects.