Concept
I created an interactive zoo-themed game where players get to dive into the fun of feeding different animals. The game features a variety of enclosures, each housing unique animals like a Lion, Elephant, Giraffe, and Bear, along with their distinctive images and sounds. The main goal is to correctly feed each animal their preferred food while managing a limited number of attempts. It’s all about exploring the zoo, having fun, and seeing how well you can feed the animals! The gameplay is designed to be engaging and straightforward. Players drag and drop food items into the enclosures, trying to match the right food with the right animal. It’s a lively experience that captures the excitement of a day at the zoo while keeping players entertained and challenged.
What I’m proud of the most is how the zoo home looks like:
Code Snippets
I’m proud of the code for the feedback system; it plays distinct sounds for correct and incorrect food choices, while also displaying visual messages. This helps the player learn from their mistakes in real time.
checkFood(chosenFood) {
if (chosenFood.name === this.correctFood) {
correctSound.play(); // Play the correct sound if food is right
correctFeeds++; // Increment correct feeds count
gameWon = (correctFeeds === zoo.length); // Check if all animals have been fed correctly
showCorrectMessage = true; // Show correct message
// Stop the sound for the current enclosure
for (let enclosure of zoo) {
if (enclosure.name === currentEnclosure) {
enclosure.stopSound();
}
}
}
else {
wrongSound.play(); // Play the wrong sound if food is wrong
lives--; // Decrement lives
// Check for loss condition
if (lives <= 0) {
gameOver = true; // Set gameOver to true if lives reach zero
}
}
}
Another code snippet I’m proud of is the mousePressed function because it lets the player easily move from the instruction screen to exploring the zoo, and if they win or lose, it resets everything for a fresh start. The way it checks if an enclosure was clicked and responds to player actions keeps the gameplay fluid and intuitive, making it simple for anyone to jump in and play without getting stuck.
function mousePressed() {
if (instructionScreen) {
instructionScreen = false; // Exit instruction screen when clicked
} else if (gameOver || gameWon) {
// Reset game state and go to instruction screen
lives = 3;
correctFeeds = 0; // Reset correct feeds count
gameOver = false;
gameWon = false;
instructionScreen = true; // Reset to instruction screen
currentEnclosure = null;
for (let enclosure of zoo) {
enclosure.stopSound();
}
} else if (currentEnclosure === null) {
// Check if an enclosure is clicked
for (let enclosure of zoo) {
enclosure.checkClick();
}
} else {
// Reset showCorrectMessage for the next animal
showCorrectMessage = false;
}
The Good Parts
The game runs on a combination of object-oriented programming and easy-to-understand mechanics. Each animal enclosure is an instance of the Enclosure class, complete with its own attributes like size, name, images, sounds, and the specific food it needs. Players simply drag and drop food items into the right enclosures, and the game gives instant feedback on whether they made the correct choice or not.
I’m really proud of how I integrated audio into the game. Each time players make a correct or incorrect choice, they hear distinct sound effects that add a fun layer to the experience. Plus, I included on-screen messages that help players understand what they did right or wrong, making it easy to learn and improve. I also love how the design encourages players to explore different enclosures and challenges, creating a loop of fun that keeps them engaged. The restart feature is a nice touch too, allowing players to jump right back in if they want to try again after finishing a round.
The Not So Good Parts
Even though I’m happy with how the project turned out, there are definitely areas where I could improve. For instance, the user interface could use a bit more flair to make it visually appealing. Sprucing up the background and button designs would enhance the overall experience. I also want to fine-tune the drag-and-drop mechanics to make them even smoother, as some players might find it tricky to place the food just right.
During the development process, I faced a few challenges along the way. One significant issue is that there are still some bugs that I didn’t have time to fix. For example, players can exploit a loophole where feeding the same animal the correct food four times counts as a win, which isn’t the intended gameplay experience. Additionally, if players don’t drag the incorrect food item away before placing the correct one, both the correct and wrong sounds will play simultaneously, which can be confusing. I also noticed that the food items tend to stick together when they touch, almost like magnets, which adds an unintended dynamic to the dragging mechanic. However, when players switch to another enclosure, the food items reset as intended, which is a positive aspect. These challenges highlighted the importance of thorough testing and debugging, and I plan to address them in future iterations of the game.