Category: Beginners

  • Lesson 7: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 7: Programming the Shooter Game in Squeak/Smalltalk

    Let us dive into the exciting process of game creation!

    In this lesson, you will begin writing the actual code that brings your game to life. The previous lessons prepared you by helping define the game’s key objects and their responsibilities. Now, with those ideas in place, it is time to create your first class in Smalltalk: ShooterGame.

    This class will act as the canvas for everything else that follows. Though it may seem plain at first, much like an artist’s blank canvas, your ShooterGame Morph will soon host a lively collection of interactive game objects – ships, enemies, shots, and more. Unlike a painting, however, this canvas can respond, animate, and change as your code evolves.

    Using the System Browser

    The work begins in the System Browser, a powerful tool within the Squeak environment where you can write, view, and organize your code. You can open the System Browser from the main menu under Tools → Browser, or by left-clicking on the desktop background and selecting Browser.

    This browser is not the only place you can write code in Squeak, but it is the one you will use most frequently as you build and modify your game. You will use it to define classes, write methods, organize your code into categories, and explore existing functionality that your objects can build on.

    ShooterGame as a Morph

    When you create your ShooterGame class, you define it as a subclass of Morph. This design choice is essential. A Morph is a graphical object in Squeak that can be added to the screen, moved around, colored, resized, and interacted with. By making ShooterGame a Morph, you give it the ability to appear on the screen and act as a visible, interactive container for the other game elements.

    This inheritance relationship also means that ShooterGame will share the capabilities of Morphs – like positioning and drawing – while allowing you to add new, game-specific behavior through your own methods.

    Understanding Initialization

    After defining your class, you will write its first method: initialize. This is a special method that sets up a new instance of the class when it is created. It is also an ideal place to define how the object should appear and behave initially.

    An instance of a class is the actual object that gets created from that class. Think of the class as a blueprint or a set of instructions – like the design for a computer. That design tells you what the computer will have and how it will work. But until someone actually builds a computer from that design, you do not have a real one. The same is true in programming: the class is the design, and an instance is the real, usable object created from that design. Every time you create a new object from a class, you are making a new instance of it. And because everything in Smalltalk is an object, even the class itself is a kind of object – one that can do things, not just describe them!

    Inside the method, you will encounter super initialize. This line is important. It tells the system to first run the initialize behavior of the parent class – in this case, Morph – before adding your custom setup code. An initialize method should always start by sending super initialize. Skipping this line can lead to unexpected issues because it would prevent an object from preparing itself properly.

    Following that, you will define the Morph’s position and size using the position: and extent: messages. In Squeak, extent refers to the width and height of the Morph – think of it as how much space it occupies on the screen. The coordinate system in Squeak starts at the top-left corner of the screen (0 @ 0), and each point is written as an x and y pair (e.g., 640 @ 480). These lines of code determine where your game window will appear and how large it will be.

    You also set the background color to black and give the object a name using setNameTo:. These finishing touches help establish your game’s visual style and identity.

    Positioning and Sizing

    In Squeak, the World refers to the entire display area of the environment – the space where all graphical objects (Morphs) appear and interact. It is the backdrop of your development tools, your game, and the broader environment in which your game objects will live and move. Even the tools you use to write your code – such as the System Browser – are Morphs themselves, sharing the same space and able to interact with the same environment as your game.

    Squeak uses a coordinate system to place and size Morphs on the screen. The top-left corner of the World is the origin (0 @ 0). When you set a Morph’s position to 100 @ 100, it will appear 100 points from the left and 100 points from the top. The extent describes the Morph’s width and height – how much space it will take up on the screen. These values give you precise control over where and how your game interface is laid out.

    Seeing the Results

    Even after completing just this lesson, you will be able to see the first visible result of your code. Though the game is not yet playable, the space in which it will take shape is now visible and ready for action. The foundation is laid, and every lesson from here will build upon it.

    Remember that these lessons are designed for live coding – you are encouraged to run, modify, and explore your work as you go. That is one of the great strengths of Smalltalk. The lessons in this series are designed for live coding, meaning the game does not need to be closed and restarted when changes are made. You can follow through the lessons just as easily without live coding; however, you may not learn as many topics, as some only arise from using live coding. Also, remember that, unlike some other programming languages, Smalltalk does not require a final period (.) at the end of a method. The final period in the last expression is optional.

    And finally, remember to save your work once you have successfully completed the lesson. This ensures you can pick up right where you left off next time or provides a good recovery option if something should go wrong.

    Lesson Resources

    To access Lesson 7 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 site not only provides everything you need to progress but also even allows you to play the game directly in your browser using 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.

    Have a great time with Smalltalk and keep on Squeaking!

  • Lesson 6: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 6: Programming the Shooter Game in Squeak/Smalltalk

    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 ShooterGame object 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, ShooterGame also acts as the central controller of the game. It initializes the Ship and Score at the start and recreates Enemy objects 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 Ship is controlled by the player, and its movements will be essential to the game. You can program the Ship to 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 Shot object 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 the Shot is 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 Enemy objects will move left and right across the screen, adding a dynamic element to the game. There will be three Enemy objects in the game, each with its own movement pattern. As the player’s shots hit the Enemy objects, the Enemy objects will be destroyed, and the player will earn points.
    • Score: The Score object 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 a Shot hits an Enemy. Because the Score object displays its information on the ShooterGame screen, 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 Ship appears within the game screen provided by ShooterGame. 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 by ShooterGame limit how far the Ship can move. ShooterGame provides the space in which the Ship operates, but it does not control the Ship’s movement.
    • Ship and Shot: When the player activates a firing action, the Ship releases a Shot that travels upward. This interaction allows the player to engage with enemies and is central to gameplay. The firing of a Shot gives the player a way to respond to the movement of Enemy objects on the screen.
    • Shot and ShooterGame: The game screen provided by ShooterGame establishes the upper boundary for shots. When a Shot moves upward and reaches the top of the screen, it is removed from play. ShooterGame does not manage or direct shots, but its boundaries help determine when a Shot leaves the gameplay area.
    • Shot and Enemy: If a Shot comes into contact with an Enemy during its path, both the Shot and the Enemy are removed from play. This interaction is a key part of gameplay: successful hits on Enemy objects are the player’s goal. When this happens, the Score is also updated to reflect the player’s progress.
    • Enemy and ShooterGame: Enemy objects move left and right across the game screen using the screen’s width to guide their motion. The screen boundaries provided by ShooterGame limit how far Enemy objects can move. When an Enemy is hit by a Shot, it is removed from the game screen.
    • Score and ShooterGame: The Score is displayed on the game screen and increases when an Enemy is destroyed. ShooterGame provides the location where the Score is shown during gameplay. As the game progresses, the Score gives 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.

    Have a great time with Smalltalk and keep on Squeaking!

  • Lesson 5: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 5: Programming the Shooter Game in Squeak/Smalltalk

    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:

    1. 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.
    2. 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 called Enemy. Choosing clear and descriptive names from the start will help your code stay organized and easier to understand.
    3. 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.

    Have a great time with Smalltalk and keep on Squeaking!

  • Lesson 4: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 4: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 4: Using Cascades in Code

    This lesson will be the last introductory lesson (lesson practices) before we begin the actual game creation.

    This lesson is simple and quick, but it introduces cascades, which are commonly used in Smalltalk code. Understanding and becoming familiar with them will help you utilize them effectively, as well as recognize them when you encounter other Smalltalk code. By using cascades, you can reduce code clutter and minimize the amount of typing needed.

    The following code is an example from Lesson 3. This code completes messages by using a period which in Smalltalk is the statement separator. Placing a period between two expressions turns them into independent statements.

    s := SimpleButtonMorph new.
    s label: ‘Move right’.
    s target: moveRight.
    s actionSelector: #value.
    s openInWorld.

    The following code is the example from Lesson 4 using cascades.

    s := SimpleButtonMorph new
    label: ‘Move right’;
    target: moveRight;
    actionSelector: #value;
    openInWorld.

    Even though the code looks simpler, it is important to understand what is happening. When the same object is the receiver of a sequence of consecutive messages, you do not need to repeat it. You can remove the repeated receiving object and replace the ending period with a semicolon (;). So, the basic rules for cascades are:

    • Cascaded expressions are separated by semicolons
    • All cascaded messages share the same receiver as the last message executed before the first semicolon

    So, if it is as simple as replacing periods with semicolons, why does this lesson’s example not work if a semicolon were placed after “SimpleButtonMorph new”?

    SimpleButtonMorph is a class, not an instance of that class. This means that you cannot send instance messages directly to the class itself. A class can receive class messages, but in this example, we are sending instance messages, which can only be sent to instances of the class, not the class itself. Therefore, to interact with the instance, you must first create an instance by sending the message “new” to SimpleButtonMorph. It is this instance of SimpleButtonMorph that can receive instance messages. In other words, all the cascaded messages are sent to the object created by “SimpleButtonMorph new”, demonstrating how a sequence of cascaded messages can be sent to the result of an expression.

    In conclusion, understanding and using cascades in Smalltalk can greatly simplify your code, making it more readable and reducing redundancy. By chaining multiple messages to the same object in a single expression, you can streamline your code and focus on the logic rather than repetitive syntax. With this knowledge, you can write more efficient, elegant Smalltalk code and recognize cascading patterns in other code you encounter.

    For Lesson 4 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 not only provides everything you need to progress but also allows you to play the game directly in your browser using 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.

    Have a great time with Smalltalk and keep on Squeaking!

  • New Video Demonstrating Morphic Animation

    New Video Demonstrating Morphic Animation

    Would you like to view a demonstration of how to take advantage of the Morphic animation system in Squeak? If so, you are in luck! A new video has recently been posted that takes you through the steps of doing just that. The Morphic animation system in Squeak offers a simple way to animate and interact with objects in your environment. Whether you are building basic animations or more complex interactive systems, Morphic provides a wealth of possibilities for both beginners and seasoned developers alike. You can watch the video titled “A BlinkingRectangle Morph in Smalltalk” here.

    In addition to the video tutorial, you can explore a very simple, yet powerful example included in the Squeak image. This example morph can be found with the somewhat hard-to-remember name, MorphExample. By evaluating “MorphExample new openInWorld” (without the surrounding parentheses) in a Workspace, you can discover how easy it is to make morphs perform various actions. This demonstration emphasizes the beauty of the Morphic system’s simplicity: you do not need to write complex code to animate objects. Instead, you can focus on creating rich, interactive applications and interfaces with just a few lines of code.

    One of the most compelling aspects of the Morphic system is how effortlessly it enables dynamic, real-time interaction, especially when used within the Smalltalk environment. Compared to many other graphical frameworks, where handling interactions often requires more complex event handling and manual updates, Morphic allows you to create interactive, animated objects with minimal code. For example, you can open a halo on the star, resize or rotate it, and the animation will continue to perform and adjust dynamically to the star’s new dimensions. This responsiveness highlights the simplicity and flexibility of the Morphic system, making it an ideal choice for building interactive systems without the need for manual recalculations or updates.

    If you are interested in delving deeper into the Morphic system, you can access Chapter 12 of Squeak by Example for more detailed explanations and examples. The book offers a clear guide to the system, making it an excellent resource for developers looking to better understand Morphic. You can read the full chapter here.

    For those who want to learn more about using halos with morphs in Squeak, there is another excellent video resource available. The video “Morphic Halo icons in Squeak Smalltalk” demonstrates how to interact with the Morphic halo icons to manipulate morphs in the Squeak environment. Whether you are new to Squeak or already familiar with the basics, this video provides valuable insights into how halos can be used to interact with morphs. Check it out here.

    Have a great time with Smalltalk and keep on Squeaking!

  • Lesson 3: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 3: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 3: Moving a Morph with Code

    In this lesson, we will learn about blocks in Smalltalk. A block is a small piece of code that can be treated as an object. It is often used to perform actions or calculations when needed. Blocks are written inside square brackets, and they can be passed around or executed by other parts of the program. While blocks are commonly used in programs to make things happen, for now, think of them as a way to understand how code can be organized and applied. This lesson is a simple introduction to blocks, so you do not need to fully understand everything about them yet. By the end of the lesson, you will have a better idea of what blocks are and how they work in code. You will also learn how to use blocks to interact with your EllipseMorph.

    We will also use a simple button morph to interact with our EllipseMorph. By clicking the button, you will be able to make the EllipseMorph move. This lesson will show you how to create a simple graphical button that can then be used to interact with your morph. This is a nice way of interacting with the morph without having to do much coding for now. It allows you to focus on understanding the basic concepts before diving into more complex programming. As you progress, you will learn how to build more advanced interactions and customize the behavior of your morphs.

    Additional Resources

    For additional learning, there are several resources that can help you dive deeper into the topics we covered. You can start by exploring the Block Swiki page here to get a better understanding of how blocks work in Smalltalk. If you want to learn more specifically about the BlockClosure class, check out a detailed explanation here, also a Swiki article. Another helpful resource is the Terse Guide to Squeak online, which is always available within the Squeak image under Help -> Terse Guide to Squeak. Lastly, the Squeak by Example book is an excellent resource for exploring Squeak and Smalltalk in more detail, and you can read it here. These resources will provide you with more in-depth information and examples to support your learning.

    For the complete series of lessons on creating the Shooter Game, including all the necessary resources like PDFs, source code, images, sound files, and more, visit https://scottgibson.site/ShooterGame/. This site not only offers everything you need to progress but also lets you play the game directly in your browser using SqueakJS. Whether you are just getting started with Squeak/Smalltalk or are advancing your skills, these resources will help guide you as you progress through the game development process.

    Have a great time with Smalltalk and keep on Squeaking!

  • Lesson 2: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 2: Programming the Shooter Game in Squeak/Smalltalk

    Lesson 2: Moving Morphs

    In this lesson, we will focus on making Morphs move, an essential step in creating interactive and engaging gameplay. You will learn how to send messages to Morph objects, enabling them to change their position on the screen. Movement is a key part of any game, whether it involves your ship, enemies, or projectiles. By the end of this lesson, you will understand different ways to move Morphs relative to a specific location, giving you basic control over their movement in your game.

    To begin, it is important to understand how Morph movement is accomplished in Squeak, a version of Smalltalk, as not all Smalltalk implementations support Morphs, which is what we are using here. Squeak is an object-oriented language, meaning everything is an object. Objects can communicate with each other by sending messages, which is how actions and information are requested in Squeak. Much like how people communicate by sending messages to one another, objects in Squeak send messages to request actions or receive information, or both.

    Understanding Messages in Smalltalk

    In Smalltalk, there are three types of messages: unary, binary, and keyword. Unary messages have the highest precedence, followed by binary messages, and then keyword messages. These different types of messages help objects interact in various ways.

    • Unary messages are messages that are sent to an object without arguments.
    • Binary messages consist of special characters like +, -, or @, and each one takes exactly one argument to perform an action or computation involving two objects.
    • Keyword messages consist of one or more keywords, each ending with a colon (:), and each keyword takes an argument.

    The Difference Between position: and position

    In this lesson, you will focus on understanding how to use the position messages. The first important thing to know is the difference between two messages that seem similar but actually work in different ways: position and position:. They both deal with the position of Morphs, but they are used differently.

    • The message position, without a colon, is a unary message. It does not require any arguments and simply retrieves the current position of the Morph.
    • The message position:, with a colon at the end, is a keyword message. It can receive a value or an argument, which is used to change the position of the Morph.

    This difference in how the messages are structured is important because it tells Squeak how to process them. The position message simply retrieves the current location of the Morph, while the position: message accepts an argument to set or change the Morph’s location.

    Understanding How to Control Morph Movement

    By understanding how messages work in Squeak, you can effectively control the movement of Morphs. Each message, whether unary, binary, or keyword, enables you to send specific instructions to objects, helping them change their state or position on the screen. This knowledge of messages forms the basis of interacting with objects in your game.

    As you progress through the lesson, you will learn how to send different types of messages to Morphs, allowing you to interact with them in various ways. This skill will be crucial for making your game dynamic and interactive, enabling you to work with Morphs to create engaging gameplay elements.

    By the end of this lesson, you will have a good foundation in how messages are used to control movement in Squeak, and you will be ready to apply this knowledge in your game.

    Final Notes

    Please remember to save your Squeak image after each lesson. This way, if you ever encounter a problem with your code, you can always close the image and reopen it from where you last saved it. It would be helpful to save your Squeak image after you have successfully completed each lesson, so you can always reopen the image from the last completed lesson in case something unexpected happens while proceeding through the current lesson.

    Note that the extra parentheses in this lesson are not necessary, but they may help new learners visualize the objects conceptually, especially at the start. The syntax is still correct and can be adjusted later, so nothing harmful is being introduced. At this point, it seemed better to provide a visual, conceptual understanding through the code, rather than focusing solely on minimizing syntax. Future lesson code will not include these.

    Lesson Resources

    For the complete series of lessons on creating the Shooter Game, including all the necessary resources like PDFs, source code, images, sound files, and more, visit https://scottgibson.site/ShooterGame/. This site not only offers everything you need to progress but also lets you play the game directly in your browser using SqueakJS. Whether you are just getting started with Squeak/Smalltalk or are advancing your skills, these resources will guide you through each step of the game development process, helping you apply the techniques you learned in this lesson, such as moving Morphs and controlling game objects.

    Have a great time with Smalltalk and keep on Squeaking!

  • Introduction/Lesson 1: Programming the Shooter Game in Squeak/Smalltalk

    Introduction/Lesson 1: Programming the Shooter Game in Squeak/Smalltalk

    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!

  • Squeakfest 2013 in Uruguay

    squeakfest2013

    It’s that time again.  Time to pack up the kids and join us at SqueakFest 2013.  Don’t forget to bring your XO computer!

    If you can’t make it please consider a donation to help cover travel costs: Donate

    For more information see: Squeakfest 2013

    From Rita:

    There will be a Squeakfest again in Uruguay at June, 7th – 9th, this time in Atlantida. Etoys will cover the major part of the event, but there will also be workshops in Python, turtle art and robotics. After all, Uruguay is the country with XO-laptops in every elementary school and teachers are using the software which comes with Sugar.

    http://squeakfest2013.weebly.com/

    From our education team, Randall Caton and myself are going to present Etoys workshops. This year, I’ll introduce Kedama. I’m looking forward to an inspiring event!

    If you want to help or know someone who would like to, I created a crowdfunding page to collect money to help to cover our travel cost. Please share as you like!

    http://crowdfundedu.com/fundraiser/educators-to-squeakfest

    Greetings,

    Rita

  • Squeak Video Tutorials, 74 and counting!

    Chris Cunnington reminded the Squeak-dev mailing list that for a while now he’s been creating video tutorials explaining aspects of Squeak. In fact he’s been working at this for so long that he now has over 70 videos available!

    The videos give snappy introductions to topics as varied as: using SqueakSource to download Squeak applications; the mysteries of the red, blue, and yellow mouse buttons; how to use morphs; and using Croquet to interact in 3D environments (as seen above).

    If you want to learn about Squeak, or to find out more about Squeak applications you’ve never used before, these are a great resource, so head over to Chris’ Smalltalk Medicine Show channel on YouTube. If you know of other great videos for newcomers to Squeak and Smalltalk, please let us know in the comments.