
Lesson 6 – Object Interaction and Behavior
In the last lesson, you were asked to identify the objects present in Figure 1 of Lesson 5. From the example, we will be using the object names ShooterGame, Ship, Shot, Enemy, and Score. These names have been chosen because they are clear, descriptive, and directly relate to the roles these objects will play within the game. Each name corresponds to a specific function within the game, and using such intuitive names helps to keep the code organized and easy to understand.
The reason these names were selected is tied to their roles and responsibilities within the game. As you will see in the following explanations, each object has a clear purpose. At the core of everything is ShooterGame, which provides the game screen – the boundary within which all gameplay takes place. It serves as the origin point for the entire game, coordinating the creation and management of other game elements and the overall flow of activity. The Ship represents the player’s character, allowing for movement and interaction with enemies. Shot represents the projectiles fired by the player, which interact with enemies to destroy them. Enemy objects are the targets that move across the screen and can be destroyed by shots. Finally, the Score object tracks the points the player earns by destroying enemies. The following sections of this article will further explain the roles and responsibilities of each object in detail, providing a better understanding of how they work together in the game.
Key Object Behaviors
- ShooterGame: The
ShooterGameobject provides the screen boundary and serves as the foundation from which the entire game emerges. It defines the playable area that other objects use to determine their positions and limits. In addition to supplying this essential structure,ShooterGamealso acts as the central controller of the game. It initializes theShipandScoreat the start and recreatesEnemyobjects when all have been eliminated. It also coordinates the overall flow of the game, including when it begins and ends, and keeps track of the main objects involved in gameplay. - Ship: The
Shipis controlled by the player, and its movements will be essential to the game. You can program theShipto move in all four directions: up, down, left, and right. Unlike many games, the ship will not be destroyed if it comes into contact with an enemy, meaning the player can continue to control the ship without worrying about direct collisions with enemies. The ship’s movement and interactions with other objects will be crucial to progressing through the game. - Shot: The
Shotobject represents the projectiles that the player shoots at the enemies. Shots will move in an upward direction as the player fires them. The behavior of theShotis simple: when a shot hits an enemy, the enemy is destroyed. This interaction between the shot and the enemy is one of the core mechanics of your space shooter game. - Enemy: The
Enemyobjects will move left and right across the screen, adding a dynamic element to the game. There will be threeEnemyobjects in the game, each with its own movement pattern. As the player’s shots hit theEnemyobjects, theEnemyobjects will be destroyed, and the player will earn points. - Score: The
Scoreobject is responsible for keeping track of the player’s points. Each time an enemy is destroyed, the player earns 100 points, and the score increases accordingly. The score is updated when aShothits anEnemy. Because theScoreobject displays its information on theShooterGamescreen, it maintains a relationship with it.
Object Interactions
Now that each object’s role and behavior has been identified, it is important to understand how these objects interact during gameplay. Their interactions define how the game functions and how players experience the game world.
- Ship and ShooterGame: The
Shipappears within the game screen provided byShooterGame. It moves in response to player input and uses the boundaries of the game screen to determine how far it can travel. The screen boundaries provided byShooterGamelimit how far theShipcan move.ShooterGameprovides the space in which theShipoperates, but it does not control theShip’s movement. - Ship and Shot: When the player activates a firing action, the
Shipreleases aShotthat travels upward. This interaction allows the player to engage with enemies and is central to gameplay. The firing of aShotgives the player a way to respond to the movement ofEnemyobjects on the screen. - Shot and ShooterGame: The game screen provided by
ShooterGameestablishes the upper boundary for shots. When aShotmoves upward and reaches the top of the screen, it is removed from play.ShooterGamedoes not manage or direct shots, but its boundaries help determine when aShotleaves the gameplay area. - Shot and Enemy: If a
Shotcomes into contact with anEnemyduring its path, both theShotand theEnemyare removed from play. This interaction is a key part of gameplay: successful hits onEnemyobjects are the player’s goal. When this happens, theScoreis also updated to reflect the player’s progress. - Enemy and ShooterGame:
Enemyobjects move left and right across the game screen using the screen’s width to guide their motion. The screen boundaries provided byShooterGamelimit how farEnemyobjects can move. When anEnemyis hit by aShot, it is removed from the game screen. - Score and ShooterGame: The
Scoreis displayed on the game screen and increases when anEnemyis destroyed.ShooterGameprovides the location where theScoreis shown during gameplay. As the game progresses, theScoregives players feedback on their performance and accomplishments.
Understanding how these objects behave and interact lays the groundwork for building a playable game. By thinking carefully about each object’s role and how it connects with others, you will be better prepared to implement the necessary features in code. These foundational concepts will continue to guide your work as you move forward with designing and programming the game’s functionality.

The tutorials are now also available for use inside the Squeak development environment through the Squeak Help System. Once installed, this resource allows you to read and follow the lessons directly within Squeak, making it easy to experiment with code and concepts without leaving the environment. The Help System documentation is included as part of the downloadable resources for the game and can be added to your Squeak image just like the other game assets.
Lesson Resources
To access Lesson 6 and the full series of tutorials for building the Shooter Game, visit https://scottgibson.site/ShooterGame/. There you will find everything you need to follow along, including PDFs, Squeak Help lesson content, source code, images, sound files, and other game assets. This resource also allows you to try out the game directly in your browser using SqueakJS. Whether you are new to programming, just getting started with Squeak/Smalltalk, or building on prior experience, these materials will support you as you continue developing your own version of the game.


Leave a comment