Introduction to the Series
This article kicks off a series designed to introduce programming to beginners through the creation of a simplified space shooter game using Squeak, an open-source implementation of the Smalltalk programming language. By breaking down the process into a series of manageable lessons, the aim is to provide an accessible and interactive entry point into the world of programming. This series will guide learners through the process of building a game from the ground up while introducing them to essential programming concepts along the way. Upon completion, and with the accompanying resources such as source code, images, and a sound file, students will have everything they need to recreate or enhance the game.
Who This Series is For
The intended audience for this article and the accompanying series includes both young learners and adults who are new to coding or to Smalltalk. Whether you are a student, educator, or hobbyist, these lessons are tailored to make programming approachable and enjoyable. Throughout the series, we will dive into key programming principles – such as object-oriented design, the concept of “Morphs” in Squeak, and more – at a beginner-friendly pace. Each lesson is supplemented with practical examples. If you are interested in starting with something fun and educational, and you are curious about how games are made or how Smalltalk can be used in a modern development environment, this series is for you.
Why a Game, and Why Squeak/Smalltalk?
So why a game, and why in Squeak/Smalltalk? Why not? Everybody understands the domain of games, or gaming. That is, the mechanics, interactions, and goals – such as managing player input, controlling game characters, defining win/loss conditions, and creating interactive environments. Games are a universal medium that spans across ages and cultures, from simple board games to complex video games. This familiarity makes games an excellent starting point for teaching programming concepts, as the mechanics and goals are intuitive to most people. Moreover, games require a variety of programming elements to function, such as managing user input, handling graphics, implementing game rules, designing levels, and even creating sound and music. These components provide a rich environment for introducing and practicing key programming skills – like decision-making, loops, object-oriented design, and event handling – while keeping learners engaged with a fun, practical outcome.
Why Squeak/Smalltalk is the Right Tool
Squeak makes all of this very easy, and you do not need to learn anything more than Smalltalk to get started. The language is intuitive and enjoyable to use, and Squeak provides a powerful and engaging development environment. While games may not balance your bank account, they can serve as an excellent resource for learning programming or a new language. Squeak/Smalltalk, in particular, makes this process both accessible and enjoyable.
How This Series Came to Be
This article introduces a series of lessons based on a simplified version of a space shooter game I developed using Squeak. The project, which was both fun to create and my first full Squeak program, turned out to be an ideal way to teach my middle school-aged son Smalltalk, as well as the fundamentals of object-oriented programming (OOP). Although he had prior programming experience, he quickly grasped the language due to its simplicity and the interactive nature of the environment. The natural syntax of Smalltalk, combined with the user-friendly environment, not only made it easier for him to solve problems but also allowed him to be more creative, without needing to alter his natural problem-solving approach. Both the language and the environment “got out of his way,” enabling him to express himself more easily and effectively.
What Will Be Covered in the Series
The lessons in this series are designed to introduce key programming concepts – such as classes, methods, debugging, and user interface design – through the process of building and modifying a game. You can find the complete list of lessons on the Shooter Game site. Each lesson was written daily, and I discussed topics both before and during the lesson to provide additional detail and ensure a deeper understanding. This approach allowed me to offer relevant explanations exactly when they were needed, based on my son’s progress and evolving needs.
For each article, I will aim to provide additional helpful information that may not be included in the lessons themselves. If you feel any details are missing or could be useful, please let me know, and I would be happy to provide further information.
Interactive, Live Coding Approach
The hands-on, live coding approach in these lessons encourages learners to experiment and learn in real time, making the process both educational and enjoyable. Each lesson also comes with a downloadable PDF version of the lesson page for easy offline reference or printing. The entire series progressively builds upon itself, allowing learners to gradually develop their programming skills as they move through the lessons.
Lesson 1: Creating and Positioning Morphs
For today’s lesson, we will dive into the first step in building our game: “Creating and Positioning Morphs.” In this lesson, we will introduce the concept of a Morph and explore how to create and manipulate these visual objects within the Squeak environment. Understanding Morphs is a crucial part of game development in Squeak, as they serve as the foundation for all the interactive elements of the game.
What is a Morph?
In Squeak, a Morph is an interactive graphical object. Like everything in Smalltalk, a Morph can be interacted with through messages. It is not a static, lifeless image on the screen, but rather a lively object waiting to interact with its environment. You can send a message to a Morph to receive information about it or to perform an operation. Everything you see when running Squeak is a Morph object. This presents some very exciting capabilities, as it provides you with the ability to create graphical objects, which can interact with the world (the entire Squeak environment – its display screen in this case) and the world can interact with them.
The Squeak world works using a coordinate system. The coordinate values can be absolute or relative. Each coordinate value is represented as a point, which has an X coordinate and a Y coordinate. For example, a Squeak world (remember, this will be the full size of the display screen in the Squeak environment) with a display size of 1024×768:
- The point 0@0 is the top-left corner of the screen.
- The point 0@768 is the lower-left corner of the screen.
- The point 1024@768 is the lower-right corner of the screen.
- The point 1024@0 is the top-right corner of the screen.
Every point in between represents a location within the world. Points can exist outside of that world too; however, they would not be visible.
In this game, everything is a subclass of Morph, so you will be using Morphs a lot.
Before beginning Lesson 1, it would be very helpful to read Chapter 1 of the Squeak By Example book (available as a free PDF, SBE-6.0.pdf), an excellent resource for learning Squeak and understanding its environment. Afterward, you can go straight to the lesson here.
Additional Resources
To access the full series of lessons and resources for the space shooter game, Shooter Game, visit the lesson site at https://scottgibson.site/ShooterGame/. There, you will find the complete set of lessons and their associated PDFs, along with the source code, images, the sound file, and other useful resources. You can even play the game directly in your browser (using the awesome SqueakJS!). Whether you are a beginner or looking to learn more about Squeak/Smalltalk, its environment, and its tools, these resources will guide you through each step and provide everything you need to recreate or enhance the game.
Have a great time with Smalltalk and keep on Squeaking!