Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

thetinycoder1234

1
Posts
A member registered Jun 08, 2025

Creator of

Recent community posts

im having a bit of a problem with it: I am trying to use it in a game im making with pygame-ce, my code is: 

import pygame

pygame.init()

# Screen setup

WIDTH, HEIGHT = 800, 600

screen = pygame.display.set_mode((WIDTH, HEIGHT))

pygame.display.set_caption("Cat Cruise: The Quest for Catnip")

# Colors

SKY_BLUE = (135, 206, 250)

PLATFORM_COLOR = (139, 69, 19)

CATNIP_COLOR = (124, 252, 0)

# Clock

clock = pygame.time.Clock()

FPS = 60

# Load and scale sprite sheet frames

def load_frames(sheet, frame_width, frame_height, num_frames, scale_to):

    frames = []

    for i in range(num_frames):

        frame = sheet.subsurface(pygame.Rect(i * frame_width, 0, frame_width, frame_height))

        scaled = pygame.transform.scale(frame, scale_to)

        frames.append(scaled)

    return frames

sprite_sheet = pygame.image.load("RUN.png").convert_alpha()

cat_frames = load_frames(sprite_sheet, 32, 32, 8, (64, 64))

# Player setup

player_width, player_height = 64, 64

player_x, player_y = 100, HEIGHT - player_height - 100

player_vel_x = 0

player_vel_y = 0

player_speed = 5

jump_strength = 15

gravity = 0.8

on_ground = False

# Animation

frame_index = 0

frame_timer = 0

frame_speed = 5

moving_left = False

moving_right = False

# Platforms

platforms = [

    pygame.Rect(0, HEIGHT - 40, WIDTH, 40),

    pygame.Rect(200, 450, 150, 20),

    pygame.Rect(400, 350, 150, 20),

    pygame.Rect(600, 250, 150, 20),

]

# Catnip goal

catnip = pygame.Rect(700, 200, 30, 30)

# Game loop

running = True

while running:

    clock.tick(FPS)

    screen.fill(SKY_BLUE)

    # Events

    for event in pygame.event.get():

        if event.type == pygame.QUIT:

            running = False

    # Movement input

    keys = pygame.key.get_pressed()

    player_vel_x = 0

    moving_left = keys[pygame.K_LEFT]

    moving_right = keys[pygame.K_RIGHT]

    if moving_left:

        player_vel_x = -player_speed

    if moving_right:

        player_vel_x = player_speed

    if keys[pygame.K_SPACE] and on_ground:

        player_vel_y = -jump_strength

        on_ground = False

    # Apply gravity

    player_vel_y += gravity

    # Move player

    player_x += player_vel_x

    player_y += player_vel_y

    player_rect = pygame.Rect(player_x, player_y, player_width, player_height)

    # Collision detection

    on_ground = False

    for platform in platforms:

        if player_rect.colliderect(platform):

            if player_vel_y > 0:

                player_y = platform.top - player_height

                player_vel_y = 0

                on_ground = True

    # Win condition

    if player_rect.colliderect(catnip):

        print("YOU FOUND THE CATNIP! 馃惐馃尶")

        running = False

    # Animation update

    if moving_left or moving_right:

        frame_timer += 1

        if frame_timer >= frame_speed:

            frame_index = (frame_index + 1) % len(cat_frames)

            frame_timer = 0

    else:

        frame_index = 0  # Idle frame

    # Draw platforms

    for platform in platforms:

        pygame.draw.rect(screen, PLATFORM_COLOR, platform)

    # Draw catnip

    pygame.draw.rect(screen, CATNIP_COLOR, catnip)

    # Draw player sprite

    current_frame = cat_frames[frame_index]

    if moving_left:

        current_frame = pygame.transform.flip(current_frame, True, False)

    screen.blit(current_frame, (player_x, player_y))

    # Update display

    pygame.display.flip()

pygame.quit() and im using the RUN animation.