I'll add London-style houses to the background to create a more urban setting for your werewolf platformer. Here's the enhanced version with Victorian-style London houses:
import pygame
import sys
import random
import math
# Initialize pygame
pygame.init()
# Screen dimensions (similar to ZX Spectrum's 256x192)
SCREEN_WIDTH = 256
SCREEN_HEIGHT = 192
SCALE = 2 # Scale up for better visibility
screen = pygame.display.set_mode((SCREEN_WIDTH * SCALE, SCREEN_HEIGHT * SCALE))
pygame.display.set_caption("Werewolf Platformer - London Nights")
# Colors (ZX Spectrum palette with some additions)
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
RED = (255, 0, 0)
MAGENTA = (255, 0, 255)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
YELLOW = (255, 255, 0)
WHITE = (255, 255, 255)
BRIGHT_YELLOW = (255, 255, 150) # For moon glow
DARK_RED = (150, 0, 0) # For brick houses
BROWN = (150, 75, 0) # For wooden elements
GRAY = (100, 100, 100) # For stone elements
# Game clock
clock = pygame.time.Clock()
FPS = 30
# Star class for twinkling stars
class Star:
def __init__(self):
self.x = random.randint(0, SCREEN_WIDTH)
self.y = random.randint(0, SCREEN_HEIGHT // 3) # Stars only in top third
self.size = random.choice([1, 1, 1, 2]) # Mostly small stars
self.brightness = random.uniform(0.5, 1.0)
self.base_brightness = self.brightness
self.twinkle_speed = random.uniform(0.01, 0.05)
self.twinkle_direction = random.choice([-1, 1])
def update(self):
# Twinkle effect
self.brightness += self.twinkle_speed * self.twinkle_direction
if self.brightness > 1.0 or self.brightness < 0.5:
self.twinkle_direction *= -1
def draw(self, screen):
color = (
int(255 * self.brightness),
int(255 * self.brightness),
int(255 * self.brightness)
)
if self.size == 1:
screen.set_at((self.x, self.y), color)
else:
pygame.draw.circle(screen, color, (self.x, self.y), self.size)
# Moon class with glow effect
class Moon:
def __init__(self):
self.x = SCREEN_WIDTH - 60
self.y = 30
self.radius = 15
self.glow_radius = 40
self.glow_alpha = 120 # Semi-transparent glow
def draw(self, screen):
# Draw moon glow
glow_surface = pygame.Surface((self.glow_radius * 2, self.glow_radius * 2), pygame.SRCALPHA)
for r in range(self.glow_radius, 0, -1):
alpha = int(self.glow_alpha * (r / self.glow_radius) * 0.7)
color = (BRIGHT_YELLOW[0], BRIGHT_YELLOW[1], BRIGHT_YELLOW[2], alpha)
pygame.draw.circle(glow_surface, color, (self.glow_radius, self.glow_radius), r)
screen.blit(glow_surface, (self.x - self.glow_radius, self.y - self.glow_radius))
# Draw moon
pygame.draw.circle(screen, WHITE, (self.x, self.y), self.radius)
# Add crater details
pygame.draw.circle(screen, BLACK, (self.x - 3, self.y - 2), 2)
pygame.draw.circle(screen, BLACK, (self.x + 4, self.y - 1), 3)
pygame.draw.circle(screen, BLACK, (self.x - 1, self.y + 3), 2)
# London House class
class LondonHouse:
def __init__(self, x, width, height):
self.x = x
self.width = width
self.height = height
self.window_color = YELLOW
self.window_spacing = 5
self.window_size = 3
self.window_rows = 3
self.window_cols = max(2, width // 10)
def draw(self, screen):
# Draw house outline
pygame.draw.rect(screen, DARK_RED, (self.x, SCREEN_HEIGHT - self.height, self.width, self.height))
# Draw roof
roof_height = 10
pygame.draw.polygon(screen, BROWN, [
(self.x - 5, SCREEN_HEIGHT - self.height),
(self.x + self.width + 5, SCREEN_HEIGHT - self.height),
(self.x + self.width // 2, SCREEN_HEIGHT - self.height - roof_height)
])
# Draw windows
for row in range(self.window_rows):
for col in range(self.window_cols):
window_x = self.x + 5 + col * (self.window_size + self.window_spacing)
window_y = SCREEN_HEIGHT - self.height + 5 + row * (self.window_size + self.window_spacing)
# Draw window frame
pygame.draw.rect(screen, WHITE, (window_x, window_y, self.window_size, self.window_size))
# Draw window glass (only if window is lit)
if random.random() > 0.3: # 70% chance window is lit
pygame.draw.rect(screen, self.window_color,
(window_x + 1, window_y + 1, self.window_size - 2, self.window_size - 2))
# Draw door
door_width = 6
door_height = 12
door_x = self.x + self.width // 2 - door_width // 2
door_y = SCREEN_HEIGHT - self.height + self.height - door_height
pygame.draw.rect(screen, BROWN, (door_x, door_y, door_width, door_height))
# Draw door handle
pygame.draw.circle(screen, YELLOW, (door_x + door_width - 2, door_y + door_height // 2), 1)
# Werewolf sprite (simple animation frames)
werewolf_frames = [
[
" 000 ",
"01110",
"11111",
"01110",
"00100",
"01010",
"10001"
],
[
" 000 ",
"01110",
"11111",
"01110",
"00100",
"01001",
"10010"
]
]
# Platform sprite
platform_sprite = [
"11111111",
"11111111"
]
# Convert sprite data to surfaces
def create_sprite(sprite_data, color):
width = len(sprite_data[0])
height = len(sprite_data)
surface = pygame.Surface((width, height), pygame.SRCALPHA)
surface.fill(BLACK)
for y, row in enumerate(sprite_data):
for x, char in enumerate(row):
if char == '1':
surface.set_at((x, y), color)
elif char == '0':
surface.set_at((x, y), WHITE)
return surface
# Create all sprites
werewolf_sprites = [create_sprite(frame, YELLOW) for frame in werewolf_frames]
platform_surface = create_sprite(platform_sprite, GRAY)
# Game objects
class Werewolf:
def __init__(self):
self.x = 50
self.y = 100
self.width = werewolf_sprites[0].get_width()
self.height = werewolf_sprites[0].get_height()
self.velocity_y = 0
self.jumping = False
self.current_frame = 0
self.animation_speed = 0.2
self.animation_timer = 0
self.direction = 1 # 1 for right, -1 for left
self.on_ground = False
def update(self, platforms):
# Animation
self.animation_timer += self.animation_speed
if self.animation_timer >= 1:
self.animation_timer = 0
self.current_frame = (self.current_frame + 1) % len(werewolf_frames)
# Gravity
self.velocity_y += 0.5
self.y += self.velocity_y
# Check for platform collisions
self.on_ground = False
for platform in platforms:
if (self.y + self.height >= platform.y and
self.y + self.height <= platform.y + platform.height and
self.x + self.width > platform.x and
self.x < platform.x + platform.width):
self.y = platform.y - self.height
self.velocity_y = 0
self.on_ground = True
self.jumping = False
# Screen boundaries
if self.y > SCREEN_HEIGHT - self.height:
self.y = SCREEN_HEIGHT - self.height
self.velocity_y = 0
self.on_ground = True
self.jumping = False
if self.x < 0:
self.x = 0
if self.x > SCREEN_WIDTH - self.width:
self.x = SCREEN_WIDTH - self.width
def jump(self):
if self.on_ground:
self.velocity_y = -8
self.jumping = True
self.on_ground = False
def move(self, direction):
self.x += direction * 2
self.direction = direction
def draw(self, screen):
# Flip sprite based on direction
sprite = werewolf_sprites[self.current_frame]
if self.direction == -1:
sprite = pygame.transform.flip(sprite, True, False)
screen.blit(sprite, (self.x, self.y))
class Platform:
def __init__(self, x, y):
self.x = x
self.y = y
self.width = platform_surface.get_width()
self.height = platform_surface.get_height()
def draw(self, screen):
screen.blit(platform_surface, (self.x, self.y))
# Create game objects
werewolf = Werewolf()
platforms = [
Platform(0, SCREEN_HEIGHT - 20),
Platform(50, 150),
Platform(120, 120),
Platform(200, 100),
Platform(150, 70)
]
# Create stars
stars = [Star() for _ in range(80)]
moon = Moon()
# Create London houses
houses = [
LondonHouse(10, 30, 50),
LondonHouse(50, 40, 60),
LondonHouse(100, 35, 55),
LondonHouse(140, 45, 70),
LondonHouse(190, 30, 45)
]
# Game loop
running = True
while running:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
werewolf.jump()
# Get keyboard state
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
werewolf.move(-1)
if keys[pygame.K_RIGHT]:
werewolf.move(1)
# Update game state
werewolf.update(platforms)
for star in stars:
star.update()
# Draw everything
screen.fill(BLACK)
# Draw starry background
for star in stars:
star.draw(screen)
# Draw moon with glow
moon.draw(screen)
# Draw London houses
for house in houses:
house.draw(screen)
# Draw platforms
for platform in platforms:
platform.draw(screen)
# Draw werewolf
werewolf.draw(screen)
# Scale up the screen
scaled_screen = pygame.transform.scale(screen, (SCREEN_WIDTH * SCALE, SCREEN_HEIGHT * SCALE))
pygame.display.get_surface().blit(scaled_screen, (0, 0))
pygame.display.flip()
clock.tick(FPS)
pygame.quit()
sys.exit()