Knockout Penguins Game Dev. Log

May 28, 2024

2024-06-16

Day before final submission, I've cleaned up all the code, added in sound effects for when the penguin hits the wall. I've also cleaned up the code and optimized inefficienies in the physics handling. I also added the image for the penguin and added a highscore feature. Oh and I cleaned up the art and visual assets. Phew! Finally the game is DONE!

2024-06-14

Today was just a day for creating the custom maps. I've created 4 maps, each increasing in difficulty (or at least thats the plan). Currently they've just ended up as a hodgepodge mess, but I will be working over the weekend to create nice maps to play in.

2024-06-13

Added the slush patches to slow the penguin down, it was a pretty simple process as the friction and deceleration value of the penguin is just increased. Other notable changes today include creating map reading functionality. I'm storing the values of the walls and the slush patches in simple text files and opening/reading them when the current level is changed.

2024-06-12

Today I spent most of my time working on fixing the physics handling. Right now I am detecting the collisions with the edges of the iceberg pretty easily because it's a simple rectangular wall. The collisions detections with the walls is trickier because there are edges and corners which seem to throw simple rect collisions off hand.

So to solve these issues I found a new way to detect collisions by calculating the distance between the edge point of the circle with the line edge of the wall. If this value is less than the radius of the circle, it means there has been a collision. This seems to work well and is relatively simple enough that I can code it in. There still some slight issues when dealing with collisions in the corners, but its reliable 90% of the time so I am going to stick with this.

Thats pretty much all I did today, next up is to create the slush patches and start creating maps.

2024-06-11

After some hard hours, I have a functioning mini-golf esque game. While it is basic in functionality, the next steps are to create various maps and potentially autogenerate maps with increasing difficulty.

Here's how it looks so far:

There is also some nice code that I'm proud of which looks calculates the angular collision with the ball and the wall. Heres what it looks like:

if not (
        ICEBERG.left + ball_radius < ball_x < ICEBERG.right - ball_radius and ICEBERG.top + ball_radius < ball_y < ICEBERG.bottom - ball_radius):
    # Determine which wall the ball has hit
    if ball_x <= ICEBERG.left + ball_radius:  # Left wall
        normal = (-1, 0)
    elif ball_x >= ICEBERG.right - ball_radius:  # Right wall
        normal = (1, 0)
    elif ball_y <= ICEBERG.top + ball_radius:  # Top wall
        normal = (0, -1)
    else:  # Bottom wall
        normal = (0, 1)

    # Calculate the dot product of the ball's velocity and the wall's normal
    dot_product = ball_x_speed * normal[0] + ball_y_speed * normal[1]

    # Reflect the ball's velocity along the wall's normal
    ball_x_speed -= 2 * dot_product * normal[0]
    ball_y_speed -= 2 * dot_product * normal[1]

2024-06-10

Due to the difficulties in getting the physics of the game to work within the criteria of the project, I am shifting the game's functionality to be a defend the iceberg experience where the user has to out click the randomly spawning penguins.

2024-06-07

I was able to create collision detection and movement of the penguins using functions and applying some fancy mathematics. I also added a launch button and am currently working on integrating the physics to work with the launching of the penguins.

2024-06-06

Today was a frustrating day as I sturggled to get the physics to work. No real progress, except for the learnings from the mistakes made along the way.

2024-06-05

I finished the aesthetics and artwork assets for my game today. I added penguins to the menu screen and added hover buttons to improve UI interaction.

2024-06-04

Went back to the menu today and added some music functionality along with the ability to adjust the volume of the music. Also I updated the penguin drawing code to show arrows when the user drags the vector for each penguin.

This is the music I chose:

Here's how the penguins with vectors look like:

2024-06-03

Today I worked on some of the game mechanics and tried to implement some physics (but failed spectacularly) so instead, all I have for today is they basic game drawn out where 5 circles for each player are randomly generated without overlapping each other. I did this by doing random generation and using a function called add_penguin to verify if the randomly generated penguin location conflicts with an already existing penguin location or is in 15px of an existing one.

This is what the code looks like:

# Define the iceberg and penguins
ICEBERG_SIZE = 500
iceberg = pygame.Rect(WIDTH // 2 - ICEBERG_SIZE // 2, HEIGHT // 2 - ICEBERG_SIZE // 2, ICEBERG_SIZE, ICEBERG_SIZE)

# Separate lists for each player's penguins and their properties
penguin_rects_p1 = []
penguin_rects_p2 = []

def add_penguin(penguin_list):
    while True:
        x = random.randint(iceberg.x, iceberg.x + ICEBERG_SIZE - 40)  # Subtract 40 to account for the penguin's size
        y = random.randint(iceberg.y, iceberg.y + ICEBERG_SIZE - 40)  # Subtract 40 to account for the penguin's size
        new_penguin = pygame.Rect(x, y, 40, 40)  # Penguin size is now 40x40
        too_close = False
        for penguin in penguin_list:
            if new_penguin.colliderect(penguin.inflate(60, 60)):
                too_close = True
                break
        if not too_close:
            penguin_list.append(new_penguin)
            break

for i in range(5):
    add_penguin(penguin_rects_p1)
    add_penguin(penguin_rects_p2)
print(penguin_rects_p1, penguin_rects_p2)

And here is the penguins drawn out!

2024-05-31

Finished the game menues with updated instructions screen! Essentially just rendering an image asset because drawing out all the text in pygame is a tedious process, and wastes time that could be spent on more pressing tasks like, physics and collision!

Here's how it looks.

2024-05-30

Not much actual visual changes today, but I focused mainly on improving the base menu code to be more robust and future proofing it by creating functions and improving handling of the button rendering and such stuff.

2024-05-29

Today I got the initial game menu up and running and setup the boilerplate code for the project. I was struggling to render the buttons in an efficient manner without using 2D lists and dictionaries but was able to do so by separating them into multiple lists.

Here's how it looks.

2024-05-28 - Game Proposal

Game Idea

2 player, turn based game with penguins on a block of ice. The objective is to knock the other player’s penguins off the ice. On each turn, each player adjusts the direction and speed in which each penguin is sent. The other player does the same, without knowledge of their opponent’s choices. Once both players have input their moves, the penguins are sent and the round is simulated. This is repeated over as many rounds until one player’s penguins are all knocked off the ice. Between each round, there is information about how researchers in the arctic and Antarctic are using technology to help protect the natural habitats of penguins and other

Milestone 1 - May 31

Game Menu (start screen), Instructions (help), Navigation System (working buttons)

  • Menu designed with following options:
    • Instructions
    • Game Settings (Volume, Effects)
    • Launch Game

Milestone 2 - June 11

Game Mechanics (Controls, Physics and Collision,  Points/Scoring etc..)

  • Mouse based controls to handle user choice on which direction penguins are sent and the speed
  • Click and drag vs. just click? Will see which is more feasible
  • Physics simulation:
    • Varies depending on speed
    • Also on ice, so make it slippery
    • Collision of penguins
    • Circle collision detection with:
(x2-x1)^2 + (y2-y1)^2 <= (r1+r2)^2
where circle 1 centre is (x1, y1) and circle 2 centre is (x2, y2)
  • Figure out moving circle collision response, at least in pseudocode
  • Add functionality for multiple rounds, (within a loop p

Milestone 3 - June 14

Game Difficulty (How the game will increase in difficulty)

  • To increase difficulty the ice block can decrease in size every round.
  • Add in functionality to check if a penguin falls off the ice block when it shrinks