When I start my working process, I began by planning out the core mechanics of the simulation, which included designing the creatures and their interactions with each other and the environment. I came up with an idea that I can create an interactive game.The I can use ES6 model(class) to define different creatures and add forces to simulate creature behavior, such as seeking a target and avoiding obstacles. So I directly create the Creature class first. Next, I designed the Point class to serve as “food” for the creatures. After that, I thought about the “rules” of the game. I designed several versions but I chose the one I think is clear and simple which I can finish. I created Monster class to introduce a predator element, which chased the creature and wanted to eat it. And the creature can be attracted by the mouse click, eating the points in its path way to gain game scores. I made the points class a lifespan, and I used the isDone property to manage the existence of creature and points(if creature be eaten by the monster, the game will be over) . Throughout the process, I utilized object-oriented principles, such as inheritance and polymorphism, to streamline the code and create reusable components. After the basic mechanics were in place, I focused on optimizing performance, I adjusted some values to ensure players have better experience.
Working on this simulation has taught me valuable lessons in both programming and game design. One of the key takeaways was the importance of planning object interactions early on. I initially focused heavily on individual behaviors like seeking and eating, but as I started adding more elements, such as the monster and lifespan properties, I realized how crucial it was to account for the relationships between objects. The use of inheritance and polymorphism proved to be very helpful, enabling me to manage different object types with shared methods and properties. Another lesson I learned was the significance of optimization. While it’s tempting to add as many objects as possible to create a more dynamic environment, I found that limiting the number of active objects was essential for maintaining performance, especially with animations and interactions happening in real-time. I also realized the benefits of forces in simulating lifelike behaviors. The application of simple physics-based forces, such as acceleration and deceleration, made the creatures feel more alive and reactive.
(I don't have a lot screenshots for this project since its a game and hard to screenshot without control;) Try the game by yourself if you are interested!)