
Lesson 5 – Designing Objects
In this lesson, you will begin the process of creating your space shooter game by identifying and designing the key objects that will make up the gameplay. Having become familiar with the Squeak programming environment and basic concepts in previous lessons, it is now time to focus on the major components of the game. Understanding and determining these objects and their roles will lay the foundation for the game mechanics we will develop in upcoming lessons.
You will be building a simple, classic space shooter game. The game will feature a user-controlled ship that can shoot, enemy creatures that can be destroyed, and a score that accumulates points for each enemy destroyed. These are some of the primary objects you will work with, but as you proceed, you may discover additional objects or find that you need to adjust the roles and responsibilities of those you have already defined.
Object Roles and Responsibilities
When designing your objects, it helps to focus on two key aspects: what the object is and what it does – that is, its roles and responsibilities. For example, the spaceship object is something you control, and its responsibility is to move and shoot at enemies. Similarly, the enemy object is something that can be destroyed when hit by a shot. Other objects, like the score object, also play important roles in your game.
At this stage, you do not need to know all the objects you will need right away – this is perfectly fine! Object-oriented programming (OOP) is flexible, allowing you to modify your design as your game evolves. As you write more code, you might find that new objects are necessary, or some you initially considered may not be needed after all.
Key Questions to Guide Your Design
As you work through this process, consider the following questions to guide your object design:
- How many objects can you identify in the example? Look closely at the example game screen provided in Figure 1 of Lesson 5. How many distinct elements can you identify that might need to be treated as objects? These could include characters like your ship, the enemies, a shot, or even the score. Everything you see has a purpose in the game. Take a moment to list them out and think about what each element represents.
- What names would you choose for these objects? Think about what each object is and what it does. For example, if your game includes a spaceship, the object representing it might be called
Ship. If there are enemies, you might have an object calledEnemy. Choosing clear and descriptive names from the start will help your code stay organized and easier to understand. - How do these objects interact with each other? Once you have identified and named your objects, think about how they interact. How does your ship shoot at enemies? How do enemies react when hit? Considering these interactions early on will give you a clearer idea of how each object contributes to the overall functionality of your game.
Naming and Organizing Your Objects
An important part of designing objects is choosing meaningful names. The names you pick should make it clear what each object is and what it does in your game. At this stage, it is best to keep things clear and simple. For example, if you are designing the object that represents the player’s ship, use a name that clearly describes it, like Ship. Similarly, for enemies, choose a name that makes it obvious what the object represents.
For other objects, consider their role and responsibility. What would you call the object that represents something the player shoots? And what about the object that tracks the score? Remember, it is better to use simple, intuitive names that describe the object’s function rather than complicating things with complex names.
Do not worry if the names are not perfect at first. The most important thing is clarity. You can always refine them as your game evolves. In Squeak, renaming objects is easy, so you do not need to worry about getting everything right in the beginning.
Final Thoughts
In object-oriented programming, the process of designing and refining your objects is ongoing. You do not need to have all the objects figured out from the start, and it is okay if things are not perfect right away. The goal is to focus on understanding what each object does and how it interacts with others to create the overall game experience. Over time, you will continue to refine and expand your design.
Remember that in Smalltalk, making changes to your objects is simple – whether that involves adding new objects, renaming them, or adjusting how they behave. Do not be afraid to iterate and improve as you go along. It is all part of the learning process!
Good luck as you begin designing your space shooter game. Be sure to refer back to the example game screen shown in Figure 1 as well as the rest of Lesson 5 in the online lesson or the downloadable PDF as you proceed.
Lesson Resources
For Lesson 5 and the complete series of lessons on creating the Shooter Game, including all the necessary resources such as PDFs, source code, images, sound file, and more, visit https://scottgibson.site/ShooterGame/. This site provides everything you need to progress and also lets you play the game directly in your browser, seamlessly powered by SqueakJS. Whether you are just getting started with Squeak/Smalltalk or advancing your skills, these resources will help guide you as you move forward through the game development process.



