Creating a retro-themed arcade game inspired by Avatar: The Last Airbender using Pygame, with no external assets, means we'll need to create everything ourselves—characters, animations, and environments—using basic shapes and pixel-style graphics.
Here's a simplified version of the game:
🎮 Features:
- Retro 8-bit style (low-res, limited color palette)
- Aang as the main character
- Firebending enemies (simple AI)
- Basic movement & firebending attacks
- Score system
✅ Requirements:
Make sure you have pygame installed:
pip install pygame
🔧 Controls:
- Arrow Keys or
WASD: Move Aang
- Spacebar: Firebend attack
🧩 Game Code:
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen settings
WIDTH, HEIGHT = 640, 480
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Airbender - Arcade Edition")
# Clock
clock = pygame.time.Clock()
FPS = 30
# Colors (Retro Palette)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (200, 0, 0)
BLUE = (0, 100, 255)
YELLOW = (255, 200, 0)
# Fonts
font = pygame.font.SysFont("Courier New", 20)
# Player class
class Player:
def __init__(self):
self.x = WIDTH // 2
self.y = HEIGHT - 60
self.speed = 5
self.width = 30
self.height = 40
self.color = BLUE
self.bullets = []
def draw(self, screen):
# Draw Aang (simplified avatar)
pygame.draw.rect(screen, self.color, (self.x, self.y, self.width, self.height))
# Head
pygame.draw.circle(screen, WHITE, (self.x + self.width//2, self.y - 10), 10)
# Attack animation placeholder
for bullet in self.bullets:
bullet.draw(screen)
def move(self):
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] or keys[pygame.K_a]:
self.x -= self.speed
if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
self.x += self.speed
if keys[pygame.K_UP] or keys[pygame.K_w]:
self.y -= self.speed
if keys[pygame.K_DOWN] or keys[pygame.K_s]:
self.y += self.speed
# Keep player within bounds
self.x = max(0, min(WIDTH - self.width, self.x))
self.y = max(0, min(HEIGHT - self.height, self.y))
def shoot(self):
bullet = Bullet(self.x + self.width//2, self.y)
self.bullets.append(bullet)
def update_bullets(self, enemies):
for bullet in self.bullets[:]:
bullet.move()
if bullet.off_screen():
self.bullets.remove(bullet)
else:
for enemy in enemies[:]:
if bullet.collide(enemy):
enemies.remove(enemy)
self.bullets.remove(bullet)
return 1 # Score increment
return 0
# Bullet class
class Bullet:
def __init__(self, x, y):
self.x = x
self.y = y
self.radius = 4
self.color = YELLOW
self.speed = -7
def draw(self, screen):
pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), self.radius)
def move(self):
self.y += self.speed
def off_screen(self):
return self.y < 0
def collide(self, enemy):
dist = ((self.x - enemy.x)**2 + (self.y - enemy.y)**2)**0.5
return dist < (self.radius + enemy.radius)
# Enemy class
class Enemy:
def __init__(self):
self.x = random.randint(0, WIDTH - 30)
self.y = random.randint(-100, -40)
self.radius = 10
self.speed = random.randint(2, 4)
self.color = RED
def draw(self, screen):
pygame.draw.circle(screen, self.color, (self.x, self.y), self.radius)
def move(self):
self.y += self.speed
def off_screen(self):
return self.y > HEIGHT
# Draw text function
def draw_text(text, x, y, color=WHITE):
label = font.render(text, True, color)
screen.blit(label, (x, y))
# Main game loop
def main():
player = Player()
enemies = []
score = 0
spawn_timer = 0
running = True
while running:
clock.tick(FPS)
screen.fill(BLACK)
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Key presses
keys = pygame.key.get_pressed()
player.move()
if keys[pygame.K_SPACE]:
if len(player.bullets) < 5: # Limit bullets
player.shoot()
# Spawn enemies
spawn_timer += 1
if spawn_timer >= 30:
enemies.append(Enemy())
spawn_timer = 0
# Update and draw enemies
for enemy in enemies[:]:
enemy.move()
enemy.draw(screen)
if enemy.off_screen():
enemies.remove(enemy)
# Update bullets and check collisions
score += player.update_bullets(enemies)
# Draw player
player.draw(screen)
# UI
draw_text(f"Score: {score}", 10, 10)
# Update display
pygame.display.flip()
pygame.quit()
sys.exit()
if __name__ == "__main__":
main()
🎨 Visual Style Notes:
- Pixelated look created by drawing rectangles and circles.
- Simple head-and-body structure for Aang.
- Firebending represented with yellow circles.
- Enemies are red balls simulating firebenders.
🚀 Future Ideas:
- Add health bar or lives
- Add different bending types (water, earth)
- Add boss battles
- Add retro sound effects (with
pygame.mixer)
- Use sprite sheets for animated characters
Let me know if you'd like this expanded into multiple levels, with a menu system, or more advanced features!