Skip to main content
ALPHA    This is new software undergoing tests! Thank you for your patience.

Candidate: Claire Candidate claire_candidate Assessed by: Mary Mentor mary_mentor

Python (2023) ~ Grade 2 (Elementary)

Splat a Cat

A silly game made for my young cousins.

Attached files
Filename (click to download) Size Uploaded by
mu_mode.png 26.2 KB claire_candidate
Markdown code
![mu_mode.png](/media/assessment/7ee9d8e4/2023-10-16/04-23-27/mu_mode.png "mu_mode.png")

Status: Submitted for assessment.


claire_candidate Claire Candidate ~ 16 Oct 2023 4:23 a.m.

I've attached some initial assets to this comment.

Music: Disco Cat by Komiku (public domain).

Sounds: a selection of free-to-use meows downloaded as WAV files from MixKit.

Images: a selection of royalty free cats on a transparent background found via this Google search.

Make sure you use the correct buttons in Mu to put these assets in the right place. I've made an image that shows you which buttons to use:

mu_mode.png


claire_candidate Claire Candidate ~ 16 Oct 2023 4:26 a.m.

Here is the code for the first draft of the game:

"""
Cat splat.
"""
import random


WIDTH = 800
HEIGHT = 600
cats = ["cat1", "cat2", "cat3", "cat4"]  # cat sprites.
meows = [sounds.meow1, sounds.meow2, sounds.meow3, sounds.meow4, sounds.meow5]  # meows.
current_cats = []  # A list of cats that are currently alive.
dead_cats = []  # A list of all the dead cats.
music.play("disco")  # Play some annoying kitty music.


def draw():
    """
    Draws each frame in the game.
    """
    screen.fill((255, 255, 255))
    for dead_cat in dead_cats:
        dead_cat.draw()
    for cat in current_cats:
        cat.draw()


def update():
    """
    Update the game state. Randomly add some cats.
    """
    if random.randint(1, 100) == 1:  # 1 in 100 chance.
        cat_sprite = random.choice(cats)  # select a sprite.
        meow_sound = random.choice(meows)  # select a meow.
        x = random.randint(100, 700)  # new x coordinate.
        y = random.randint(100, 500)  # new y coordinate.
        new_cat = Actor(cat_sprite, pos=(x, y))  # make the cat.
        current_cats.append(new_cat)  # Add to list of cats.
        meow_sound.play()  # play the meow.


def on_mouse_down(pos):
    """
    Handle a mouse-click event.
    """
    new_dead_cats = []  # Temporary list of cats newly killed.
    for cat in current_cats:  # Check all alive cats.
        if cat.collidepoint(pos):  # Hit a cat!
            cat.image = "splat"  # Cat image is now a splat.
            dead_cats.append(cat)  # Cat is now dead.
            new_dead_cats.append(cat)  # Killed cats need further work.
            sounds.splat.play()  # SPLAT!
    for dead_cat in new_dead_cats:
        # Newly killed cats need removing from the current cat list.
        current_cats.remove(dead_cat)

You can see a video playthrough of this game here:


claire_candidate Claire Candidate ~ 16 Oct 2023 4:28 a.m.

Here is the code for the first draft of the game:

"""
Cat splat.
"""
import random


WIDTH = 800
HEIGHT = 600
cats = ["cat1", "cat2", "cat3", "cat4"]  # cat sprites.
meows = [sounds.meow1, sounds.meow2, sounds.meow3, sounds.meow4, sounds.meow5]  # meows.
current_cats = []  # A list of cats that are currently alive.
dead_cats = []  # A list of all the dead cats.
music.play("disco")  # Play some annoying kitty music.


def draw():
    """
    Draws each frame in the game.
    """
    screen.fill((255, 255, 255))
    for dead_cat in dead_cats:
        dead_cat.draw()
    for cat in current_cats:
        cat.draw()


def update():
    """
    Update the game state. Randomly add some cats.
    """
    if random.randint(1, 100) == 1:  # 1 in 100 chance.
        cat_sprite = random.choice(cats)  # select a sprite.
        meow_sound = random.choice(meows)  # select a meow.
        x = random.randint(100, 700)  # new x coordinate.
        y = random.randint(100, 500)  # new y coordinate.
        new_cat = Actor(cat_sprite, pos=(x, y))  # make the cat.
        current_cats.append(new_cat)  # Add to list of cats.
        meow_sound.play()  # play the meow.


def on_mouse_down(pos):
    """
    Handle a mouse-click event.
    """
    new_dead_cats = []  # Temporary list of cats newly killed.
    for cat in current_cats:  # Check all alive cats.
        if cat.collidepoint(pos):  # Hit a cat!
            cat.image = "splat"  # Cat image is now a splat.
            dead_cats.append(cat)  # Cat is now dead.
            new_dead_cats.append(cat)  # Killed cats need further work.
            sounds.splat.play()  # SPLAT!
    for dead_cat in new_dead_cats:
        # Newly killed cats need removing from the current cat list.
        current_cats.remove(dead_cat)

You can see a video of this in action here:


mary_mentor Mary Mentor ~ 16 Oct 2023 4:35 a.m.

Hi Claire,

I'm Mary and I'm going to be your mentor. I have some questions and a couple of bits of feedback for you...


Back to top