Arts >> Theater >> Comedy

Fan-Made Python Game: SpongeBob "The Quickster" Prototype

The code below is a fan-created Python/Pygame prototype inspired by the SpongeBob SquarePants episode "The Quickster" (where SpongeBob gains super-speed). It is not official game code.

import pygame
import sys

# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

# Screen
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

# Player (SpongeBob)
player = pygame.sprite.Sprite()
player.image = pygame.image.load("spongebob.png")
player.rect = player.image.get_rect()

# Walls
walls = pygame.sprite.Group()
for i in range(5):
    wall = pygame.sprite.Sprite()
    wall.image = pygame.Surface((100, 100))
    wall.image.fill(GREEN)
    wall.rect = wall.image.get_rect()
    wall.rect.x = i * 100
    wall.rect.y = i * 100
    walls.add(wall)

# Main Loop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        player.rect.x -= 5
    if keys[pygame.K_RIGHT]:
        player.rect.x += 5
    if keys[pygame.K_UP]:
        player.rect.y -= 5
    if keys[pygame.K_DOWN]:
        player.rect.y += 5
    if pygame.sprite.spritecollideany(player, walls):
        player.rect.x -= 5
        player.rect.y -= 5
    screen.fill(BLACK)
    screen.blit(player.image, player.rect)
    walls.draw(screen)
    pygame.display.flip()

This simple demo shows basic movement and collision. A real game would add animation, levels, enemies, and the "Quickster" speed mechanic.

Comedy

Related Categories