Absolutely! Here’s a very simple Python game with a GUI and visual sprites using the popular pygame library.
You control a player sprite with arrow keys and try to "catch" a moving creature sprite.
No external images are needed—sprites are drawn as colored rectangles/circles for simplicity.
Install pygame first (if needed):
bash
pip install pygame
Simple Catch-the-Creature Game
python
import pygame
import random
# Initialize pygame
pygame.init()
# Screen settings
WIDTH, HEIGHT = 500, 400
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Catch the Creature!")
# Colors
WHITE = (255, 255, 255)
BLUE = (50, 100, 255)
GREEN = (50, 255, 100)
RED = (255, 80, 80)
# Player settings
player_size = 40
player_pos = [WIDTH // 2, HEIGHT // 2]
player_speed = 5
# Creature settings
creature_size = 30
creature_pos = [random.randint(0, WIDTH - creature_size), random.randint(0, HEIGHT - creature_size)]
creature_speed = 3
# Score
score = 0
font = pygame.font.SysFont(None, 36)
clock = pygame.time.Clock()
def move_creature():
# Randomly move creature
dx = random.choice([-1, 0, 1]) * creature_speed
dy = random.choice([-1, 0, 1]) * creature_speed
creature_pos[0] = max(0, min(WIDTH - creature_size, creature_pos[0] + dx))
creature_pos[1] = max(0, min(HEIGHT - creature_size, creature_pos[1] + dy))
def draw():
screen.fill(WHITE)
# Draw player (blue square)
pygame.draw.rect(screen, BLUE, (*player_pos, player_size, player_size))
# Draw creature (green circle)
pygame.draw.ellipse(screen, GREEN, (*creature_pos, creature_size, creature_size))
# Draw score
score_text = font.render(f"Score: {score}", True, RED)
screen.blit(score_text, (10, 10))
pygame.display.flip()
def check_collision():
px, py = player_pos
cx, cy = creature_pos
if (px < cx + creature_size and px + player_size > cx and
py < cy + creature_size and py + player_size > cy):
return True
return False
# Main game loop
running = True
while running:
clock.tick(30) # 30 FPS
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Player movement
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
player_pos[0] = max(0, player_pos[0] - player_speed)
if keys[pygame.K_RIGHT]:
player_pos[0] = min(WIDTH - player_size, player_pos[0] + player_speed)
if keys[pygame.K_UP]:
player_pos[1] = max(0, player_pos[1] - player_speed)
if keys[pygame.K_DOWN]:
player_pos[1] = min(HEIGHT - player_size, player_pos[1] + player_speed)
move_creature()
if check_collision():
score += 1
# Move creature to a new random position
creature_pos = [random.randint(0, WIDTH - creature_size), random.randint(0, HEIGHT - creature_size)]
draw()
pygame.quit()
How to Play
Run the script (python yourfile.py)
Move the blue square with arrow keys.
Catch the green creature (circle) to score points!
The creature moves randomly each frame.
You can easily expand this with images, sound, or more features. Let me know if you want a more advanced version!