For my final assignment in Introduction to Computer Programming (CIS 1100) class, I built a version of the classic Snake Game. This project gave me the chance to bring together many of the programming concepts I learned throughout the course, including nodes, records, and object-oriented design.
Game Overview
The game is similar to the classic snake game: you move the snake using the WASD keys, eat apples to grow longer and earn points, and press R to restart after losing, all while avoiding walls, spikes, and your own body. To make the game more exciting, I added extra features such as bonus food (red apples worth 1 point, green apples worth 5 points, and golden apples worth 10 points), a high score tracker that records your best run achieved in a session, and spikes that serve as extra obstacles. The graphical interface was built using PennDraw, an expanded version of StdDraw.
Class Structure
SnakeGame.java – entry point with the main game loop, user input, and high score tracking.
Board.java – manages the overall game, calling update() and draw() on all objects, and displaying the “Game Over” screen.
Snake.java – handles movement, growth, collisions, and rendering of the snake’s body.
Food.java – generates apples, updates score, and prevents spawning on spikes or the snake’s body.
Segment.java – implements a linked list node to represent the snake’s body, showing my understanding of dynamic data structures.
Spike.java – uses a Java record to represent obstacles in a clean, immutable way.
Gameplay Video