Here's a complete and well-documented clone of the classic Tempest game using Python and Pygame. It features glowing visuals, animated stars, and a retro aesthetic with neon-style effects.
🎮 Tempest Clone in Pygame
✅ Features:
Glowing bullets, enemies, and player ship
Animated starfield background
Responsive keyboard controls
Basic enemy spawning and collision detection
Score tracking
📦 Requirements
Make sure you have Python and Pygame installed:
bash
pip install pygame
🧠 Game Structure Overview
This implementation uses:
Pygame Sprites to manage player, bullets, and enemies
Custom events to spawn enemies periodically
Glowing effects using semi-transparent circles
Animated background stars for visual appeal
🧾 Full Code
python
import pygame
import random
from pygame.locals import *
# Initialize Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Tempest Clone")
clock = pygame.time.Clock()
# Colors
WHITE = (255, 255, 255)
BLUE = (0, 150, 255)
RED = (255, 50, 50)
GREEN = (0, 255, 0)
BLACK = (0, 0, 0)
# Glow Colors (RGBA)
GLOW_BLUE = (0, 255, 255, 150)
GLOW_RED = (255, 0, 0, 150)
GLOW_GREEN = (0, 255, 0, 150)
# Fonts
font = pygame.font.SysFont(None, 36)
# Player Class
class Player(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.Surface((40, 20))
self.image.fill(BLUE)
self.rect = self.image.get_rect()
self.rect.centerx = 400
self.rect.bottom = 580
self.speed = 5
def update(self):
keys = pygame.key.get_pressed()
if keys[K_LEFT]:
self.rect.x -= self.speed
if keys[K_RIGHT]:
self.rect.x += self.speed
# Clamp to screen
self.rect.left = max(0, self.rect.left)
self.rect.right = min(800, self.rect.right)
def shoot(self):
bullet = Bullet(self.rect.centerx, self.rect.top)
all_sprites.add(bullet)
bullets.add(bullet)
# Bullet Class
class Bullet(pygame.sprite.Sprite):
def __init__(self, x, y):
super().__init__()
self.image = pygame.Surface((5, 10))
self.image.fill(WHITE)
self.rect = self.image.get_rect()
self.rect.centerx = x
self.rect.bottom = y
self.speed = -10
def update(self):
self.rect.y += self.speed
if self.rect.bottom < 0:
self.kill()
# Enemy Class
class Enemy(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.Surface((30, 30))
self.image.fill(RED)
self.rect = self.image.get_rect()
self.rect.x = random.randint(0, 770)
self.rect.y = random.randint(-100, -30)
self.speed = random.randint(1, 3)
def update(self):
self.rect.y += self.speed
if self.rect.top > 600:
self.kill()
# Starfield
stars = []
for _ in range(100):
x = random.randint(0, 800)
y = random.randint(0, 600)
speed = random.uniform(0.5, 1.5)
stars.append([x, y, speed])
# Sprite Groups
all_sprites = pygame.sprite.Group()
bullets = pygame.sprite.Group()
enemies = pygame.sprite.Group()
# Player
player = Player()
all_sprites.add(player)
# Enemy Spawn Event
ENEMY_EVENT = pygame.USEREVENT + 1
pygame.time.set_timer(ENEMY_EVENT, 1000)
# Game Loop
running = True
score = 0
while running:
clock.tick(60)
# --- Event Handling ---
for event in pygame.event.get():
if event.type == QUIT:
running = False
elif event.type == ENEMY_EVENT:
enemy = Enemy()
all_sprites.add(enemy)
enemies.add(enemy)
elif event.type == KEYDOWN:
if event.key == K_SPACE:
player.shoot()
# --- Update Logic ---
all_sprites.update()
# Check bullet-enemy collisions
hits = pygame.sprite.groupcollide(enemies, bullets, True, True)
for hit in hits:
score += 10
# Check player-enemy collisions
if pygame.sprite.spritecollide(player, enemies, True):
print("Game Over!")
running = False
# --- Update Starfield ---
for star in stars:
star[1] += star[2]
if star[1] > 600:
star[1] = 0
star[0] = random.randint(0, 800)
# --- Drawing ---
screen.fill(BLACK)
# Draw stars
for star in stars:
pygame.draw.circle(screen, WHITE, (int(star[0]), int(star[1])), 1)
# Create glow surface
glow_surface = pygame.Surface((800, 600), pygame.SRCALPHA)
glow_surface.fill((0, 0, 0, 0))
# Draw bullet glows
for bullet in bullets:
pygame.draw.circle(glow_surface, GLOW_BLUE, bullet.rect.center, 10)
# Draw enemy glows
for enemy in enemies:
pygame.draw.circle(glow_surface, GLOW_RED, enemy.rect.center, 15)
# Draw player glow
if player.alive():
pygame.draw.circle(glow_surface, GLOW_GREEN, player.rect.center, 20)
# Blit glow surface
screen.blit(glow_surface, (0, 0))
# Draw all sprites
all_sprites.draw(screen)
# Draw score
score_text = font.render(f"Score: {score}", True, WHITE)
screen.blit(score_text, (10, 10))
# Update display
pygame.display.flip()
pygame.quit()
🎨 Visual Style
Glow Effects: Achieved using semi-transparent circles drawn on a separate surface (glow_surface) with alpha blending.
Neon Colors: Bright blues, reds, and greens give a retro arcade look.
Starfield: Animated stars scrolling downward create a sense of motion and depth.
🧩 Future Improvements (Optional)
You can expand this game with:
Particle effects on enemy destruction
Different enemy types and movement patterns
Power-ups and health system
Sound effects and background music
Difficulty scaling over time
🕹️ Controls
Left Arrow: Move Left
Right Arrow: Move Right
Spacebar: Shoot
🎉 Summary
This Tempest clone uses Pygame to recreate a visually appealing, glowing arcade-style shooter with retro charm. The glowing effects and animated background stars give it a "cool and glowy" vibe, as requested.
Let me know if you'd like to add sound, music, or more advanced gameplay mechanics!