This repository contains two interactive Python projects developed in collaboration with a partner for UBC's CPEN 333 courses, exploring real-time systems through graphical interfaces, multithreading, and network communication.
Each part is built on a template provided by the course instructor and demonstrates structured class-based design, thread-safe operations, and event-driven programming, with clear separation between logic and interface.
A functional snake game built in Python, originally developed using Tkinter for the GUI (part1.py) and later re-implemented with Pygame as an alternative version (part1_alternative.py). The game loop runs on a separate thread and communicates with the GUI through a thread-safe queue to ensure responsiveness and concurrency.
- Real-time snake movement and prey generation
- GUI versions using both Tkinter and Pygame
- Clean separation of game logic and rendering logic
- Queue-based communication between threads
The game is structured around several core classes:
Game: Manages all gameplay logic, including snake movement, prey generation, and collision detection.QueueHandler: Facilitates safe communication between the game loop and the GUI using a thread-safe queue.- GUI wrappers (
SnakeAppfor Tkinter,PygameApp): Handle rendering, user input, and interface updates based on queued tasks.
These components were designed to ensure modularity, reusability, and responsiveness.
Through this project, we:
- Built a thread-safe game loop using Python’s
queueandthreadingmodules - Compared widget-based and immediate-mode GUI paradigms (Tkinter vs Pygame)
- Improved understanding of coordinate systems, bounding boxes, and frame-based animation
- Tuned gameplay variables like step size for balanced control and difficulty
- Implemented bounding box checks to prevent prey from overlapping with snake or score display
- Validated movement and collision logic by simulating sequences and adjusting step size
- Pygame version tested frame redrawing and event queue handling under different framerates
Tkinter Version
The original version of the game was built using Tkinter's canvas system. The screenshot below shows the snake navigating the playfield, with score tracking and live prey generation.
Pygame Version
This alternative version re-implements the GUI using Pygame intended as extra challenge.
A lightweight chat system built using Python’s socket module and Tkinter GUI. The project runs a centralized server and multiple clients on localhost, each in its own process, simulating a real-time messaging environment.
- Centralized TCP server to handle multiple clients
- Each client has its own scrollable chat window
- Real-time message broadcast with basic error handling
- Graceful disconnect detection and auto-shutdown of server
This project is organized around two core classes:
ChatServer: Manages all incoming client connections, maintains a dictionary of client sockets, relays messages between clients, and updates the server-side chat display.ChatClient: Provides the user interface, handles user input, connects to the server, and displays messages in real time.
Both classes make use of dedicated threads to manage socket communication without blocking the GUI. This separation ensures a responsive user experience and allows each component to remain modular and testable.
Through this project, we:
- Learned to create and manage socket-based TCP connections between multiple processes
- Built thread-safe message-passing systems between sockets and GUIs using
threadingandTkinter - Designed both client and server to operate independently while sharing a common communication protocol
- Encountered and debugged platform-specific issues related to GUI updates and firewall/network permissions (e.g., macOS socket restrictions)
- Verified message delivery between multiple client windows
- Tested auto-shutdown on full client disconnect
- Addressed platform-specific issues including Tkinter widget thread-safety and socket binding behavior
Attached below is an image of the chat application in action:
| Team Member | Contributions |
|---|---|
| Joshua Obi | Lead developer on chat application and co-programmer for the Snake Game Alternative |
| Bevio Chen | Lead developer for the Snake Game and co-programmer for the Snake Game Alternative |



