Sierpinski’s Nightmare
In this project, I developed and illustrated a 2D platform game named Sierpinski’s Nightmare.
In Sierpinski’s Nightmare, you step into the shoes of Dr. Sierpinski, the renowned mathematician whose name graces the famous Sierpinski fractals.
One fateful day, Dr. Sierpinski finds himself trapped in a nightmarish realm filled with fractal monsters of his own creation. The player must guide him to safety by hunting down the monsters that haunt him. The journey grows more challenging as the doctor descends deeper into the shadows.
Developing Sierpinski’s Nightmare from scratch was more than an opportunity to hone my personal coding and artistic skills—it was a way to create an immersive experience that blended together art, computer science, and storytelling.
Today, I am still driven by the same obsessive passion to create features and experiences that can tell a good story and generate joy.
Character Animation
I created a set of animated pixel sprites using Photoshop for the main character in the game.
Since it is possible for multiple commands to be registered to a single user action in the game, different animations had to be created for each action or combination of actions. For example, walking is a separate animation from walking and attacking. Attacking mid-air is also possible.
Idling
Walking
Attacking + Walking
Dancing
Jumping
Falling
Game Screens
The game is developed in Java and the UI and interactive components use JavaFx and Java Swing. The various scenes are hand-painted using Photoshop with the exception of the fractal monster shapes (triangle, square, circle) and platform blocks which are drawn by recursive code functions.
Menu: The player opens to the main menu, where the user can start the game, exit the game, open to detailed instructions, or look at the high score screen.
Stages: Each of the intermediate stages in the game uses the same backdrop of a hill. Depending on the particular stage, the code generates a set of unique rendered platforms that have object collision detection with both the position of the monsters and the player.
Final Boss: The final boss moves as a set of bundled fractal circles and painted legs which form a giant spider. If the player is successfully able to jump and hit all of the eyeballs, the spider then breaks apart into individual smaller fractal shapes which the player must then eliminate to win the game.
Programming Notes
Player Mechanics
Movement: W, A, S, D (left, up, right, down) are the key bindings which move the character in each of the X-Y Cartesian coordinates. On collision with a monster, the player is knocked back a few pixels in the opposite direction.
Attacking: A mouse click is registered to an attack which launches bullets towards the mouse cursor’s current location from the player’s current position, so combinations of player movement (jumping, moving) are all accounted for when calculating where the bullets are launched from, what direction they are heading, and if they end up colliding with a platform or monster’s bounding area.
Health: Player health is calculated based on an HP bar which decreases each time the player collides with a monster’s bounding box, or the player’s position drops below the lowest point of the rendered screen (i.e., the player falls to their death). Each full depletion of an HP bar decreases the number of lives the player has. The game ends when the player runs out of lives.
Monster Mechanics
Movement: Monster position is generated at the beginning of a scene and predetermined by the stage that the player is currently in. If the player moves towards the spawned monster or conversely launches an attack (in any direction), the distance between the monster and the player’s current position is calculated and the monster starts to move in the plane towards the player until a collision event is detected.
Attacking: Collision events between a player’s character and the monster is considered as an attack from the monster’s perspective and actively depletes player health for each collision.
Health: Monster health is calculated on a per-hit basis as a boolean (hit or miss). If a fractal monster is hit, it then breaks into a smaller sized version of itself until it becomes an atomic size (1 unit), after which point a single hit will clear the monster. When all generated fractal shapes are cleared within the same stage, this means the stage has been successfully completed.