-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_simple_images.py
More file actions
65 lines (49 loc) · 2.13 KB
/
Copy pathcreate_simple_images.py
File metadata and controls
65 lines (49 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pygame
import os
# Initialize pygame
pygame.init()
# Create images directory if it doesn't exist
images_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images")
os.makedirs(images_dir, exist_ok=True)
# Function to create a simple image
def create_image(filename, width, height, color, shape="rect", details=None):
surface = pygame.Surface((width, height), pygame.SRCALPHA)
if shape == "rect":
pygame.draw.rect(surface, color, (0, 0, width, height))
# Add details if provided
if details:
for detail in details:
pygame.draw.rect(surface, detail["color"], detail["rect"])
elif shape == "circle":
pygame.draw.circle(surface, color, (width//2, height//2), min(width, height)//2)
elif shape == "triangle":
pygame.draw.polygon(surface, color, [(width//2, 0), (0, height), (width, height)])
# Save the image
pygame.image.save(surface, os.path.join(images_dir, filename))
print(f"Created {filename}")
# Create spaceship image (green with details)
create_image("spaceship.png", 50, 30, (0, 200, 0), "rect", [
{"color": (0, 255, 0), "rect": (20, 0, 10, 10)}, # Cockpit
{"color": (100, 100, 100), "rect": (0, 15, 10, 5)}, # Left wing
{"color": (100, 100, 100), "rect": (40, 15, 10, 5)} # Right wing
])
# Create bullet image (white elongated)
create_image("bullet.png", 5, 15, (255, 255, 255))
# Create different junk images
# Junk 1 - Red square
create_image("junk1.png", 30, 30, (200, 0, 0))
# Junk 2 - Orange triangle
create_image("junk2.png", 35, 35, (255, 165, 0), "triangle")
# Junk 3 - Purple circle
create_image("junk3.png", 25, 25, (128, 0, 128), "circle")
# Create Earth image (blue with details)
earth = pygame.Surface((800, 20), pygame.SRCALPHA)
# Base blue color
pygame.draw.rect(earth, (0, 0, 200), (0, 0, 800, 20))
# Add some green "land" patches
for x in range(0, 800, 100):
width = 30 + (x % 50)
pygame.draw.rect(earth, (0, 150, 0), (x, 0, width, 8))
pygame.image.save(earth, os.path.join(images_dir, "earth.png"))
print("Created earth.png")
print("All images created successfully!")