SlideShare a Scribd company logo
C Game Programming Learn Game Programming With C
Step By Step Very Easy Am Moh download
https://ebookbell.com/product/c-game-programming-learn-game-
programming-with-c-step-by-step-very-easy-am-moh-37623908
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
C Game Programming Learn Game Programming With C Step By Step Very
Easy Am Moh
https://ebookbell.com/product/c-game-programming-learn-game-
programming-with-c-step-by-step-very-easy-am-moh-42327138
C Game Programming Learn Game Programming With C Step By Step Very
Easy Moh
https://ebookbell.com/product/c-game-programming-learn-game-
programming-with-c-step-by-step-very-easy-moh-42295524
C Game Development By Example Learn To Build Games And Graphics With
Sfml Opengl And Vulkan Using C Programming Siddharth Shekar
https://ebookbell.com/product/c-game-development-by-example-learn-to-
build-games-and-graphics-with-sfml-opengl-and-vulkan-using-c-
programming-siddharth-shekar-11124250
Handson Game Development With Webassembly Learn Webassembly C
Programming By Building A Retro Space Game 1st Edition Rick Battagline
https://ebookbell.com/product/handson-game-development-with-
webassembly-learn-webassembly-c-programming-by-building-a-retro-space-
game-1st-edition-rick-battagline-36528724
Coding Fun Learn C Programming With Games Animations And Mobile Apps
Amrico Moreira
https://ebookbell.com/product/coding-fun-learn-c-programming-with-
games-animations-and-mobile-apps-amrico-moreira-231944410
Learning C By Creating Games With Ue4 Learn C Programming With A Fun
Realworld Application That Allows You To Create Your Own Games William
Sherif
https://ebookbell.com/product/learning-c-by-creating-games-with-
ue4-learn-c-programming-with-a-fun-realworld-application-that-allows-
you-to-create-your-own-games-william-sherif-5108028
Learning C By Creating Games With Ue4 Learn C Programming With A Fun
Realworld Application That Allows You To Create Your Own Games William
Sherif
https://ebookbell.com/product/learning-c-by-creating-games-with-
ue4-learn-c-programming-with-a-fun-realworld-application-that-allows-
you-to-create-your-own-games-william-sherif-6724808
Learning C 7 By Developing Games With Unity 2017 Learn C Programming
By Building Fun And Interactive Games With Unity Third Edition 3rd
Edition Micael Dagraca Greg Lukosek
https://ebookbell.com/product/learning-c-7-by-developing-games-with-
unity-2017-learn-c-programming-by-building-fun-and-interactive-games-
with-unity-third-edition-3rd-edition-micael-dagraca-greg-
lukosek-7250930
C Game Programming Learn C Games Very Easy For Beginners Boo
https://ebookbell.com/product/c-game-programming-learn-c-games-very-
easy-for-beginners-boo-38381288
C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh
C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh
C++ for Beginners
C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh
C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh
Table of Contents
Beginning C++ Game Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Dedication
Preface
Timber!!!
Zombie ArenaTable of ContentsThomas was Late
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. C++, SFML, Visual Studio, and Starting the First Game
The games
Timber!!!
Zombie Arena
Thomas was Late
Meet C++
Microsoft Visual Studio
SFML
Setting up the development environment
What about Mac and Linux?
Installing Visual Studio Express 2015 on your desktop Setting up SFML
Creating a reusable project template
Planning Timber!!!
Creating a project from the template
Project assets
Outsourcing assets
Making your own sound FX
Adding assets to the project
Exploring assets
Understanding screen and internal coordinates Starting to code the game
Making code clearer with comments
#including Windows essentials
The main function
Presentation and syntax
Returning values from a function
Running the game
Opening a window using SFML
#including SFML features
OOP, classes, objects
Using namespace sf
SFML VideoMode and RenderWindow
Running the game
The main game loop
While loops
C-style code comments
Input, update, draw, repeat
Detecting a key press
Clearing and drawing the scene
Running the game
Drawing the game background
Preparing the sprite using a texture
Double-buffering the background sprite
Running the game
Handling errors
Configuration errors
Compile errors
Link errors
Bugs
FAQ
Summary
2. Variables, Operators, and Decisions – Animating Sprites
C++ variables
Types of variable
Constants
User-defined types
Declaring and initializing variables
Declaring variables
Initializing variables
Declaring and initializing in one step
Declaring and initializing user-defined types
Manipulating variables
C++ arithmetic and assignment operators
Getting things done with expressions
Adding clouds, a tree, and a buzzing bee
Preparing the tree
Preparing the bee
Preparing the clouds
Drawing the tree, the bee, and the clouds
Random numbers
Generating random numbers in C++
Making decisions with if and else
Logical operators
C++ if and else
If they come over the bridge, shoot them! Or do this instead
Reader challenge
Timing
The frame-rate problem
The SFML frame-rate solution
Moving the clouds and the bee
Giving life to the bee
Blowing the clouds
FAQ
Summary
3. C++ Strings, SFML Time, Player Input, and HUD
Pausing and restarting the game
C++ strings
Declaring strings
Assigning a value to strings
Manipulating strings
SFML Text and Font
Adding a score and a message
Adding a time bar
FAQ
Summary
4. Loops, Arrays, Switch, Enumerations, and Functions – Implementing
Game Mechanics
Loops
while loops
Breaking out of a while loop
for loops
Arrays
Declaring an array
Initializing the elements of an array
Quickly initializing the elements of an array
So what do these arrays really do for our games?
Making decisions with switch
Class enumerations
Getting started with functions
Function return types
Function names
Function parameters
The function body
Function prototypes
Organizing functions
Function gotcha!
Final word on functions - for now
Absolute final word on functions - for now
Growing the branches
Preparing the branches
Updating the branch sprites each frame
Drawing the branches
Moving the branches
FAQ
Summary
5. Collisions, Sound, and End Conditions – Making the Game Playable
Preparing the player (and other sprites)
Drawing the player and other sprites
Handling the player's input
Handling setting up a new game
Detecting the player chopping
Detecting a key being released
Animating the chopped logs and the ax
Handling death
Simple sound FX
How SFML sound works?
When to play the sounds
Adding the sound code
Improving the game and the code
FAQ
Summary
6. Object-Oriented Programming, Classes, and SFML Views
Planning and starting the Zombie Arena game
Creating a project from the template
The project assets
Exploring the assets
Adding the assets to the project
OOP
What is OOP?
Encapsulation
Polymorphism
Inheritance
Why do it like this?
What is a class?
The class variable and function declarations
The class function definitions
Using an instance of a class
Constructors and getter functions
Jumping around in the code
Building the Player-the first class
Coding the Player class header file
Coding the Player class function definitions
Controlling the game camera with SFML View
Starting the Zombie Arena game engine
Managing the code files
Starting coding the main game loop
FAQ
Summary
7. C++ References, Sprite Sheets, and Vertex Arrays
C++ References
References summary
SFML vertex arrays and sprite sheets
What is a sprite sheet?
What is a vertex array?
Building a background from tiles
Building a vertex array
Using the vertex array to draw
Creating a randomly generated scrolling background
Using the background
FAQ
Summary
8. Pointers, the Standard Template Library, and Texture Management
Pointers
Pointer syntax
Declaring a pointer
Initializing a pointer
Reinitializing pointers
Dereferencing a pointer
Pointers are versatile and powerful
Dynamically allocated memory
Passing a pointer to a function
Declaring and using a pointer to an object
Pointers and arrays
Summary of pointers
The Standard Template Library
What is a Map
Declaring a Map
Adding data to a Map
Finding data in a Map
Removing data from a Map
Checking the size of a Map
Checking for keys in a Map
Looping/iterating through the key-value pairs of a Map
The auto keyword
STL summary
The TextureHolder Class
Coding the TextureHolder header file
Coding the TextureHolder function definitions
What exactly have we achieved with TextureHolder? Building a horde of
zombies
Coding the Zombie.h file
Coding the Zombie.cpp file
Using the Zombie class to create a horde
Bringing the horde to life (back to life)
Using the TextureHolder class for all textures
Change the way the background gets its textures
Change the way Player gets its texture
FAQ
Summary
9. Collision Detection, Pickups, and Bullets
Coding the Bullet class
Coding the Bullet header file
Coding the Bullet source file
Making the bullets fly
Including the Bullet class
Control variables and the bullet array
Reloading the gun
Shooting a bullet
Updating the bullets each frame
Drawing the bullets each frame
Giving the player a crosshair
Coding a class for pickups
Coding the Pickup header file
Coding the Pickup class function definitions
Using the Pickup class
Detecting collisions
Has a zombie been shot?
Has the player been touched by a zombie? Has the player touched a pickup?
FAQ
Summary
10. Layering Views and Implementing the HUD
Adding all the Text and HUD objects
Updating the HUD each frame
Drawing the HUD, and the home and level up screens
FAQ
Summary
11. Sound Effects, File I/O, and Finishing the Game
Saving and loading the high-score
Preparing sound effects
Leveling up
Restarting the game
Playing the rest of the sounds
Adding sound effects while the player is reloading Make a shooting sound
Play a sound when the player is hit
Play a sound when getting a pickup
Make a splat sound when a zombie is shot
FAQ
Summary
12. Abstraction and Code Management – Making Better Use of OOP The
Thomas Was Late game
Features of Thomas Was Late
Creating a project from the template
The project assets
Game level designs
GLSL Shaders
The graphical assets close-up
The sound assets close-up
Adding the assets to the project
Structuring the Thomas Was Late code
Building the game engine
Reusing the TextureHolder class
Coding Engine.h
Coding Engine.cpp
Coding the Engine class constructor definition
Coding the run function definition
Coding the input function definition
Coding the update function definition
Coding the draw function definition
The Engine class so far
Coding the main function
FAQ
Summary
13. Advanced OOP – Inheritance and Polymorphism
Inheritance
Extending a class
Polymorphism
Abstract classes - virtual and pure virtual functions
Building the PlayableCharacter class
Coding PlayableCharacter.h
Coding PlayableCharacter.cpp
Building the Thomas and Bob classes
Coding Thomas.h
Coding Thomas.cpp
Coding Bob.h
Coding Bob.cpp
Updating the game engine to use Thomas and Bob Updating Engine.h to add
an instance of Bob and Thomas Updating the input function to control
Thomas and Bob Updating the update function to spawn and update the
PlayableCharacter instances
Spawning Thomas and Bob
Updating Thomas and Bob each frame
Drawing Bob and Thomas
FAQ
Summary
14. Building Playable Levels and Collision Detection
Designing some levels
Building the LevelManager class
Coding LevelManager.h
Coding the LevelManager.cpp file
Coding the loadLevel function
Updating the engine
Collision detection
Coding the detectCollisions function
More collision detection
Summary
15. Sound Spatialization and HUD
What is Spatialization?
Emitters, attenuation, and listeners
How SFML handles spatialization
Building the SoundManager class
Coding SoundManager.h
Coding the SoundManager.cpp file
Coding the constructor
Coding the playFire function
Coding the rest of the SoundManager functions
Adding SoundManager to the game engine
Populating the sound emitters
Coding the populateEmitters function
Playing sounds
The HUD class
Coding HUD.h
Coding the HUD.cpp file
Using the HUD class
Summary
16. Extending SFML Classes, Particle Systems, and Shaders
The SFML Drawable class
An alternative to inheriting from Drawable Why it is best to inherit from
Drawable?
Building a particle system
Coding the Particle class
Coding Particle.h
Coding the Particle.cpp file
Coding the ParticleSystem class
Coding ParticleSystem.h
Coding the ParticleSystem.cpp file
Using ParticleSystem
Adding a ParticleSystem object to the Engine class Initializing
ParticleSystem
Updating the particle system in each frame Starting the particle system
Drawing the particle system
OpenGL, shaders, and GLSL
The programmable pipeline and shaders
Coding a fragment shader
Coding a vertex shader
Adding shaders to the Engine class
Loading the shaders
Updating and drawing the shader in each frame
Summary
17. Before you go...
Thanks!
Chapter 1. C++, SFML, Visual Studio, and Starting
the First Game
Welcome to Beginning C++ Game Programming. I will waste no time in
getting you started on your journey to writing great games for the PC, using
C++ and OpenGL-powered SFML.
This is quite a hefty first chapter, but we will learn absolutely everything we
need to, in order to have the first part of our first game up-and-running. Here
is what we will cover in this chapter:
Find out about the games we will build
Learn a bit about C++
Explore SFML and its relationship with C++
Look at the Visual Studio software, which we will use throughout the book
Set up a game development environment
Create a reusable project template, which will save a lot of time Plan and
prepare for the first game project, Timber!!!
Write the first C++ code of the book and make a runnable game that draws a
background
The games
We will learn the fundamentals of the super-fast C++ language, a step at a time, and then put the new
knowledge to use, so it should be fairly easy to add cool features to the three games we are building.
Tip
If you get stuck with any of the content in this chapter, take a look at the sections near the end Handling
errors and FAQs.
These are our three projects for the book:
Timber!!!
The first game is an addictive, fast-paced clone of the hugely successful
Timberman, which can be found at
http://store.steampowered.com/app/398710/. Our game, Timber!!!, will
introduce us to all the C++ basics at the same time as building a genuinely
playable game. Here is what our version of the game will look like when we
are done and we have added a few last-minute enhancements.
Zombie Arena
Next, we will build a frantic, zombie survival shooter, not unlike the Steam
hit, Over 9000 Zombies, which can be found at
http://store.steampowered.com/app/273500/. The player will have a machine
gun, and must fight off ever-growing waves of zombies. All this will take
place in a randomly generated, scrolling world. To achieve this we will learn
about object-oriented programming and how it enables us to have a large
code base (lots of code) that is easy to write and maintain. Expect exciting
features such as hundreds of enemies, rapid-fire weaponry, pickups, and a
character that can be "leveled-up" after each wave.
Thomas was Late
The third game will be a stylish and challenging puzzle platformer, which can
be played as a single player and coop. It is based on the very popular game,
Thomas was Alone, which can be found at
http://store.steampowered.com/app/220780/. Expect to learn about cool
topics such as particle effects, OpenGL Shaders, and split-screen cooperative
multiplayer features.
Tip
If you want to play any of the games now, you can do so from the download
bundle in the Runnable Games folder. Just double-click on the appropriate .exe
file. Notice that in this folder you can either run the completed games or any
game in its partially completed state from any chapter.
Let's get started by introducing C++, Visual Studio, and SFML!
Meet C++
One question you might have is, why use C++ at all? C++ is fast, very fast.
What makes this the case is the fact that the code that we write is directly
translated into machine executable instructions. These instructions make the
game. The executable game is contained within an .exe file that the player can
simply double-click to run.
There are a few steps in the process. First, the pre-processor looks to see if
any other code needs to be included within our own code and adds it when
necessary. Next, all the code is compiled into object files by the compiler
program. Finally, a third program, called the linker, joins all the object files
into the executable file, which is our game.
In addition, C++ is well established at the same time as being extremely upto-
date. C++ is an object oriented programming ( OOP ) language, which
means we can write and organize our code in a proven way that makes our
games efficient and manageable. The benefits, as well as the necessity for
this, will reveal themselves as we progress through the book.
Most of the other code to which I referred is SFML, and we will find out
more about SFML in just a minute. The pre-processor, compiler, and linker
programs I have just mentioned, are all part of the Visual Studio Integrated
Development Environment(IDE).
Microsoft Visual Studio
Visual Studio hides away the complexity of the pre-processing, compiling, and linking. It wraps it all
up into one press of a button. In addition to this, it provides a slick user interface for us to type our code
and manage what will become a large selection of code files, and other project assets as well. While
there are advanced versions of Visual Studio that cost hundreds of dollars, we will be able to build all
three of our games in the free Express
SFML
Simple Fast Media Library (SFML) is not the only C++ library for games
and multimedia. It is possible to make an argument for using other libraries,
but SFML seems to be the best for me, every time. First it is written using
object oriented C++. The benefits of this are numerous. Most of these
benefits you will experience as you progress through the book.
SFML is so easy to get started and is therefore a good choice if you are a
beginner. At the same time, it also has the potential to build the
highestquality 2D games if you are a professional. So a beginner can get
started using SFML and not worry about having to start again with a new
language/library as their experience grows.
Perhaps the biggest benefit is that most modern C++ programming uses OOP.
Every C++ beginners guide I have ever read uses and teaches OOP. OOP is,
in fact, the future (and the now) of coding in almost all languages. So why, if
you're learning C++ from the beginning, would you want to do it any other
way?
SFML has a module (code) for just about anything you would ever want to
do in a 2D game. SFML works using OpenGL, which can also make 3D
games. OpenGL is the de-facto free-to-use graphics library for games when
you want them to run on more than one platform. When you use SFML, you
are automatically using OpenGL.
SFML drastically simplifies:
2D graphics and animation including scrolling game worlds. Sound effects
and music playback, including high-quality directional sound.
Online multiplayer features
The same code can be compiled and linked on all major desktop operating
systems, and soon mobile, as well!
Extensive research has not uncovered any more suitable way to build 2D games for PC, even for expert
developers, and especially if you are a beginner and want to learn C++ in a fun gaming environment.
Setting up the development environment
Now you know a bit more about how we will be making these games, it is
time to set up a development environment so we can get coding.
What about Mac and Linux?
The games that we make can be built to run on Windows, Mac
and Linux!
The code we use will be identical for each. However, each
version does
need to be compiled and linked on the platform for which it is
intended and
Visual Studio will not be able to help us with Mac and Linux.
It would be unfair to say that this book is entirely suited for
Mac and Linux
users, especially complete beginners. Although, I guess, if you
are an
enthusiastic Mac or Linux user, and you are comfortable with
your
operating system, the vast majority of the extra challenges
you will
encounter will be in the initial setup of the development
environment,
SFML, and the first project.
To this end, I can highly recommend the following tutorials
which will
hopefully replace the next 10 pages (approximately), up to the
section
Planning Timber!!!, when this book should again become
relevant to all
operating systems.
For Linux, read this for an overview:
http://www.sfmldev.org/tutorials/2.0/start-linux.php .
For Linux, read this for step-by-step guidance:
http://en.sfmldev.org/forums/index.php?topic=9808.0 .
On Mac, read this tutorial as well as the linked out articles:
http://www.edparrish.net/common/sfml-.osx.html .
Installing Visual Studio Express 2015 on your
desktop
Installing Visual Studio can be almost as simple as downloading a file and
clicking a few buttons. It will help us, however, if we carefully run through
exactly how we do this. For this reason, I will walk through the installation
process a step at a time.
The Microsoft Visual Studio site says that you need 5 GB of hard disk space.
From experience, however, I would suggest you need at least 10 GB of free
space. In addition, these figures are slightly ambiguous. If you are planning to
install it on a secondary hard drive, you will still need at least 5 GB on the
primary hard drive because no matter where you choose to install Visual
Studio, it will need this space too.
Note
To summarize this ambiguous situation: It is essential to have a full 10 GB
space on the primary hard disk, if you intend to install Visual Studio to that
primary hard disk. On the other hand, make sure you have 5 GB on the
primary hard disk as well as 10 GB on the secondary, if you intend to install
to a secondary hard disk. Yep, stupid, I know!
1. The first thing you need is a Microsoft account and the login details. If you
have a Hotmail or MSN email address then you already have one. If not, you
can sign up for a free one here: https://login.live.com/.
2. Visit this link: https://www.visualstudio.com/en
us/downloads/download-visual-studio-vs.aspx. Click on Visual Studio 2015,
then Express 2015 for desktop then the Downloads button. The next
screenshot shows the three places to click:
3. Wait for the short download to complete and then run the downloaded file.
Now you just need to follow the on-screen instructions. However, make a
note of the folder where you choose to install Visual Studio. If you want to
do things exactly the same as me, then create a new folder called Visual Studio
2015 on your preferred hard disk and install to this folder. This whole process
could take a while depending on the speed of your Internet connection.
4. When you see the next screen, click on Launch and enter your Microsoft
account login details.
Now we can
turn to SFML.
Setting up SFML
This short tutorial will take you through downloading the SFML files that
allow us to include the functionality contained in the library. In addition, we
will see how to use the SFML DLL files that will enable our compiled object
code to run alongside SFML:
1. Visit this link on the SFML website: http://www.sfml
dev.org/download.php. Click on the button that says Latest stable version as
shown next.
2. By the time you read this guide, the latest version will almost certainly
have changed. That doesn't matter as long as you do the next step correctly.
We want to download the 32-bit version for Visual C++ 2014. This might
sound counter-intuitive because we have just installed Visual Studio 2015
and you probably (most commonly) have a 64-bit PC. The reason we choose
this download is because Visual C++ 2014 is part of Visual Studio 2015
(Visual Studio offers more than just C++) and we will be building games in
32-bit so that they run on both 32- and 64- bit machines. To be clear, click
the following download:
3. When the download completes, create a folder at the root of the same drive
where you installed Visual Studio and name it SFML. Also create another
folder at the root of the drive where you installed Visual Studio and call it
Visual Studio Stuff. We will store all kinds of Visual Studio-related things here so
Visual Studio Stuff seems like a good name. Just to be clear, here is what my hard
drive looks like after this step:
4. Obviously, the folders you have in between the highlighted three folders in
the screenshot will probably be totally different to mine. Now we are ready
for all the projects we will soon be making, create a new folder inside Visual
Studio Stuff. Name the new folder
Projects.
5. Finally, unzip the SFML download. Do this on your desktop. When
unzipping is complete you can delete the zip folder. You will be left with a
single folder on your desktop. Its name will reflect the version of SFML that
you downloaded. Mine is called SFML-2.3.2-windowsvc14-32-bit. Your file name
will likely reflect a more recent version. Double-click this folder to see the
contents, then double-click again into the next folder (mine is called SFML-
2.3.2). The following screenshot shows what my SFML-2.3.2 folder's contents
looks like, when the entire contents have been selected. Yours should look
the same.
6. Copy the entire contents of this folder, as seen in the previous screenshot,
and paste/drag all the contents into the SFML folder you created in Step 3. For
the rest of the book I will refer to this folder simply as your SFML folder.
Now we are ready to start using C++ and SFML in Visual Studio.
Creating a reusable project template
As setting up a project is a fairly fiddly process, we will create a project and
then save it as a Visual Studio template. This will save us quite a significant
amount of work each time we start a new game. So, if you find the next
tutorial a little tedious, rest assured that you will never need to do this again:
1. Start Visual Studio and, in the New Project window, click the little drop-
down arrow next to Visual C++ to reveal more options, then click Win32,
and click Win32 Console Application. You can see all these selections in
the next screenshot.
2. Now, at the bottom of the New Project window, type HelloSFML in the
Name: field.
3. Next, browse to the Visual Studio StuffProjects folder that we created in the
previous tutorial. This will be the location where all our project files will be
kept. All templates are based on an actual project. So, we will have a project
called HelloSFML but the only thing we will do with it is make a template from
it.
4. When you have completed the steps above, click OK. The next screenshot
shows the Application Settings window. Check the box for Console
application, and leave the other options as shown below.
5. Click Finish and Visual Studio will create the new project.
6. Next, we will add some fairly intricate and important project settings. This
is the laborious part but, as we will create a template, we will only need to do
this once. What we need to do is tell Visual Studio, or more specifically the
code compiler that is part of Visual Studio, where to find a special type of
code file from SFML. The special type of file I am referring to is a header
file. Header files are the files that define the format of the SFML code. So
when we use the SFML code, the compiler knows how to handle it. Note that
the header files are distinct from the main source code files and they are
contained in files with the .hpp file extension. (All this will become clearer
when we eventually start adding our own header files in the second project).
In addition, we need to tell Visual Studio where it can find the SFML library
files. From the Visual Studio main menu select Project | HelloSFML
properties.
7. In the resulting HelloSFML Property Pages window, perform the
following steps, flagged in the next screenshot.
8. Select All Configurations from the Configuration: drop-down.
9. Select C/C++ then General from the left-hand menu.
10. Locate the Additional Include Directories edit box and type the drive
letter where your SFML folder is located, followed by SFMLinclude. The full
path to type, if you located your SFML folder on your D drive, is as shown in
the screenshot: D:SFMLinclude. Vary your path if you installed SFML to a
different drive.
11. Click Apply to save your configurations so far.
12. Now, still in the same window, perform these next steps, again flagged in
the next screenshot. Select Linker then General.
13. Find the Additional Library Directories edit box and type the drive
letter where your SFML folder is, followed by SFMLlib. So the full path to type
if you located your SFML folder on your D drive is, as shown in the
screenshot, D:SFMLlib. Vary your path if you installed SFML to a different
drive.
14. Click Apply to save your configurations so far.
15. Finally for this stage, still in the same window, perform these steps,
which again refer to the next screenshot. Switch the Configuration: drop-
down(1) to Debug as we will be running and testing our games in Debug
mode.
16. Select Linker then Input (2).
17. Find the Additional Dependencies edit box (3) and click into it on the far
left-hand side. Now copy and paste/type the following: sfml
graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfmlnetwork-d.lib;sfml-audio-d.lib; at the
indicated place. Again, be
really careful to place the cursor precisely, and dont overwrite any of the text
that is already there.
18. Click OK.
19. Let's make a template from our HelloSFML project so we never have to do
this slightly mind-numbing task again. Creating a reusable project template is
really easy. In Visual Studio select File | Export Template.... Then, in the
Export Template Wizard window, make sure the Project template option
is selected, and then select HelloSFML project for the From which project
do you want to create a template option.
20. Click Next and then Finish.
Phew, that's it! Next time we create a project, I'll show you how to do it from
this template. Now let's build Timber!!!
Planning Timber!!!
Whenever you make a game it is always best to start with a pencil and paper.
If you don't know exactly how your game is going to work on the screen,
how can you possibly make it work in code?
Tip
At this point, if you haven't already, I suggest you go and watch a video of
Timberman in action, so you can see what we are aiming for. If you feel your
budget can stretch to it, then grab a copy and give it a play. It is often on sale
for under a dollar on Steam.
http://store.steampowered.com/app/398710/ .
The features and objects of a game, which define the gameplay, are known as
the mechanics. The basic mechanics of the game are:
Time is always running out.
Get more time by chopping the tree.
Chopping the tree causes the branches to fall.
The player must avoid the falling branches.
Repeat until the time runs out or the player is squished.
Expecting you to plan the C++ code at this stage is obviously a bit silly. This
is, of course, the first chapter of a C++ beginner's guide. We can, however,
take a look at all the assets we will use and an overview of what we will need
to make our C++ do what we want it to.
Take a look at a annotated screenshot of the game:
You
can see that we have the following features:
Player's current score: Each time the player chops a log he will get one
point. He can chop a log with either the left or the right arrow. Player
Character: Each time the player chops, he will move/stay on the same side
of the tree. Therefore the player must be careful which side he chooses to
chop on. When the player chops, a simple ax graphic will appear in the player
character's hands.
Shrinking time-bar: Each time the player chops, a small amount of time will
be added to the ever-shrinking time bar.
Lethal branches: The faster the player chops, the more time he will get, but
also the faster the branches will move down the tree, and therefore the more
likely he is to get squished. The branches spawn randomly at the top of the
tree and move down with each chop. When the player gets squished, which
he will quite regularly, a gravestone graphic will appear.
Chopped log: When the player chops, a chopped log graphic will whiz off
away from the player.
There are three floating clouds that will drift at random heights and speeds as
well as a bee that does nothing but fly around. All this takes place on a pretty
background.
So, in nutshell the player must frantically chop to gain points and avoid
running out of time. As a slightly perverse but fun consequence, the faster he
chops, the more likely his squishy demise.
We now know what the game looks like, how it is played, and the motivation
behind the game mechanics. We can go ahead and start to build it.
Creating a project from the template
Creating a new project is now extremely easy. Just follow these
straightforward steps in Visual Studio:
1. Select File | New Project from the main menu.
2. Make sure that Visual C++ is selected in the left-hand menu and then
select HelloSFML from the list of presented options. This next screenshot
should make this clear.
3. In the Name: field, type Timber and also make sure that the Create
directory for solution option is checked. Now click OK.
4. Now we need to copy the SFML .dll files into the main project directory.
My main project directory is D:Visual Studio StuffProjectsTimberTimber. It was
created by Visual Studio in the previous step. If you put your Projects folder
somewhere else, then perform this step there instead. The files we need to
copy into the project folder are located in your SFMLbin folder. Open a
window for each of the two locations and highlight the required files as
shown in the next screenshot on the left.
5.
Now copy and paste the highlighted files into the project folder on the right
of the previous screenshot.
The project is now set up and ready to go. You will be able to see the screen
shown in this next screenshot. I have annotated the screenshot so you can
start to familiarize yourself with Visual Studio. We will revisit all these areas,
and others, soon.
Your layout might look slightly different from the screenshot because the
windows of Visual Studio, like most applications, are customizable. Take the
time to locate the Solution Explorer window on the right and adjust it to
make its contents nice and clear, such as they are in the previous screenshot.
We will be back here really soon to start coding.
Project assets
Assets are anything you need to make your game. In our case the assets
include:
A font for the writing on the screen
Sound effects for different actions such as chopping, dying, and running out
of time
Graphics for the character, background, branches, and other game objects
All the graphics and sound required for the game are included in the
download bundle. They can be found in the Chapter 1/graphics and Chapter 1/sound
folders as appropriate.
The font that is required has not been supplied. This is because I wanted to
avoid any possible ambiguity regarding licensing. This will not cause a
problem though, as I will show you exactly where and how to choose and
download fonts for yourself.
Although I will provide either the assets themselves or information on where
to get them, you might like to create and acquire them for yourself.
Outsourcing assets
There are a number of websites that allow you to contract artists, sound engineers, and even
programmers. One of the biggest is
the www.upwork.com. You can join this site for free and post your jobs. You need to write a clear
explanation of your requirements as well as state how much you are prepared to pay. Then you will
probably get a good selection of contractors bidding to do the work. Be aware, there is a lot of
unqualified contractors whose work might be disappointing, but if you choose carefully you will likely
find a competent, enthusiastic, and great value person or company to do the job.
Making your own sound FX
Sound effects can be downloaded for free from sites
like www.freesound.org but often the license won't allow you to use them if you are selling your game.
Another option is to use an open source software called BFXR from www.bfxr.net, which can help you
generate lots of different sound effects that are yours to keep and do as you like with.
Adding assets to the project
Once you have decided which assets you will use, it is time to add them to
the project. These next instructions will assume you are using all the assets
supplied in the book's download bundle. Where you are using your own,
simply replace the appropriate sound or graphic file with your own, using
exactly the same file name.
1. Browse to the Visual D:Visual Studio
StuffProjectsTimberTimber.
2. Create three new folders within this folder and name them as
graphics, sound, and fonts.
3. From the download bundle, copy the entire contents of Chapter
1/graphics into the D:Visual Studio
StuffProjectsTimberTimbergraphics folder.
4. From the download bundle, copy the entire contents of Chapter
1/sound into the D:Visual Studio
StuffProjectsTimberTimbersound folder.
5. Now visit: http://www.1001freefonts.com/komika_poster.font in your web
browser and download the Komika Poster font.
6. Extract the contents of the zipped download and add the KOMIKAP_.ttf
file to the D:Visual Studio
StuffProjectsTimberTimberfonts folder.
Let's take a look at these assets, especially the graphics, so we can better
visualize what is happening when we use them in our C++ code.
Exploring assets
Graphical assets form the individual parts of the screen in our Timber!!!
game. Take a look at the graphical assets and it should be clear where, in our
game, they will be used.
The sound files are all .wav format. These are files containing the sound
effects that we will play at certain events throughout the game. They were all
generated using BFXR. They are:
chop.wav : A sound that is a bit like an ax (a retro ax) chopping a tree death.wav:
A sound a bit like a retro "losing" sound.
out_of_time.wav: Plays when the player loses by running out of time, as opposed
to being squashed
Understanding screen and internal coordinates
Before we move on to the actual C++ coding, let's talk a little about
coordinates. All the images that we see on our monitors are made out of
pixels. Pixels are little tiny dots of light that combine to make the images we
see.
There are many different monitor resolutions but, as an example, a fairly
typical gamer's monitor might have 1920 pixels horizontally and 1080 pixels
vertically.
The pixels are numbered starting at the top left of the screen. As you can see
from the next diagram, our 1920 x 1080 example is numbered from 0 through
to 1919 on the horizontal (x) axis and 0 through 1079 on the vertical (y) axis.
A specific and exact screen location can therefore be identified by x and y
coordinate. We create our games by drawing game objects such as
background, characters, bullets and, text, to specific locations on the screen.
These locations are identified by the coordinates of the pixels. Take a look at
this next hypothetical example of how we might draw at, approximately, the
central coordinates of the screen. In the case of a 1920 x 1080 screen this
would be at position 960, 540.
In addition to the screen coordinates, our game objects will each have their
own similar coordinate system as well. As with the screen coordinate system,
their internal or local coordinates start at 0,0 in the top left-hand corner.
We can see in the previous screenshot that 0,0 of the character is drawn at
960, 540 of the screen.
A visual, 2D game object, such as a character or perhaps a zombie, is called a
sprite. A sprite is typically made from an image file. All sprites have what is
known as an origin.
If we draw a sprite at a specific location on the screen, the origin will be
located at this specific location. The 0,0 coordinates of the sprite are the
origin. The next screenshot demonstrates this.
This is why, in the screenshot showing the character drawn to the screen,
although we drew the image at the central position (960, 540) it appears off to
the right and down a bit.
We just need to bear in mind how this works as we progress through the first
project.
Note that, in the real world, gamers have a huge variety of screen resolutions
and our games will need to work with as many of them as possible. In the
second project we will see how we can make our games dynamically adapt to
almost any resolution. In this first project we will need to assume that the
screen resolution is 1920 x 1080. Don't worry if your screen is different to
this, as I have provided a separate set of code for each chapter, for the
Timber!!! game. The code files are nearly identical, apart from adding and
swapping a few lines of code near the beginning. If you have a lower-
resolution screen, then simply follow the code in the book that assumes a
1920 x 1080 resolution and when it comes to trying out the game you can
copy and paste the code files from the low res folder in each of Chapters 1 to 5,
as appropriate. In fact, once the extra lines have been added in this first
chapter, all the rest of the code will be identical regardless of your screen
resolution. I have supplied the low-res code for each chapter, just as a
convenience. We will discuss how the few lines of code work their magic
(scale the screen) in the second project. The alternative code will work on
resolutions as low as 960 x 540 so should be good on almost any PC or
laptop.
Now we can write our first C++ code, and very soon we will see it in action.
Starting to code the game
Open up Visual Studio if it isn't already, open up the Timber project (if it isn't
already open) by left-clicking it from the Recent list on the main Visual
Studio window.
The first thing we will do is to rename our main code file. It is currently
called HelloSFML.cpp and we will rename it to the more appropriate
Timber.cpp. The .cpp stands for C plus plus.
1. Find the Solution Explorer window on the right-hand side.
2. Locate the HelloSFML.cpp file under the Source Files folder.
3. Right-click HelloSFML.cpp and choose Rename.
4. Edit the filename to Timber.cpp and press Enter.
Make some minor edits in the code window so that you have exactly the
same code as shown next. You can do so in exactly the same way that you
would with any text editor or word processor; you could even copy and paste
it if you prefer. After you have made the slight edits, we can talk about them:
// Include important C++ libraries here
#include "stdafx.h"
int main()
{
return 0;
}
This simple C++ program is a good place to start. Let's go through it line by
line
Making code clearer with comments
As you can see, the only code that needed to change was a little bit at the
very top. The first line of code is this:
// Include important C++ libraries here
Any line of code that starts with // is a comment and is ignored by the
compiler. As such, this line of code does nothing. It is used to leave any
information that we might find useful when we come back to the code at a
later date. The comment ends at the end of the line, so anything on the next
line is not part of the comment. There is another type of comment called a
multi-line or c-style comment, which can be used to leave comments that
take up more than a single line. We will see some of them later in this
chapter. Throughout this book I will leave hundreds of comments to help add
context and further explain the code.
#including Windows essentials
Now that you know what comments are for, you can probably take a decent
guess at what the next line of code does. Here it is again:
#include "stdafx.h"
The #include directive tells Visual Studio to include, or add the contents of
another file before compiling. The effect of this is that some other code, that
we have not written ourselves, will be a part of our program when we run it.
The process of adding code from other files into our code is called pre-
processing and, perhaps unsurprisingly, is performed by something called a
pre-processor. The file extension .h stands for header file.
You might be wondering what this code will do? The stdafx.h file actually
contains more #include directives itself. It adds into our program, all the
necessary code that is required to run our program on Windows. We will
never need to see this file and definitely don't need to concern ourselves with
what is in it. We just need to add the line of code at the top of every game
that we make.
What is more significant and relevant to us, and the reason it is worth
discussing the #include directive, is that we will add many more #include
directives at the top of our code files. This is to include code that we will use
and take the trouble to understand.
The main files that we will be including are the SFML header files, which
give us access to all the cool game coding features. We will also use #include to
access the C++ Standard Library header files. These header files give us
access to core features of the C++ language itself.
That's two lines squared away, so let's move on.
The main function
The next line we see in our code is this:
int main()
The code int is what is known as a type. C++ has many types and they
represent different types of data. An int is an integer or whole number. Hold
that thought and we will come back to it in a minute.
The main() code part is the name of the section of code that follows. This
section of code is marked out between the opening curly brace { and the next
closing curly brace }.
So, everything in between these curly braces {...} is a part of main. We call a
section of code like this, a function.
Every C++ program has a main function and it is the place where the
execution (running) of the entire program will start. As we progress through
the book, eventually our games will have many code files. However, there
will only ever be one main function, and no matter what code we write, our
game will always begin execution from the first line of code inside the
opening curly brace of the main function.
For now, don't worry about the strange brackets that follow the function name
(). We will discuss them further in Chapter 4: Loops, Arrays, Switch,
Enumerations, and Functions-Implementing Game Mechanics, where we will
get to see functions in a whole new and more interesting light.
Let's look closely at the one single line of code within our Main function.
Another Random Scribd Document
with Unrelated Content
“All right, I'm goin'. But all right for you!” On his way up the stairs
he passed Henrietta coming down, and she touched him lightly on
the shoulder in sign of her good-will. She was going down to meet
Carter Bruce, who had insisted that she see him that morning. She
found him awaiting her on the porch, in a mood not exactly
pleasant.
“I've got to have something definite,” he said, when he had told
her why he had come. “This can't go on a day longer.”
“I'm glad,” said Henrietta.
“Glad about what? Glad Gay is so thoroughly infatuated with that
sneak—with Freeman?”
“No, glad you know now that you do love Gay,” said Henrietta.
“That was what I hoped for, Carter: that you would discover it. For
you do love her. And, if you do, I need not worry. Gay will not prefer
Freeman to you; not if you are bold, as a lover should be.”
“She does, though,” said Carter. “I don't care what he is, he has a
way with women.”
“Why don't you have a way with them, then, if that is what is
needed?”
“Because I have n't it, that's all! I'm slow. Henrietta, she likes him
best. She likes me, but I have no chance with him around. He has to
go. You've got to give me facts. Where is this wife of his? How can I
prove he has a wife? You owe it to me, and to Gay, and to the wife,
to tell me.”
“It is enough that I say so. You can tell him I told you.”
Carter Bruce hesitated.
“I'm sorry,” he said, “but that is n't enough. I—”
Henrietta looked at him steadily for a moment and then let her
eyes fall.
“I know what you mean,” she said. “You mean you can't trust my
words. You mean I am a liar.”
“I have to be frank,” Carter said. “Gay has told me about William
Vane. She does not believe there is a William Vane. When I told her
—”
“You told her I had said Freeman has a wife?” asked Henrietta.
“And you promised not to tell, Carter!”
“I told her.”
“Well?”
“She said, 'Perhaps Henrietta is romancing again.'”
Across the street Gay came out upon her porch. She waved a
hand, and Henrietta returned the salutation, but the next moment
she guessed it had not been meant for her, for Freeman came
around the house, waving to Gay as he came. Henrietta put her
hand on Carter's arm.
“No, I can't tell you more,” she said breathlessly. “I'm sorry—only
it is true he has a wife. It is true, Carter.”
Carter's eyes hardened. He walked down the steps of the porch
and toward Freeman, until he faced him.
“You are a sneak and a cur and a cad,” he said, “and I am going
to give you this every time I see you.”
He shot out his fist and it struck Freeman on his cheek, throwing
him to the ground. An instant he lay there and then he was on his
feet and, mad with rage, had leaped for Carter. Henrietta screamed.
From across the street Gay came, her palms pressed to her cheeks.
The fight was all over before she reached the two men. Bruce stood
arranging his tie, but Freeman lay where the last blow had sent him,
prone on the grass.
Carter laughed, pantingly.
“Every time I meet you, remember,” he said, and turned to Gay.
“I thrashed him,” he said, but Gay dropped to her knees beside
the prostrate man.
“Freeman! Freeman!” she cried; and then to Carter, “You brute!
You cruel brute!”
“Oh, just as you wish!” said Carter Bruce, and laughed again, and
went across the yard to the steps and out of the gate.
“Get up!” Henrietta said, coldly, to Freeman.
“Oh! how can you be so cruel!” Gay cried, but Henrietta did not
change her tone.
“Get up!” she repeated. “Get up and go into the house.”
“How can you speak to him like that!” cried Gay, and she helped
Freeman to arise.
He was rather badly battered, and tried to hide the side of his face
where the worst blows had fallen. He laughed thinly.
“He's bigger than I am,” he said. “He hit me before I expected it.”
“He's a brute!” said Gay again.
“Go in the house!” Henrietta ordered; and without more ado
Freeman picked up his hat and went into the house. Henrietta
followed him.
For a minute more Gay stood where she was, and then she went
homeward.
“The brute! The big bully! I'll never speak to Carter Bruce again as
long as I live. Never!”
N
CHAPTER XX
ow, don't you go an' let on to your Aunt Sue, Lem,” Harvey
told the boy that night when Lem came begging to be taken
back. “You just keep your mouth shut, an' in a week or so
you come to Burlin'ton an' hunt me up. You won't have no
trouble findin' where the post-office in Burlin'ton is, an' when you git
there you go to the window, an' ask if there's a letter for Lemuel
Redding. It'll tell you where to find me, an' then you come to where
it says.”
“I'd ruther go with you,” Lem said wistfully. “I ain't ever been on a
train. I don't know how to do on a train.”
“You don't need to do nohow. You buy a ticket an' you git on the
train an' sit down in a seat. That's all you do. When the conductor
comes around, you hand him your ticket an' let him punch a hole in
it, an' when you git to Burlin'ton you ask where the post-office is.
That's all there is to it.”
“Why can't I go with you, pop? I'm sort o' scared of it.”
“I can't take no chances, Lem. If we was to go together, man an'
boy, your aunt would sure think I took you an' she would n't rest
until she fetched us back. She's got to think you've runned away. On
your own hook. I got to keep clear of you awhile. If she got a notion
I'd stole you out o' pawn she'd raise the dod-basted dickens against
me. She'd make me hand over every red cent I've got, an' I need it
to start the new business I aim to go into once I get away from
here.”
He took a fat roll of bills from his pocket. “I'm goin' to give you
twenty-five dollars, Lem,” he said solemnly. “That's more'n enough
to see you through easy. Don't you lose it. An' don't you ever let on I
give it to you.”
“I won't,” Lem promised.
Harvey had planned carefully. He meant to depart the next night,
and the next day he trudged up the hill and paid Miss Sue twenty-
five dollars on account of his debt. That might quiet her for a while
in case she learned of his departure too soon.
Miss Sue took the money, and the severe expression she had worn
when Harvey appeared softened.
“Well, I will say, Harvey, you've done better at keeping your word
than I ever thought you would. Bein' a saint has n't hurt you any—I
'll say that. I'll mark this down on the back of your note, and keep
good track of it, and I only hope you keep on the same way.”
“So do I,” said Harvey. “How's Lem carryin' on?”
“He's a trial,” Miss Susan said, “but I'll bear him.”
“You don't want I should take him away?”
“Harvey Redding, that boy stays until you get me paid the last
cent you owe me. A bargain is a bargain.”
Harvey sighed.
“Well—” he said, and went away.
That night he departed from Riverbank and Miss Sue put the
saint's five crisp bills in her purse.
A week later, Miss Susan, going to her room to retire after a hard
day, picked up her purse. It was lying on her bureau. Lorna had just
paid a week's board and Miss Sue took the money from her pocket
and opened the purse. Her eyes saw at once that the purse was
empty, the five crisp five-dollar bills Lem's father had given her were
gone.
For a moment or two she stood, her hand laid along her cheek,
thinking. No, she had not taken the money from the purse. She
could remember putting it there, but not taking it out again. She
opened her door and walked toward Lem's room.
At Lem's door she paused, for she heard the boy moving about.
She opened the door suddenly.
Lem stood, as he had stood on that other night, fully dressed and
his ragged straw hat on his head. In his hand was a handkerchief,
tied together by the four corners and bulging with the food he had
purloined to sustain him on his journey. As the door opened he
leaped for the window, but Miss Susan overtook him and dragged
him back into the room. He kicked and struck at her, but she held
fast. Lorna and Henrietta came to the door, and a minute later
Johnnie Alberson also came, all fully clad, for these pleasant nights
all sat late. Freeman did not appear; he was with Gay, across the
street, on her porch.
“You hold the little rat!” Susan cried, and Johnnie grasped the boy
from behind. Miss Susan's hands felt the boy's pockets. Unlike that
other time Lem did not struggle now.
“You leave me alone!” he kept repeating. “You better leave me
alone!”
Not until Miss Susan took the five crisp bills from his pocket did he
begin to cry.
“Don't you take that; that's my money, you old thief, you!” he
sobbed helplessly. “You stole my dollar, and you want to steal
everything, you old thief!”
“Quiet, Lem!” Henrietta said, but this time the boy paid no heed.
If she meant to suggest that he “go stiff” again, the hint was lost. All
the fight, all hope, all belief that anything would ever be right again
in his unhappy life seemed to have deserted the boy. It was Johnnie
Alberson who tried to comfort him.
“Oh, here! Come now!” he said, still holding fast to Lem, however.
“Don't cry. That's not how big boys do. What's the trouble all about,
anyway?”
“He stole from me,” said Miss Susan, holding up the money.
“I didn't! She's an old liar!” sobbed Lem, “and I don't care if I do
say it! She wants to steal all my money all the time—”
“Look at him,” said Miss Susan. “All packed up and ready to run
away! And my money in his pocket! This time there'll be no
nonsense, I tell you. He'll go packing off to reform school, where he
belongs.”
“That's all right,” said Johnnie soothingly. “We'll see about that in
the morning. The reform schools won't all close to-night. I'll go bail
for Lem to-night; I 'll take him into my room. If he gets away, Miss
Susan, you can send me to reform school in his place.”
There seemed nothing better to do and Johnnie led the boy away.
“Good-night, Miss Bates,” Johnnie called to Henrietta, for the affair
had interrupted their tête-à-tête on the porch. “I've got to keep this
young man company.”
Henrietta went down. She sat in her dark corner of the porch,
staring across the street at the porch where Gay and Freeman, she
knew, were sitting, and waited for Freeman.
Henrietta and Freeman had had one heated interview that night.
About ten o'clock, when Henrietta was still in her room, Freeman
had thrown his cigarette end from the porch and had entered the
house. Miss Susan was at work in the kitchen, where he heard her,
and he went up the stairs softly. While smoking his cigarette on the
porch, he had come to a decision.
It was clear to him that he could not long remain in Riverbank
with Carter Bruce on his trail and ready to beat him up whenever
they met. Just what Carter Bruce knew he could not guess with any
certainty, but he had enough respect for the young lawyer's fists and
enough dread of his own past to believe that if Bruce kept on, his
whole situation at Riverbank would be as unpleasant as possible,
and, being so hard put to it to raise any money whatever, he saw no
satisfactory reason why he should remain in the town. He went up
the stairs with a coldly formed and complete intention to see
whether Miss Susan had left any money in her room. If she had left
any there, he meant to take it and get away from Riverbank as
quickly and as thoroughly as possible, and he meant to take Gay
with him if she would go.
Freeman Todder was in Miss Susan's room and had already taken
the money from her purse when Henrietta opened the door.
Freeman turned to look at her.
“What are you doing here, Freeman?” Henrietta asked.
Her husband waved his hand carelessly.
“Tapping the till, dearest,” he said. “Breaking the bank. Getting the
cash.”
Henrietta advanced into the room. She spoke calmly enough.
“Now, this I will not have!” she said. “You may be a thief and a
rascal, but you must not play your tricks in this house. If you have
taken anything, put it back. Freeman, did you take any money?”
“This,” he said defiantly, and he held up the fold of crisp bills,
slipping it into his pocket again, but as he moved he looked past
Henrietta and saw Lem, surprised and wide-eyed, standing in the
doorway. Lem had come to the room to get his “other” shirt,
preparatory to his departure.
“I found it,” said Freeman slowly. “Finders is keepers, you know,
dear.” He let his eyes glare into Lem's. “And you know what I am
when I am angry, Henrietta. Any one who tells on me I'll kill. I'm
desperate, you see. I'll murder any one who tells on me.”
Lem slid back into the darkness of the hall and fled to his room.
Nothing in this house brought him anything but trouble, and he only
wanted to get away as soon as he could.
“That is nonsense,” Henrietta told Freeman. “You will never kill any
one. You are too great a coward. Now, put that money back and get
out of here before some one comes.”
For answer Freeman pushed past her.
“I 'll put nothing back,” he said. “I need this. You don't get any for
me; I've got to get for myself.”
“Freeman!”
He had gone into the hall. She followed him, and he could not
throw her hand from his arm without causing a struggle and a noise
that he did not at all desire. His wife drew him into her room.
“All right, go on with the lecture,” he said, with a laugh, “but make
it short. It won't do any good. I'm going to keep this money, and I
'm going to get away from here to-night. I 'm going so far you'll
never see me again.”
Henrietta sat on the bedside and, with her eyes on his face, let
her mind touch upon the possibilities. If Freeman went, and went
forever, her lot in life would be far simpler, far easier! But, if he fled,
and the money was gone, Miss Susan would know he had taken it,
and she already knew he was Henrietta's husband. That would
besmirch Henrietta even worse than she was now. It would be the
last straw. And even if Freeman went, it would not mean perfect
freedom for her, for he would always remain a menace, always liable
to appear again to work his husbandly blackmail and make trouble
for her. She felt unutterably depressed.
“You must put the money back now—at once,” she said wearily,
“before any one knows it is gone.”
“Too late now, Et,” he said. “Somebody knows. The only thing for
your little Freeman-boy to do is to skip out while the skipping is
good. That Lem saw me.”
“Lem?”
“Yes. He was at the door while your back was turned. He saw, and
heard, too. So there you are! Nothing left but to clear out.”
Henrietta pleaded with him.
“But not this way, Freeman! Wait. Take the money back and to-
morrow I'll borrow some. I 'll coax it out of Lorna, or Gay. Or even
Johnnie Alberson; I believe I could get some out of him. Please,
Freeman!”
“Et, you make me tired,” Freeman said. “I've got the cash and I'm
going to skip out before this night is over. That's flat, and if you
don't like it, you can lump it, and if you don't like it lumped, you can
roll it out and fry it. I'm sick of this and I'm going to vamoose. I'm
going over to say good-bye to Gay and then I'm going.”
“Freeman!” she cried, “I knew you were a despicable creature, but
I never, never, never thought you were quite as low as this!”
“Oh, cut the melodrama, Et!” he said, and while she sat looking at
him helplessly he went out of the room.
It was after this scene that she had to sit listening to Johnnie
Alberson, making conversation with him while her thoughts were on
Freeman.
From where she sat she could see Gay's white dress as a spot
against the dark brick of the house across the way, and that spot
she watched, all her plans in chaos, knowing only that if the spot
disappeared she must rush across and keep Gay safe, no matter
what else happened. When she returned from Lem's room, she
looked across with fear, and breathed her thanks, for Gay was still
there.
Almost immediately Freeman came across the street. He was not
in a pleasant mood.
“Freeman,” Henrietta said.
“My God! Again? What is it now?” he asked.
“What is it now? Throwing the blame for your thievery on that
poor boy! Hasn't he enough to bear without that? You are low—that
is the only name for it—low!”
“Fine! Fine and oratorical and everything, Et!” Freeman said
carelessly. “Only—I did not throw any blame on him. Not that I care,
you know,” he added.
“Freeman, don't lie to me. You put that money in his pocket.”
“Oh, no, I did n't!” Freeman laughed, and he held up Miss Susan's
bank-notes. “I need this money. And I have this money, and I am
going to keep this money.”
“I don't understand,” said Henrietta. “How did you get it again?
Did you take it from her a second time?”
“Oh, quit it!” Freeman said disgustedly. “Don't be stupid. This is
not the money Lem had. I've had this all the while. I don't know
where the little devil got his. What does it matter? Maybe she had
two wads. What do I care?”
“I care,” Henrietta said.
“I'm going to clear out,” Freeman said. “Last you'll ever see of
me.”
He turned toward the door leading into the house.
“Freeman, what about Gay?”
“None of your dear business, Et,” he said. Henrietta heard him
tiptoe softly up the stairs. She sat a minute longer, thinking, and
then went into the house herself, and up the stairs.
There are times when heroic actions seem the only solution of
great difficulties, but, however much a heroic act might add to the
glory of this narrative, it was not Henrietta's fortune to rise to great
heights now. She paused at Freeman's door and listened, then
opened his door.
Freeman sat on a chair at the end of his bed, in shirt and
underwear, changing his socks. On a chair close to Henrietta's hand
lay his two pairs of trousers—the one pair crumpled on the seat of
the chair; the other, newly pressed, laid carefully across the chair
back. With a sweep of her arm Henrietta gathered up both pairs of
trousers, backed from the room, and closed the door.
For a few moments, perhaps, Freeman did not realize the full
extent of the catastrophe, but in another moment he did. What
locked doors, tears, and pleadings cannot do, the loss of a man's
trousers can do. In the dark hall, before Freeman could reach his
door, Henrietta disposed of her gleanings.
“Et!” Freeman whispered: “Et! Bring those back!”
“Bring what?” she answered.
“My pants. Bring them back, and mighty quick.”
“I don't know what you are talking about,” she said. “You must be
drunk. I know nothing about your pants. Go to bed.”
From down the hall she heard the loud breathing of Johnnie
Alberson—call it a light snore if you choose. Henrietta hesitated. Ill-
fitting as Johnnie's short, wide trousers might be on slender-waisted
Freeman, she knew a man will wear any garments in a crisis, and
that Freeman would not be beneath stealing what he needed from
the sleeper. Too, through her mind flashed the thought, “If John is
awake, Freeman will not dare to make a loud fuss,” and she walked
to Johnnie's door and rapped sharply upon it.
“We—well? Well?” came Johnnie's voice, slumber heavy. “What?
What is it?”
“It's Henrietta,” she answered. “I want Lem. I want Lem to come
to me.”
She heard Lem whine, “You leave me alone, you!” and then the
reassuring voice of Johnnie, and the door opened a wide crack, and
Lem, rubbing his eyes, stepped out. Freeman's door closed.
“Come with me, Lem,” she said, and led the half-awakened boy to
her room. He staggered to her bed and threw himself upon it, asleep
the moment he touched it.
“Lem!” she called sharply, standing over him.
The boy opened his eyes slowly, looking up into her face.
“Hello!” he said. “I—I been asleep, I guess—”
“Yes. That does n't matter. You will be all right presently. I want
you to tell me the truth—the honest-to-God, cross-your-heart truth,
Lem—about that money. Where did you get it, Lem?”
“I ain't goin' to tell you,” the boy said.
Henrietta took his hand. She spoke kindly. “Yes; you must tell me,
Lem,” she urged. “Did you steal it?”
“No, I did n't steal it.”
“That's honest-to-God, cross-your-heart, Lem?”
“Yes. I did n't steal it an' anybody that says I did is an old liar,
that's what she is, an' I don't care who knows it. She's a mean, old
liar—”
“Wait, Lem. Maybe nobody is a liar. Can I believe that you did n't
steal it? Can I bet my bottom dollar on that, Lem?”
“Yes; you bet you can bet your bottom dollar on it. You can bet
your boots on it. I don't steal—only old junk. I don't steal money—”
“No, I know you don't, Lem. But Miss Susan found the money in
your pocket, did n't she?”
“I don't care where she found it. I don't care what that old devil
finds. I 'll get even with her!”
“Did she find it in your pocket, Lem?”
“Yes. Only that old Alberson had to hold me. I bet if he had n't
held me—”
“Of course. And who put the money in your pocket, Lem?”
“None of your—I mean, I won't say.”
“Did you?” Henrietta urged. “Did you put it in?”
“I won't say.”
“But, listen to me, Lem. Somebody stole some of Miss Susan's
money—”
“I know. He did it,” Lem said. “Freeman Todder did it.”
“But never mind that now. Miss Susan does n't know that. Did
Freeman, here, put the money in your pocket?”
“I won't say. I tell you I won't say. Nobody can get me to say.”
“Lem,” said Henrietta seriously, “you don't understand what all this
means. I'm trying to help you. If Miss Susan keeps on thinking you
stole her money she will send you away. She'll send you to jail and
to reform school and you'll be sad and unhappy all your life. I want
you to be happy—”
“I 'll bust out of jail if she sends me, drat her old hide!” Lem
declared.
“No; you can't. You'll be watched every minute. Boys never do
break out of jail, Lem. They just stay there and are so miserable. So
what I want to do is to help you now. So you need n't be sent away
at all.”
“If she won't send me I'm goin'away, anyway,” Lem declared. “I
won't stay in any old house with such an old hyena pickin' on me all
the time.”
“Miss Susan doesn't understand you, Lem, and you don't
understand her. But that does n't matter now. If you go away you
must not go with the name of a thief fastened on you—” The door
opened and Freeman Todder came into the room.
“Look here,” he said angrily, “I want my pants. I won't stand any
nonsense. You give them to me.”
“You're insane!” said Henrietta. “I know nothing about them.”
“Oh! that's it, is it?” he said. “All right!”
He began searching the room.
“Well, I ain't a thief, an' I don't care who says I am,” Lem was
saying. “I did n't take her old money. She took mine, an' she's an old
thief, an' I'll tell her so to her face. An' I'll make her give it back to
me. I 'll set the police on her.”
“Listen, Lem, won't you please try to help me? Won't you tell me
where you got that money?”
“No, I won't!” the boy declared stubbornly. “But I 'll tell her who
stole her money. I 'll tell her he stole it, an' when she searches him
she'll find it.”
“I 'll be hanged if she will, unless she finds my pants,” Freeman
growled.
“If you won't help me, I can't help you, Lem,” said Henrietta. “Just
to tell on Mr. Todder will not help at all. Won't you just whisper to
me where you got the money?”
“No, I won't! I'd rather be killed first!”
Freeman was throwing articles of clothing from Henrietta's closet
upon the bedroom floor. She hardly glanced at him.
“Of course! I know where you got the money, Lem,” she said.
“Your father gave it to you. Is n't that so?”
She saw the startled look in the boy's eyes.
“I won't say, I tell you!” he declared.
“Then your father did give it to you?”
“I won't tell you!”
“And I can tell Miss Susan your father gave it to you?”
“No. He said—no; I won't tell you who gave it to me! I won't tell
you what he said!”
“What did your father say?”
“I won't tell you what he said! None of your old business what he
said!”
“I see!” said Henrietta. “Your father is going away and he gave
you the money to follow him. Is that it?”
“I won't tell you!”
“You need n't tell me, Lem,” Henrietta said. “No more, at any rate.
You have told me all about it.” She turned to Freeman. “What you
are hunting is not here,” she said, “and you are only making yourself
ridiculous. Go back to your room. When I am ready I will give you
what you are hunting, but first, Freeman, you will have to tell Miss
Susan who took her money.”
Freeman looked at his wife with hatred in his eyes. He opened his
mouth to speak, but thought better of it and went out and into his
own room. The moment her door was dosed, Henrietta took Miss
Susan's money from her waist and hid it carefully, where she felt
sure it would be safe.
Poor Lem was already sound asleep and Henrietta removed her
shoes and a few of her outer garments, wrapped herself in her
bathrobe, and in a minute she too was asleep.
H
CHAPTER XXI
enrietta's first act on awakening was to look for Lem and, as
she might have expected, the boy was gone. Her next was to
look at her watch. She felt she must have slept until midday,
so different was her physical and mental condition than when
she had thrown herself on the bed. For some quite unaccountable
reason she felt tremendously strong and buoyant. For a few
moments she could not grasp why she felt so, and then she
suddenly realized that her cheer of mind was due to the fact that
Freeman, for the only time in years, was not a threatening menace,
but absolutely under her control. Until she chose to permit him to be
clad, he was her prisoner, and as her prisoner, subject to her orders.
When she had drawn on her kimona and tiptoed out of her room
on her way to the bath, she glanced at Freeman's closed door and
smiled. No need to worry about Freeman for an hour or two.
Half an hour later, fully garbed, she stepped from her room again,
and this time she tapped on Freeman's door, gently at first and then
more vigorously. There was no response. Henrietta opened the door
and looked into the room. It was empty; Freeman was gone.
In the hall, in the corner nearest Henrietta's door, stood a wood
box, receptacle for the wood used in the winter stoves, and above
this the plaster and lath had been broken. It was in the hole in the
wall thus made that Henrietta had thrust Freeman's trousers,
crowding them down out of sight. They were still there, and as if in
answer to another query that came into Henrietta's mind at the
moment, she heard Gay's voice, brisk and happy, speaking to Lorna
below. If Freeman had fled, he had not persuaded Gay to fly with
him. Probably he had fled with such covering as he could improvise,
hoping to arouse one of his boon companions and beg what was
necessary, Henrietta thought.
When she reached the hall below she found Gay, Lorna, and
Johnnie Alberson there, laughing over some item in the morning
Eagle.
“Lem has gone,” she said.
“Good for Lem,” said Johnnie, and he handed her the paper,
pointing to a headline.
“Riverbank Loses Only Saint,” the headline said. “Little Brother of
Stray Dogs Departs for Parts Unknown. Holy Life Too Strenuous For
Saint Harvey of Riverbank.”
Lorna and Johnnie, it seemed, had already breakfasted. Henrietta,
leaving the three to laugh over the article in the paper, went to the
dining-room and through it into the kitchen, where Miss Susan was
thumping at a piece of wet wood in her stove, using the lid-lifter.
“Lem has run away,” Henrietta said without preliminaries.
“And good riddance. Hope I never set eyes on him again, the
mean thief! Him and his pa, indeed! Robbin' and cheatin'!”
“No, Lem's not a thief. Here is the money you missed.”
Miss Susan looked at the bills.
“What's that money? I got mine off of him. He did n't go and steal
it over again? You don't mean to tell me that young—”
“No. It wasn't your money you found on him. That was money his
father gave him—to run away with, I suppose. He did not take your
money at all. Miss Susan, Freeman has gone.”
Miss Susan put down the lid-lifter and turned to Henrietta.
“Gone? Run off, you mean? Well, a nice kettle of fish him and you
are, I must say, you and your fine husband, lyin' and fightin' with
Carter Bruce all over my front yard, and makin' love to Gay and
Johnnie! I never heard of such go-ings-on in all my born days.
What'd that worthless husband of yours run of! for?”
She looked at Henrietta keenly.
“It was him stole my money, was n't it?” she said.
“Yes.”
“Then he's good riddance, and that's all I've got to say about
that,” said Susan. “And the farther that worthless Lem goes and the
longer he stays, the better I 'll like it. When you going?”
“Now. Any time. Whenever you wish,” said Henrietta.
“You can't go too soon to suit me,” said Miss Susan. “I've had
enough and a plenty of the whole lot of you. If you want to get
yourself some breakfast you can, and if you don't want to, you need
n't, but I hope I won't see you around too long. I've got to get your
room ready for the next boarder that comes, and I'd like to have it
empty by noon.”
Henrietta hesitated, but only for a moment. “Of course I'll go if
you want me to go, Miss Susan,” she said cheerfully. “You've been
very kind and patient with me. I just want to thank you for that. I 'll
never forget that. I will have breakfast before I go. I'm ravenous this
morning.”
She found the coffee-pot on the back of the stove, and Miss Susan
grudgingly opened the oven door and let Henrietta see where her
breakfast had been kept warm. Henrietta carried it to the dining-
room. She was eating when Johnnie Alberson came in and took a
seat opposite her.
“I'm going away,” she said.
“You! Going away! Where? What for?” he asked.
“Miss Susan needs my room; she expects another boarder.”
“But, hold on! You don't mean it, do you? Where are you going?”
“I don't know—yet. Away from Riverbank, I suppose. I have n't
had time to think yet. She just told me.”
“But, look here!” he said. “You mean she is sending you away?”
“It seems to be that.”
“It does, does it?” said Alberson, and he was out of his chair and
on his way to the kitchen, and did not wait, although she called,
“Johnnie, wait!” after him.
Henrietta ate her breakfast slowly. She could hear Johnnie's briskly
cheerful tone and Miss Susan's voice—at first hard and obstinate,
and then yielding. Johnnie came back into the din-ing-room and sat
opposite Henrietta again.
“That's all right now,” he said. “You don't have to go unless you
want to. She's willing to have you stay.”
“She is? Miss Susan is? Whatever did you say to her?”
Johnnie leaned forward and smiled at Henrietta.
“I'm an Alberson, you know; one of the River-bank Albersons,” he
said. “We are used to having our way.”
“But that's no reason—that's—she would not let that change her
mind. You said something else.”
“Why, yes; I did,” said Johnnie. “I told her you were going to
marry an Alberson. I told her you were going to marry me.”
Henrietta put down her fork and looked at him squarely.
“But I told you I had a husband. You know I have a husband in
Colorado. I told you so.”
“Of course. I remember that. I honor you for that, Henrietta. But
of course it was all a lie. You have no husband in Colorado. Have
you?” Henrietta tried to look into his eyes and say she had, but his
eyes would not look into hers seriously. They twinkled mischievously
and looked through her eyes into her heart. She drew a deep breath,
like one drowning, and looked down.
“No,” she said. “I have no husband—in Colorado.”
M
CHAPTER XXII
oses Shuder, having paid Saint Harvey of Riverbank his good
money, went back to his own junkyard feeling high elation.
The great ambition that had urged him ever since he had
begun, a raw immigrant, was consummated. He was the
mightiest Junk King of Riverbank. He need fear no paltry
competition. He could put prices down and he could buy or refuse to
buy, and he could put prices up, and no one would interfere. He saw
himself the future great man of his people, bringing his downtrodden
compatriots from Russia, sending them out upon the roads of free
America to glean the waste metals and rags, setting them up in
small trades, financing them, being a father to them. He had
eliminated Harvey Redding.
But as he considered the transaction he began to worry. It is the
duty of every man, in making a bargain, to make a good bargain—in
fact, the best possible bargain—and Shuder began to fear he had
not done that. Saint Harvey had accepted his offer almost too
promptly.
His knowledge of values quieted this fear somewhat. The junk he
had bought was worth more than he had paid for it, he knew, and
the yard was worth more than one hundred dollars per year.
Suddenly the awful thought came to him that, although he had paid
Saint Harvey cash money, he had nothing to show for it. He had no
“paper,” no receipt, no lease, nothing! Not even a witness! The cold
perspiration oozed from his every pore. He had been cheated!
Moses Shuder, lying beside his soundly sleeping—and snoring—
wife, squirmed with shame at the thought that he had been such a
fool. He pulled at his beard angrily. So be it! He would find this
Harvey Redding and make him give a paper. In the morning—
He suddenly sat bolt upright.
“Rosa, hush!” he whispered, putting his palm under her chin and
closing her mouth.
“What is it, Moses? Fire? Thieves?”
“Hush! Thieves,” he whispered. He slid out of bed and drew on his
trousers. From the lean-to where he kept his most precious junk—his
copper and his lead—came the subdued clink of metal. Stealthily
Shuder glided to his back door. He glided to the door of the lean-to.
“Thief! I got you!” he cried, and pounced upon Lem.
“You leave me alone! You let go of me!” the boy cried. But Shuder
had him fast, and scolding in Yiddish he dragged the boy from the
lean-to and into the shack.
Rosa lit the oil lamp.
“Sure!” panted Shuder. “Young Redink! Stealing chunk! Sure!”
Lem was in a panic. Fear, such as he had never experienced,
cowed him. To the mind of youth the strange foreigner seems a
thing to be jeered and hooted in the open day, but in the homes and
churches and synagogues of the foreigners are believed to lurk
strange mysteries; deep, unfathomable, blood-curdling, weird ways
and doings, especially dire when wrought upon boys. Lem, in
Shuder's grasp, did not see the poor shack with its grotesque
furnishings rescued from purchases of offcast second-hand things.
He did not see the tawdry intimate surroundings of a poor Jew
struggling to wrest comfort and life from a none too friendly
environment. Lem saw a perilous twilight in which might be worked
strange tortures, awful incantations, black wizardry. Lem was scared
stiff.
“Stealink!” said Shuder bitterly. The poor man was, indeed, almost
in tears. His natural anger was all but lost in a feeling of
hopelessness that he would ever be able to protect his property in
this land of scorn.
“You should gif him by a policemans right avay,” said Rosa. “He
should go to chail. Stealink at night!”
“Vait!” said Shuder, upraising his free hand. “Boy, vere is your
fadder?”
“I don't know,” Lem whimpered. “How do I know where he is? He
don't have to tell me, does he? You let me go, I tell you!”
“Should you tell me vere is your fadder, I let you go,” said Shuder.
“Stop viggling. I don't hurt you. Why you steal my chunk?”
“I did n't steal it. I just took some.”
“Why?” Shuder insisted.
Lem looked up at the Jew.
“I won't tell,” he said.
“Then to chail!” said Shuder.
“Well—I wanted it,” said Lem reluctantly, and suddenly he broke
down and began to ay. “I wanted to go to pop. I wanted to go to
him. He said I could go where he is.”
“Rosa, hush!” said Shuder when his wife tried to speak again, and
he began patiently, and with the little English he could command, to
comfort Lem and let him know nothing dire was to happen to him.
Slowly, Lem's fear of some mysterious fate was lessened, and
again and again he heard that Shuder, too, wished to find Saint
Harvey. Not to harm him, Shuder assured Lem; only to get a “paper”
that Saint Harvey had forgotten to leave. The importance of this
paper to Shuder loomed vast as the Jew spoke of it again and again.
In spite of his fear and hatred, Lem felt that the “paper” was
something Shuder should not be robbed of—that it was some sort of
Magna Charta of his life which Harvey had carried away by mistake.
“You won't get a policeman after me?” Lem begged.
“Sure, no! I gif you right by it. Sure, no!”
“Well, I ain't goin' to tell you. Pop he told me not to tell. But I
can't help it if you go where I go, can I?”
“Nobody could,” said Shuder. “How could you?”
“Well, then, you let me go an' I'll go. I'll go right where he told me
to, because that's what he said for me to do. And I can't help it if
you follow me. Only you better get ready to walk a long ways,
because it's sixty miles, I guess. Anyway, I guess it is.”
Shuder stroked his beard.
“Could a man go by the railroad?”
“Sure he could, if he had the money. Was n't that what I wanted
some junk for—to sell it, so I could go on the train? But I have n't
got any money. So I got to walk.”
“Mebby I should pay,” said Shuder.
Lem considered this.
“I guess that's all right,” he said, “if you want to. We'd get there
sooner, anyway.”
Lem would not, however, tell where they were to go even then,
and the next morning Shuder had to press close behind the boy at
the ticket window to overhear him ask for a ticket to Burlington. He
sat beside the boy all the way, too, never moving far from him even
when they changed cars at the junction. At noon he fed Lem from
the lunch Rosa had provided, and he bought Lem two apples from
the train-boy. Shuder was close behind the boy when Lem asked at
the post-office window for a letter for Lemuel Redding. Although he
could not read, he peered over Lem's shoulder as Lem read the
letter the clerk handed out.
“Pa ain't here no more,” said Lem, looking up at Shuder. “He's
gone somewheres.”
Shuder grasped the letter from Lem's hand and stared at it,
turning it over and over.
“Please, misder,” he begged of a man who passed, “you should
read this to me.”
The man took the letter.
“Dear Lem,” he read. “I'm going on from here because the Jews
have the junk business all tied up here from what I can see, and it's
no place for me. No telling where I 'll land up at. You better go back
to your Aunt Susan and wait until I send for you. Maybe it won't be
as long as it looks like now.”
“And the name? The name?” cried Shuder. “Redding; it looks like
Henry Redding, or something like that.”
“Well, I won't go back,” said Lem. “I don't care what he says. I
won't go back to that old aunt. I don't care if I starve to death, I
won't go back to her.”
Shuder had heard about Miss Susan on the way down from
Riverbank, for Lem had been full of a sense of injustice and had had
to talk to some one about it or burst. Lem and his troubles were
none of Shuder's affair, but, on the other hand, Saint Harvey and the
“paper” were, and Lem was Shuder's only link with Saint Harvey
now.
“Do I ask you to go back by her, Lem'vel?” Shuder demanded.
“No! But why should you vorry? Ain't I got two houses? Ain't I got
two chunkyards? Ain't I got plenty room? I esk you, come by me
awhile, Lem'vel.”
“Say, what you mean?” Lem asked. “You want me to go an' live at
your house?”
“Sure!” said Shuder.
Lem looked at the Jew.
“All right,” he said. “Until I get a word from pop. I bet you don't
have so many dishes to wash, anyway.”
Shuder raised a hand.
“Listen! Listen, Lem'vel!” he said solemnly. “I gif you my word you
should n't wash even your face if you don't want to.”
“All right, I'll come,” said Lem.
C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh
T
CHAPTER XXIII
o his very considerable surprise, Lem did not find residing with
the Shuders a painful experience. Rosa, for all her strange
ways of doing things and her incomprehensible objection to
chickens killed in any but a certain way, was a better cook
than Saint Harvey, and knew how to prepare things that a boy's
appetite found delicious. Lem had to sleep in the lean-to, on an old
iron cot set among the piles of junk, but it was summer and hot and
he enjoyed that.
Shuder made him work, but it was work that Lem liked; the kind
he had always done for his father, and he had only about half as
much of it to do as his father had made him do. He enjoyed helping
with the horse, harnessing and unharnessing it. There was only one
thing Lem refused to do—he would not go out of the junkyard. For a
week he kept under close cover. Then, one night, he stole away,
and, keeping in the alley shadows, made his way to Miss Susan's
back gate. He did not risk the rusty hinges creaking, but climbed the
fence, and dodged to the shadow of the house.
Miss Susan was in the kitchen. Lem went around the house. On
the porch Lorna sat, on one of the steps as usual, and Henrietta and
Johnnie Alberson had chairs. It was Henrietta Lem wanted. He
seated himself under the drooping spirea bushes that edged the
porch, and waited. Presently Lorna went up.
Lem heard a chair move on the porch and hoped Johnnie Alberson
was going, but he was to have no such luck. He heard Johnnie
speak.
“Henrietta,” he said, “when are we going to be married?”
“Never,” Henrietta answered, but not as if the question had
offended her.
“But I'm not going to take that for an answer,” he said. “I can't. It
would make a liar of me. I told Miss Susan I was going to marry you,
and she rather depends on it, poor soul.”
“I told you, Johnnie, I have a husband. It is ridiculous, sinful, for
you to talk to me of marrying.”
“I see! Which husband do you mean, Etta? The Colorado one who
was and then was n't?”
“Oh! please don't!” Henrietta begged. “I can't tell you. Not now.
Not yet. Perhaps never. I—”
“If you don't mean the Colorado myth,” said Johnnie, quite
unabashed, “you must mean Freeman. Do you?”
There was a momentary silence.
“Yes, I do mean Freeman,” Henrietta said then. “How did you
know he was my husband?”
“Well, you see,” said Johnnie slowly but wickedly, “he sold you to
me. The night of the row about Lem stealing Miss Susan's money,
Freeman came to my room after you had taken Lem, and we had a
frank talk—quite a frank talk. So I bought you.”
“John!”
“Yes; I did. You cost me three hundred dollars, too—a lot of
money to pay for a wife these days. You cost me two hundred—the
money he stole from me—and another hundred in cold cash that I
gave him to get away on. And my very best pants. That's three
hundred dollars plus. So that settles that.”
“He is still my husband.”
“But not for long. He threw in a promise to that effect. I made
him. He's getting a divorce now.”
“But he can't. I've always been more than faithful.”
“Yes, he can. You stole his trousers. That's grounds for the
strongest kind of divorce. That's cruelty de luxe. So that's settled.
When are you going to marry me?”
Henrietta, in spite of herself, laughed, but was serious again
instantly.
“Never, John,” she said. “I'm not going to do any more marrying.
I'm going to do penance for the marrying I have done in the past. If
what you say is true and Freeman frees me, I—”
“What?”
“I want to take that poor Lem boy and make a good man of him. I
want to do in Lem what I undid in Freeman. I want that to be my
penance.” Johnnie laughed, and arose.
“All right! We'll leave it that way to-night. Good-night, Henrietta.
You've some penance ahead of you, if I know that boy! Good-night.”
Henrietta sat thinking after Johnnie was gone. She had many things
she wished to let drift through her mind, trying each as it came up.
Johnnie Alberson first of all. If Freeman did get a divorce—
“Say!”
Henrietta, although seldom nervous, was startled by this voice
coming from the bushes.
“Who is that?” she asked, her heart standing still for a moment.
Her first thought was that it was Freeman returned.
“It's Lem,” the boy whispered. “Is he gone? Can I come out?”
“Oh, Lem! You did frighten me! Yes, come here. Where have you
been? You poor child—”
“I ain't been anywhere,” Lem said. “I'm to Shuder's—to his
junkyard. I'm junkin' for him an' he's keepin' me.”
“Shuder is? Who is Shuder?”
Lem came and stood by her side.
“He's the Jew. He's the one that pop could n't abide. He's all right,
though, Shuder is. Say—”
“Yes?”
“You know my pop—well, he went away. So I went. But he was n't
there. He said he'd send word to me when he was somewhere else
—he said he'd send it here to Aunt Susan's house. But he did n't, did
he?”
“No; I'm quite sure he has not.”
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

More Related Content

Similar to C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh (20)

DOCX
Workflow
crimzon36
 
DOCX
Workflow
crimzon36
 
PDF
Unreal Engine Basics 02 - Unreal Editor
Nick Pruehs
 
PDF
Cocos2d programming
Changwon National University
 
PDF
IntroToEngineDevelopment.pdf
zakest1
 
PPT
Introduction To Game Programming
Dien Wong
 
PDF
Introduction to Box2D Physics Engine
firstthumb
 
PDF
Making A Game Engine Is Easier Than You Think
Gorm Lai
 
PPTX
Game Programming Syllabus for B.Tech Final Year
AvinashAvuthu2
 
PDF
Monogame and xna
Lee Stott
 
PPT
Synapseindia dot net development about programming
Synapseindiappsdevelopment
 
DOCX
Types of Gaming Program
AbdullahWakeel1
 
PPTX
Clayton Wang presentation
cwang36
 
PPT
Programming
fika sweety
 
DOCX
2d game anthony newman brother
anthonynewman
 
PPTX
SynapseIndia dotnet debugging development process
Synapseindiappsdevelopment
 
PPTX
Beginning direct3d gameprogramming01_20161102_jintaeks
JinTaek Seo
 
PPTX
Introduction to Game Development
Shaan Alam
 
PDF
Cocos2d 소개 - Korea Linux Forum 2014
Changwon National University
 
ODP
SDL2 Game Development VT Code Camp 2013
Eric Basile
 
Workflow
crimzon36
 
Workflow
crimzon36
 
Unreal Engine Basics 02 - Unreal Editor
Nick Pruehs
 
Cocos2d programming
Changwon National University
 
IntroToEngineDevelopment.pdf
zakest1
 
Introduction To Game Programming
Dien Wong
 
Introduction to Box2D Physics Engine
firstthumb
 
Making A Game Engine Is Easier Than You Think
Gorm Lai
 
Game Programming Syllabus for B.Tech Final Year
AvinashAvuthu2
 
Monogame and xna
Lee Stott
 
Synapseindia dot net development about programming
Synapseindiappsdevelopment
 
Types of Gaming Program
AbdullahWakeel1
 
Clayton Wang presentation
cwang36
 
Programming
fika sweety
 
2d game anthony newman brother
anthonynewman
 
SynapseIndia dotnet debugging development process
Synapseindiappsdevelopment
 
Beginning direct3d gameprogramming01_20161102_jintaeks
JinTaek Seo
 
Introduction to Game Development
Shaan Alam
 
Cocos2d 소개 - Korea Linux Forum 2014
Changwon National University
 
SDL2 Game Development VT Code Camp 2013
Eric Basile
 

Recently uploaded (20)

PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Ad

C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh

  • 1. C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh download https://ebookbell.com/product/c-game-programming-learn-game- programming-with-c-step-by-step-very-easy-am-moh-37623908 Explore and download more ebooks at ebookbell.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. C Game Programming Learn Game Programming With C Step By Step Very Easy Am Moh https://ebookbell.com/product/c-game-programming-learn-game- programming-with-c-step-by-step-very-easy-am-moh-42327138 C Game Programming Learn Game Programming With C Step By Step Very Easy Moh https://ebookbell.com/product/c-game-programming-learn-game- programming-with-c-step-by-step-very-easy-moh-42295524 C Game Development By Example Learn To Build Games And Graphics With Sfml Opengl And Vulkan Using C Programming Siddharth Shekar https://ebookbell.com/product/c-game-development-by-example-learn-to- build-games-and-graphics-with-sfml-opengl-and-vulkan-using-c- programming-siddharth-shekar-11124250 Handson Game Development With Webassembly Learn Webassembly C Programming By Building A Retro Space Game 1st Edition Rick Battagline https://ebookbell.com/product/handson-game-development-with- webassembly-learn-webassembly-c-programming-by-building-a-retro-space- game-1st-edition-rick-battagline-36528724
  • 3. Coding Fun Learn C Programming With Games Animations And Mobile Apps Amrico Moreira https://ebookbell.com/product/coding-fun-learn-c-programming-with- games-animations-and-mobile-apps-amrico-moreira-231944410 Learning C By Creating Games With Ue4 Learn C Programming With A Fun Realworld Application That Allows You To Create Your Own Games William Sherif https://ebookbell.com/product/learning-c-by-creating-games-with- ue4-learn-c-programming-with-a-fun-realworld-application-that-allows- you-to-create-your-own-games-william-sherif-5108028 Learning C By Creating Games With Ue4 Learn C Programming With A Fun Realworld Application That Allows You To Create Your Own Games William Sherif https://ebookbell.com/product/learning-c-by-creating-games-with- ue4-learn-c-programming-with-a-fun-realworld-application-that-allows- you-to-create-your-own-games-william-sherif-6724808 Learning C 7 By Developing Games With Unity 2017 Learn C Programming By Building Fun And Interactive Games With Unity Third Edition 3rd Edition Micael Dagraca Greg Lukosek https://ebookbell.com/product/learning-c-7-by-developing-games-with- unity-2017-learn-c-programming-by-building-fun-and-interactive-games- with-unity-third-edition-3rd-edition-micael-dagraca-greg- lukosek-7250930 C Game Programming Learn C Games Very Easy For Beginners Boo https://ebookbell.com/product/c-game-programming-learn-c-games-very- easy-for-beginners-boo-38381288
  • 9. Table of Contents Beginning C++ Game Programming Credits About the Author About the Reviewer www.PacktPub.com eBooks, discount offers, and more Why subscribe? Dedication Preface Timber!!!
  • 10. Zombie ArenaTable of ContentsThomas was Late What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Downloading the color images of this book Errata Piracy Questions 1. C++, SFML, Visual Studio, and Starting the First Game The games Timber!!! Zombie Arena Thomas was Late Meet C++ Microsoft Visual Studio SFML Setting up the development environment What about Mac and Linux? Installing Visual Studio Express 2015 on your desktop Setting up SFML Creating a reusable project template Planning Timber!!! Creating a project from the template Project assets Outsourcing assets Making your own sound FX
  • 11. Adding assets to the project Exploring assets Understanding screen and internal coordinates Starting to code the game Making code clearer with comments #including Windows essentials The main function Presentation and syntax Returning values from a function Running the game Opening a window using SFML #including SFML features OOP, classes, objects Using namespace sf SFML VideoMode and RenderWindow Running the game The main game loop While loops C-style code comments Input, update, draw, repeat Detecting a key press Clearing and drawing the scene Running the game Drawing the game background Preparing the sprite using a texture Double-buffering the background sprite Running the game Handling errors Configuration errors Compile errors Link errors Bugs FAQ Summary 2. Variables, Operators, and Decisions – Animating Sprites C++ variables Types of variable
  • 12. Constants User-defined types Declaring and initializing variables Declaring variables Initializing variables Declaring and initializing in one step Declaring and initializing user-defined types Manipulating variables C++ arithmetic and assignment operators Getting things done with expressions Adding clouds, a tree, and a buzzing bee Preparing the tree Preparing the bee Preparing the clouds Drawing the tree, the bee, and the clouds Random numbers Generating random numbers in C++ Making decisions with if and else Logical operators C++ if and else If they come over the bridge, shoot them! Or do this instead Reader challenge Timing The frame-rate problem The SFML frame-rate solution Moving the clouds and the bee Giving life to the bee Blowing the clouds FAQ Summary 3. C++ Strings, SFML Time, Player Input, and HUD Pausing and restarting the game C++ strings Declaring strings Assigning a value to strings Manipulating strings SFML Text and Font
  • 13. Adding a score and a message Adding a time bar FAQ Summary 4. Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics Loops while loops Breaking out of a while loop for loops Arrays Declaring an array Initializing the elements of an array Quickly initializing the elements of an array So what do these arrays really do for our games? Making decisions with switch Class enumerations Getting started with functions Function return types Function names Function parameters The function body Function prototypes Organizing functions Function gotcha! Final word on functions - for now Absolute final word on functions - for now Growing the branches Preparing the branches Updating the branch sprites each frame Drawing the branches Moving the branches FAQ Summary 5. Collisions, Sound, and End Conditions – Making the Game Playable Preparing the player (and other sprites) Drawing the player and other sprites
  • 14. Handling the player's input Handling setting up a new game Detecting the player chopping Detecting a key being released Animating the chopped logs and the ax Handling death Simple sound FX How SFML sound works? When to play the sounds Adding the sound code Improving the game and the code FAQ Summary 6. Object-Oriented Programming, Classes, and SFML Views Planning and starting the Zombie Arena game Creating a project from the template The project assets Exploring the assets Adding the assets to the project OOP What is OOP? Encapsulation Polymorphism Inheritance Why do it like this? What is a class? The class variable and function declarations The class function definitions Using an instance of a class Constructors and getter functions Jumping around in the code Building the Player-the first class Coding the Player class header file Coding the Player class function definitions Controlling the game camera with SFML View Starting the Zombie Arena game engine Managing the code files
  • 15. Starting coding the main game loop FAQ Summary 7. C++ References, Sprite Sheets, and Vertex Arrays C++ References References summary SFML vertex arrays and sprite sheets What is a sprite sheet? What is a vertex array? Building a background from tiles Building a vertex array Using the vertex array to draw Creating a randomly generated scrolling background Using the background FAQ Summary 8. Pointers, the Standard Template Library, and Texture Management Pointers Pointer syntax Declaring a pointer Initializing a pointer Reinitializing pointers Dereferencing a pointer Pointers are versatile and powerful Dynamically allocated memory Passing a pointer to a function Declaring and using a pointer to an object Pointers and arrays Summary of pointers The Standard Template Library What is a Map Declaring a Map Adding data to a Map Finding data in a Map Removing data from a Map Checking the size of a Map Checking for keys in a Map
  • 16. Looping/iterating through the key-value pairs of a Map The auto keyword STL summary The TextureHolder Class Coding the TextureHolder header file Coding the TextureHolder function definitions What exactly have we achieved with TextureHolder? Building a horde of zombies Coding the Zombie.h file Coding the Zombie.cpp file Using the Zombie class to create a horde Bringing the horde to life (back to life) Using the TextureHolder class for all textures Change the way the background gets its textures Change the way Player gets its texture FAQ Summary 9. Collision Detection, Pickups, and Bullets Coding the Bullet class Coding the Bullet header file Coding the Bullet source file Making the bullets fly Including the Bullet class Control variables and the bullet array Reloading the gun Shooting a bullet Updating the bullets each frame Drawing the bullets each frame Giving the player a crosshair Coding a class for pickups Coding the Pickup header file Coding the Pickup class function definitions Using the Pickup class Detecting collisions Has a zombie been shot? Has the player been touched by a zombie? Has the player touched a pickup? FAQ
  • 17. Summary 10. Layering Views and Implementing the HUD Adding all the Text and HUD objects Updating the HUD each frame Drawing the HUD, and the home and level up screens FAQ Summary 11. Sound Effects, File I/O, and Finishing the Game Saving and loading the high-score Preparing sound effects Leveling up Restarting the game Playing the rest of the sounds Adding sound effects while the player is reloading Make a shooting sound Play a sound when the player is hit Play a sound when getting a pickup Make a splat sound when a zombie is shot FAQ Summary 12. Abstraction and Code Management – Making Better Use of OOP The Thomas Was Late game Features of Thomas Was Late Creating a project from the template The project assets Game level designs GLSL Shaders The graphical assets close-up The sound assets close-up Adding the assets to the project Structuring the Thomas Was Late code Building the game engine Reusing the TextureHolder class Coding Engine.h Coding Engine.cpp Coding the Engine class constructor definition Coding the run function definition Coding the input function definition
  • 18. Coding the update function definition Coding the draw function definition The Engine class so far Coding the main function FAQ Summary 13. Advanced OOP – Inheritance and Polymorphism Inheritance Extending a class Polymorphism Abstract classes - virtual and pure virtual functions Building the PlayableCharacter class Coding PlayableCharacter.h Coding PlayableCharacter.cpp Building the Thomas and Bob classes Coding Thomas.h Coding Thomas.cpp Coding Bob.h Coding Bob.cpp Updating the game engine to use Thomas and Bob Updating Engine.h to add an instance of Bob and Thomas Updating the input function to control Thomas and Bob Updating the update function to spawn and update the PlayableCharacter instances Spawning Thomas and Bob Updating Thomas and Bob each frame Drawing Bob and Thomas FAQ Summary 14. Building Playable Levels and Collision Detection Designing some levels Building the LevelManager class Coding LevelManager.h Coding the LevelManager.cpp file Coding the loadLevel function Updating the engine Collision detection Coding the detectCollisions function
  • 19. More collision detection Summary 15. Sound Spatialization and HUD What is Spatialization? Emitters, attenuation, and listeners How SFML handles spatialization Building the SoundManager class Coding SoundManager.h Coding the SoundManager.cpp file Coding the constructor Coding the playFire function Coding the rest of the SoundManager functions Adding SoundManager to the game engine Populating the sound emitters Coding the populateEmitters function Playing sounds The HUD class Coding HUD.h Coding the HUD.cpp file Using the HUD class Summary 16. Extending SFML Classes, Particle Systems, and Shaders The SFML Drawable class An alternative to inheriting from Drawable Why it is best to inherit from Drawable? Building a particle system Coding the Particle class Coding Particle.h Coding the Particle.cpp file Coding the ParticleSystem class Coding ParticleSystem.h Coding the ParticleSystem.cpp file Using ParticleSystem Adding a ParticleSystem object to the Engine class Initializing ParticleSystem Updating the particle system in each frame Starting the particle system Drawing the particle system
  • 20. OpenGL, shaders, and GLSL The programmable pipeline and shaders Coding a fragment shader Coding a vertex shader Adding shaders to the Engine class Loading the shaders Updating and drawing the shader in each frame Summary 17. Before you go... Thanks!
  • 21. Chapter 1. C++, SFML, Visual Studio, and Starting the First Game Welcome to Beginning C++ Game Programming. I will waste no time in getting you started on your journey to writing great games for the PC, using C++ and OpenGL-powered SFML. This is quite a hefty first chapter, but we will learn absolutely everything we need to, in order to have the first part of our first game up-and-running. Here is what we will cover in this chapter: Find out about the games we will build Learn a bit about C++ Explore SFML and its relationship with C++ Look at the Visual Studio software, which we will use throughout the book Set up a game development environment Create a reusable project template, which will save a lot of time Plan and prepare for the first game project, Timber!!! Write the first C++ code of the book and make a runnable game that draws a background The games We will learn the fundamentals of the super-fast C++ language, a step at a time, and then put the new knowledge to use, so it should be fairly easy to add cool features to the three games we are building. Tip If you get stuck with any of the content in this chapter, take a look at the sections near the end Handling errors and FAQs. These are our three projects for the book:
  • 22. Timber!!! The first game is an addictive, fast-paced clone of the hugely successful Timberman, which can be found at http://store.steampowered.com/app/398710/. Our game, Timber!!!, will introduce us to all the C++ basics at the same time as building a genuinely playable game. Here is what our version of the game will look like when we are done and we have added a few last-minute enhancements.
  • 23. Zombie Arena Next, we will build a frantic, zombie survival shooter, not unlike the Steam hit, Over 9000 Zombies, which can be found at http://store.steampowered.com/app/273500/. The player will have a machine gun, and must fight off ever-growing waves of zombies. All this will take place in a randomly generated, scrolling world. To achieve this we will learn about object-oriented programming and how it enables us to have a large code base (lots of code) that is easy to write and maintain. Expect exciting features such as hundreds of enemies, rapid-fire weaponry, pickups, and a character that can be "leveled-up" after each wave.
  • 24. Thomas was Late The third game will be a stylish and challenging puzzle platformer, which can be played as a single player and coop. It is based on the very popular game, Thomas was Alone, which can be found at http://store.steampowered.com/app/220780/. Expect to learn about cool topics such as particle effects, OpenGL Shaders, and split-screen cooperative multiplayer features. Tip If you want to play any of the games now, you can do so from the download bundle in the Runnable Games folder. Just double-click on the appropriate .exe file. Notice that in this folder you can either run the completed games or any game in its partially completed state from any chapter. Let's get started by introducing C++, Visual Studio, and SFML!
  • 25. Meet C++ One question you might have is, why use C++ at all? C++ is fast, very fast. What makes this the case is the fact that the code that we write is directly translated into machine executable instructions. These instructions make the game. The executable game is contained within an .exe file that the player can simply double-click to run. There are a few steps in the process. First, the pre-processor looks to see if any other code needs to be included within our own code and adds it when necessary. Next, all the code is compiled into object files by the compiler program. Finally, a third program, called the linker, joins all the object files into the executable file, which is our game. In addition, C++ is well established at the same time as being extremely upto- date. C++ is an object oriented programming ( OOP ) language, which means we can write and organize our code in a proven way that makes our games efficient and manageable. The benefits, as well as the necessity for this, will reveal themselves as we progress through the book. Most of the other code to which I referred is SFML, and we will find out more about SFML in just a minute. The pre-processor, compiler, and linker programs I have just mentioned, are all part of the Visual Studio Integrated Development Environment(IDE). Microsoft Visual Studio Visual Studio hides away the complexity of the pre-processing, compiling, and linking. It wraps it all up into one press of a button. In addition to this, it provides a slick user interface for us to type our code and manage what will become a large selection of code files, and other project assets as well. While there are advanced versions of Visual Studio that cost hundreds of dollars, we will be able to build all three of our games in the free Express
  • 26. SFML Simple Fast Media Library (SFML) is not the only C++ library for games and multimedia. It is possible to make an argument for using other libraries, but SFML seems to be the best for me, every time. First it is written using object oriented C++. The benefits of this are numerous. Most of these benefits you will experience as you progress through the book. SFML is so easy to get started and is therefore a good choice if you are a beginner. At the same time, it also has the potential to build the highestquality 2D games if you are a professional. So a beginner can get started using SFML and not worry about having to start again with a new language/library as their experience grows. Perhaps the biggest benefit is that most modern C++ programming uses OOP. Every C++ beginners guide I have ever read uses and teaches OOP. OOP is, in fact, the future (and the now) of coding in almost all languages. So why, if you're learning C++ from the beginning, would you want to do it any other way? SFML has a module (code) for just about anything you would ever want to do in a 2D game. SFML works using OpenGL, which can also make 3D games. OpenGL is the de-facto free-to-use graphics library for games when you want them to run on more than one platform. When you use SFML, you are automatically using OpenGL. SFML drastically simplifies: 2D graphics and animation including scrolling game worlds. Sound effects and music playback, including high-quality directional sound. Online multiplayer features The same code can be compiled and linked on all major desktop operating systems, and soon mobile, as well! Extensive research has not uncovered any more suitable way to build 2D games for PC, even for expert developers, and especially if you are a beginner and want to learn C++ in a fun gaming environment.
  • 27. Setting up the development environment Now you know a bit more about how we will be making these games, it is time to set up a development environment so we can get coding. What about Mac and Linux? The games that we make can be built to run on Windows, Mac and Linux! The code we use will be identical for each. However, each version does need to be compiled and linked on the platform for which it is intended and Visual Studio will not be able to help us with Mac and Linux. It would be unfair to say that this book is entirely suited for Mac and Linux users, especially complete beginners. Although, I guess, if you are an enthusiastic Mac or Linux user, and you are comfortable with your operating system, the vast majority of the extra challenges you will encounter will be in the initial setup of the development environment, SFML, and the first project. To this end, I can highly recommend the following tutorials which will hopefully replace the next 10 pages (approximately), up to the section Planning Timber!!!, when this book should again become relevant to all operating systems. For Linux, read this for an overview: http://www.sfmldev.org/tutorials/2.0/start-linux.php . For Linux, read this for step-by-step guidance: http://en.sfmldev.org/forums/index.php?topic=9808.0 . On Mac, read this tutorial as well as the linked out articles: http://www.edparrish.net/common/sfml-.osx.html .
  • 28. Installing Visual Studio Express 2015 on your desktop Installing Visual Studio can be almost as simple as downloading a file and clicking a few buttons. It will help us, however, if we carefully run through exactly how we do this. For this reason, I will walk through the installation process a step at a time. The Microsoft Visual Studio site says that you need 5 GB of hard disk space. From experience, however, I would suggest you need at least 10 GB of free space. In addition, these figures are slightly ambiguous. If you are planning to install it on a secondary hard drive, you will still need at least 5 GB on the primary hard drive because no matter where you choose to install Visual Studio, it will need this space too. Note To summarize this ambiguous situation: It is essential to have a full 10 GB space on the primary hard disk, if you intend to install Visual Studio to that primary hard disk. On the other hand, make sure you have 5 GB on the primary hard disk as well as 10 GB on the secondary, if you intend to install to a secondary hard disk. Yep, stupid, I know! 1. The first thing you need is a Microsoft account and the login details. If you have a Hotmail or MSN email address then you already have one. If not, you can sign up for a free one here: https://login.live.com/. 2. Visit this link: https://www.visualstudio.com/en us/downloads/download-visual-studio-vs.aspx. Click on Visual Studio 2015, then Express 2015 for desktop then the Downloads button. The next screenshot shows the three places to click:
  • 29. 3. Wait for the short download to complete and then run the downloaded file. Now you just need to follow the on-screen instructions. However, make a note of the folder where you choose to install Visual Studio. If you want to do things exactly the same as me, then create a new folder called Visual Studio 2015 on your preferred hard disk and install to this folder. This whole process could take a while depending on the speed of your Internet connection. 4. When you see the next screen, click on Launch and enter your Microsoft account login details.
  • 30. Now we can turn to SFML.
  • 31. Setting up SFML This short tutorial will take you through downloading the SFML files that allow us to include the functionality contained in the library. In addition, we will see how to use the SFML DLL files that will enable our compiled object code to run alongside SFML: 1. Visit this link on the SFML website: http://www.sfml dev.org/download.php. Click on the button that says Latest stable version as shown next. 2. By the time you read this guide, the latest version will almost certainly have changed. That doesn't matter as long as you do the next step correctly. We want to download the 32-bit version for Visual C++ 2014. This might sound counter-intuitive because we have just installed Visual Studio 2015 and you probably (most commonly) have a 64-bit PC. The reason we choose this download is because Visual C++ 2014 is part of Visual Studio 2015 (Visual Studio offers more than just C++) and we will be building games in 32-bit so that they run on both 32- and 64- bit machines. To be clear, click the following download:
  • 32. 3. When the download completes, create a folder at the root of the same drive where you installed Visual Studio and name it SFML. Also create another folder at the root of the drive where you installed Visual Studio and call it Visual Studio Stuff. We will store all kinds of Visual Studio-related things here so Visual Studio Stuff seems like a good name. Just to be clear, here is what my hard drive looks like after this step: 4. Obviously, the folders you have in between the highlighted three folders in the screenshot will probably be totally different to mine. Now we are ready for all the projects we will soon be making, create a new folder inside Visual Studio Stuff. Name the new folder Projects.
  • 33. 5. Finally, unzip the SFML download. Do this on your desktop. When unzipping is complete you can delete the zip folder. You will be left with a single folder on your desktop. Its name will reflect the version of SFML that you downloaded. Mine is called SFML-2.3.2-windowsvc14-32-bit. Your file name will likely reflect a more recent version. Double-click this folder to see the contents, then double-click again into the next folder (mine is called SFML- 2.3.2). The following screenshot shows what my SFML-2.3.2 folder's contents looks like, when the entire contents have been selected. Yours should look the same. 6. Copy the entire contents of this folder, as seen in the previous screenshot, and paste/drag all the contents into the SFML folder you created in Step 3. For the rest of the book I will refer to this folder simply as your SFML folder. Now we are ready to start using C++ and SFML in Visual Studio.
  • 34. Creating a reusable project template As setting up a project is a fairly fiddly process, we will create a project and then save it as a Visual Studio template. This will save us quite a significant amount of work each time we start a new game. So, if you find the next tutorial a little tedious, rest assured that you will never need to do this again: 1. Start Visual Studio and, in the New Project window, click the little drop- down arrow next to Visual C++ to reveal more options, then click Win32, and click Win32 Console Application. You can see all these selections in the next screenshot. 2. Now, at the bottom of the New Project window, type HelloSFML in the Name: field. 3. Next, browse to the Visual Studio StuffProjects folder that we created in the previous tutorial. This will be the location where all our project files will be kept. All templates are based on an actual project. So, we will have a project called HelloSFML but the only thing we will do with it is make a template from it. 4. When you have completed the steps above, click OK. The next screenshot shows the Application Settings window. Check the box for Console application, and leave the other options as shown below.
  • 35. 5. Click Finish and Visual Studio will create the new project. 6. Next, we will add some fairly intricate and important project settings. This is the laborious part but, as we will create a template, we will only need to do this once. What we need to do is tell Visual Studio, or more specifically the code compiler that is part of Visual Studio, where to find a special type of code file from SFML. The special type of file I am referring to is a header file. Header files are the files that define the format of the SFML code. So when we use the SFML code, the compiler knows how to handle it. Note that the header files are distinct from the main source code files and they are contained in files with the .hpp file extension. (All this will become clearer when we eventually start adding our own header files in the second project). In addition, we need to tell Visual Studio where it can find the SFML library files. From the Visual Studio main menu select Project | HelloSFML properties. 7. In the resulting HelloSFML Property Pages window, perform the following steps, flagged in the next screenshot. 8. Select All Configurations from the Configuration: drop-down. 9. Select C/C++ then General from the left-hand menu. 10. Locate the Additional Include Directories edit box and type the drive letter where your SFML folder is located, followed by SFMLinclude. The full path to type, if you located your SFML folder on your D drive, is as shown in the screenshot: D:SFMLinclude. Vary your path if you installed SFML to a different drive.
  • 36. 11. Click Apply to save your configurations so far. 12. Now, still in the same window, perform these next steps, again flagged in the next screenshot. Select Linker then General. 13. Find the Additional Library Directories edit box and type the drive letter where your SFML folder is, followed by SFMLlib. So the full path to type if you located your SFML folder on your D drive is, as shown in the screenshot, D:SFMLlib. Vary your path if you installed SFML to a different drive. 14. Click Apply to save your configurations so far. 15. Finally for this stage, still in the same window, perform these steps, which again refer to the next screenshot. Switch the Configuration: drop- down(1) to Debug as we will be running and testing our games in Debug mode. 16. Select Linker then Input (2). 17. Find the Additional Dependencies edit box (3) and click into it on the far left-hand side. Now copy and paste/type the following: sfml graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfmlnetwork-d.lib;sfml-audio-d.lib; at the indicated place. Again, be really careful to place the cursor precisely, and dont overwrite any of the text that is already there. 18. Click OK. 19. Let's make a template from our HelloSFML project so we never have to do this slightly mind-numbing task again. Creating a reusable project template is really easy. In Visual Studio select File | Export Template.... Then, in the Export Template Wizard window, make sure the Project template option is selected, and then select HelloSFML project for the From which project
  • 37. do you want to create a template option. 20. Click Next and then Finish. Phew, that's it! Next time we create a project, I'll show you how to do it from this template. Now let's build Timber!!!
  • 38. Planning Timber!!! Whenever you make a game it is always best to start with a pencil and paper. If you don't know exactly how your game is going to work on the screen, how can you possibly make it work in code? Tip At this point, if you haven't already, I suggest you go and watch a video of Timberman in action, so you can see what we are aiming for. If you feel your budget can stretch to it, then grab a copy and give it a play. It is often on sale for under a dollar on Steam. http://store.steampowered.com/app/398710/ . The features and objects of a game, which define the gameplay, are known as the mechanics. The basic mechanics of the game are: Time is always running out. Get more time by chopping the tree. Chopping the tree causes the branches to fall. The player must avoid the falling branches. Repeat until the time runs out or the player is squished. Expecting you to plan the C++ code at this stage is obviously a bit silly. This is, of course, the first chapter of a C++ beginner's guide. We can, however, take a look at all the assets we will use and an overview of what we will need to make our C++ do what we want it to. Take a look at a annotated screenshot of the game:
  • 39. You can see that we have the following features: Player's current score: Each time the player chops a log he will get one point. He can chop a log with either the left or the right arrow. Player Character: Each time the player chops, he will move/stay on the same side of the tree. Therefore the player must be careful which side he chooses to chop on. When the player chops, a simple ax graphic will appear in the player character's hands. Shrinking time-bar: Each time the player chops, a small amount of time will be added to the ever-shrinking time bar. Lethal branches: The faster the player chops, the more time he will get, but also the faster the branches will move down the tree, and therefore the more likely he is to get squished. The branches spawn randomly at the top of the tree and move down with each chop. When the player gets squished, which he will quite regularly, a gravestone graphic will appear. Chopped log: When the player chops, a chopped log graphic will whiz off away from the player. There are three floating clouds that will drift at random heights and speeds as well as a bee that does nothing but fly around. All this takes place on a pretty background. So, in nutshell the player must frantically chop to gain points and avoid
  • 40. running out of time. As a slightly perverse but fun consequence, the faster he chops, the more likely his squishy demise. We now know what the game looks like, how it is played, and the motivation behind the game mechanics. We can go ahead and start to build it.
  • 41. Creating a project from the template Creating a new project is now extremely easy. Just follow these straightforward steps in Visual Studio: 1. Select File | New Project from the main menu. 2. Make sure that Visual C++ is selected in the left-hand menu and then select HelloSFML from the list of presented options. This next screenshot should make this clear. 3. In the Name: field, type Timber and also make sure that the Create directory for solution option is checked. Now click OK. 4. Now we need to copy the SFML .dll files into the main project directory. My main project directory is D:Visual Studio StuffProjectsTimberTimber. It was created by Visual Studio in the previous step. If you put your Projects folder somewhere else, then perform this step there instead. The files we need to copy into the project folder are located in your SFMLbin folder. Open a window for each of the two locations and highlight the required files as shown in the next screenshot on the left.
  • 42. 5. Now copy and paste the highlighted files into the project folder on the right of the previous screenshot. The project is now set up and ready to go. You will be able to see the screen shown in this next screenshot. I have annotated the screenshot so you can start to familiarize yourself with Visual Studio. We will revisit all these areas, and others, soon. Your layout might look slightly different from the screenshot because the windows of Visual Studio, like most applications, are customizable. Take the
  • 43. time to locate the Solution Explorer window on the right and adjust it to make its contents nice and clear, such as they are in the previous screenshot. We will be back here really soon to start coding.
  • 44. Project assets Assets are anything you need to make your game. In our case the assets include: A font for the writing on the screen Sound effects for different actions such as chopping, dying, and running out of time Graphics for the character, background, branches, and other game objects All the graphics and sound required for the game are included in the download bundle. They can be found in the Chapter 1/graphics and Chapter 1/sound folders as appropriate. The font that is required has not been supplied. This is because I wanted to avoid any possible ambiguity regarding licensing. This will not cause a problem though, as I will show you exactly where and how to choose and download fonts for yourself. Although I will provide either the assets themselves or information on where to get them, you might like to create and acquire them for yourself. Outsourcing assets There are a number of websites that allow you to contract artists, sound engineers, and even programmers. One of the biggest is the www.upwork.com. You can join this site for free and post your jobs. You need to write a clear explanation of your requirements as well as state how much you are prepared to pay. Then you will probably get a good selection of contractors bidding to do the work. Be aware, there is a lot of unqualified contractors whose work might be disappointing, but if you choose carefully you will likely find a competent, enthusiastic, and great value person or company to do the job. Making your own sound FX Sound effects can be downloaded for free from sites like www.freesound.org but often the license won't allow you to use them if you are selling your game. Another option is to use an open source software called BFXR from www.bfxr.net, which can help you generate lots of different sound effects that are yours to keep and do as you like with.
  • 45. Adding assets to the project Once you have decided which assets you will use, it is time to add them to the project. These next instructions will assume you are using all the assets supplied in the book's download bundle. Where you are using your own, simply replace the appropriate sound or graphic file with your own, using exactly the same file name. 1. Browse to the Visual D:Visual Studio StuffProjectsTimberTimber. 2. Create three new folders within this folder and name them as graphics, sound, and fonts. 3. From the download bundle, copy the entire contents of Chapter 1/graphics into the D:Visual Studio StuffProjectsTimberTimbergraphics folder. 4. From the download bundle, copy the entire contents of Chapter 1/sound into the D:Visual Studio StuffProjectsTimberTimbersound folder. 5. Now visit: http://www.1001freefonts.com/komika_poster.font in your web browser and download the Komika Poster font. 6. Extract the contents of the zipped download and add the KOMIKAP_.ttf file to the D:Visual Studio StuffProjectsTimberTimberfonts folder. Let's take a look at these assets, especially the graphics, so we can better visualize what is happening when we use them in our C++ code.
  • 46. Exploring assets Graphical assets form the individual parts of the screen in our Timber!!! game. Take a look at the graphical assets and it should be clear where, in our game, they will be used. The sound files are all .wav format. These are files containing the sound effects that we will play at certain events throughout the game. They were all generated using BFXR. They are: chop.wav : A sound that is a bit like an ax (a retro ax) chopping a tree death.wav: A sound a bit like a retro "losing" sound. out_of_time.wav: Plays when the player loses by running out of time, as opposed to being squashed
  • 47. Understanding screen and internal coordinates Before we move on to the actual C++ coding, let's talk a little about coordinates. All the images that we see on our monitors are made out of pixels. Pixels are little tiny dots of light that combine to make the images we see. There are many different monitor resolutions but, as an example, a fairly typical gamer's monitor might have 1920 pixels horizontally and 1080 pixels vertically. The pixels are numbered starting at the top left of the screen. As you can see from the next diagram, our 1920 x 1080 example is numbered from 0 through to 1919 on the horizontal (x) axis and 0 through 1079 on the vertical (y) axis. A specific and exact screen location can therefore be identified by x and y coordinate. We create our games by drawing game objects such as background, characters, bullets and, text, to specific locations on the screen. These locations are identified by the coordinates of the pixels. Take a look at this next hypothetical example of how we might draw at, approximately, the central coordinates of the screen. In the case of a 1920 x 1080 screen this would be at position 960, 540.
  • 48. In addition to the screen coordinates, our game objects will each have their own similar coordinate system as well. As with the screen coordinate system, their internal or local coordinates start at 0,0 in the top left-hand corner. We can see in the previous screenshot that 0,0 of the character is drawn at 960, 540 of the screen. A visual, 2D game object, such as a character or perhaps a zombie, is called a sprite. A sprite is typically made from an image file. All sprites have what is known as an origin. If we draw a sprite at a specific location on the screen, the origin will be located at this specific location. The 0,0 coordinates of the sprite are the origin. The next screenshot demonstrates this.
  • 49. This is why, in the screenshot showing the character drawn to the screen, although we drew the image at the central position (960, 540) it appears off to the right and down a bit. We just need to bear in mind how this works as we progress through the first project. Note that, in the real world, gamers have a huge variety of screen resolutions and our games will need to work with as many of them as possible. In the second project we will see how we can make our games dynamically adapt to almost any resolution. In this first project we will need to assume that the screen resolution is 1920 x 1080. Don't worry if your screen is different to
  • 50. this, as I have provided a separate set of code for each chapter, for the Timber!!! game. The code files are nearly identical, apart from adding and swapping a few lines of code near the beginning. If you have a lower- resolution screen, then simply follow the code in the book that assumes a 1920 x 1080 resolution and when it comes to trying out the game you can copy and paste the code files from the low res folder in each of Chapters 1 to 5, as appropriate. In fact, once the extra lines have been added in this first chapter, all the rest of the code will be identical regardless of your screen resolution. I have supplied the low-res code for each chapter, just as a convenience. We will discuss how the few lines of code work their magic (scale the screen) in the second project. The alternative code will work on resolutions as low as 960 x 540 so should be good on almost any PC or laptop. Now we can write our first C++ code, and very soon we will see it in action.
  • 51. Starting to code the game Open up Visual Studio if it isn't already, open up the Timber project (if it isn't already open) by left-clicking it from the Recent list on the main Visual Studio window. The first thing we will do is to rename our main code file. It is currently called HelloSFML.cpp and we will rename it to the more appropriate Timber.cpp. The .cpp stands for C plus plus. 1. Find the Solution Explorer window on the right-hand side. 2. Locate the HelloSFML.cpp file under the Source Files folder. 3. Right-click HelloSFML.cpp and choose Rename. 4. Edit the filename to Timber.cpp and press Enter. Make some minor edits in the code window so that you have exactly the same code as shown next. You can do so in exactly the same way that you would with any text editor or word processor; you could even copy and paste it if you prefer. After you have made the slight edits, we can talk about them: // Include important C++ libraries here #include "stdafx.h" int main() { return 0; } This simple C++ program is a good place to start. Let's go through it line by line
  • 52. Making code clearer with comments As you can see, the only code that needed to change was a little bit at the very top. The first line of code is this: // Include important C++ libraries here Any line of code that starts with // is a comment and is ignored by the compiler. As such, this line of code does nothing. It is used to leave any information that we might find useful when we come back to the code at a later date. The comment ends at the end of the line, so anything on the next line is not part of the comment. There is another type of comment called a multi-line or c-style comment, which can be used to leave comments that take up more than a single line. We will see some of them later in this chapter. Throughout this book I will leave hundreds of comments to help add context and further explain the code.
  • 53. #including Windows essentials Now that you know what comments are for, you can probably take a decent guess at what the next line of code does. Here it is again: #include "stdafx.h" The #include directive tells Visual Studio to include, or add the contents of another file before compiling. The effect of this is that some other code, that we have not written ourselves, will be a part of our program when we run it. The process of adding code from other files into our code is called pre- processing and, perhaps unsurprisingly, is performed by something called a pre-processor. The file extension .h stands for header file. You might be wondering what this code will do? The stdafx.h file actually contains more #include directives itself. It adds into our program, all the necessary code that is required to run our program on Windows. We will never need to see this file and definitely don't need to concern ourselves with what is in it. We just need to add the line of code at the top of every game that we make. What is more significant and relevant to us, and the reason it is worth discussing the #include directive, is that we will add many more #include directives at the top of our code files. This is to include code that we will use and take the trouble to understand. The main files that we will be including are the SFML header files, which give us access to all the cool game coding features. We will also use #include to access the C++ Standard Library header files. These header files give us access to core features of the C++ language itself. That's two lines squared away, so let's move on.
  • 54. The main function The next line we see in our code is this: int main() The code int is what is known as a type. C++ has many types and they represent different types of data. An int is an integer or whole number. Hold that thought and we will come back to it in a minute. The main() code part is the name of the section of code that follows. This section of code is marked out between the opening curly brace { and the next closing curly brace }. So, everything in between these curly braces {...} is a part of main. We call a section of code like this, a function. Every C++ program has a main function and it is the place where the execution (running) of the entire program will start. As we progress through the book, eventually our games will have many code files. However, there will only ever be one main function, and no matter what code we write, our game will always begin execution from the first line of code inside the opening curly brace of the main function. For now, don't worry about the strange brackets that follow the function name (). We will discuss them further in Chapter 4: Loops, Arrays, Switch, Enumerations, and Functions-Implementing Game Mechanics, where we will get to see functions in a whole new and more interesting light. Let's look closely at the one single line of code within our Main function.
  • 55. Another Random Scribd Document with Unrelated Content
  • 56. “All right, I'm goin'. But all right for you!” On his way up the stairs he passed Henrietta coming down, and she touched him lightly on the shoulder in sign of her good-will. She was going down to meet Carter Bruce, who had insisted that she see him that morning. She found him awaiting her on the porch, in a mood not exactly pleasant. “I've got to have something definite,” he said, when he had told her why he had come. “This can't go on a day longer.” “I'm glad,” said Henrietta. “Glad about what? Glad Gay is so thoroughly infatuated with that sneak—with Freeman?” “No, glad you know now that you do love Gay,” said Henrietta. “That was what I hoped for, Carter: that you would discover it. For you do love her. And, if you do, I need not worry. Gay will not prefer Freeman to you; not if you are bold, as a lover should be.” “She does, though,” said Carter. “I don't care what he is, he has a way with women.” “Why don't you have a way with them, then, if that is what is needed?” “Because I have n't it, that's all! I'm slow. Henrietta, she likes him best. She likes me, but I have no chance with him around. He has to go. You've got to give me facts. Where is this wife of his? How can I prove he has a wife? You owe it to me, and to Gay, and to the wife, to tell me.” “It is enough that I say so. You can tell him I told you.” Carter Bruce hesitated. “I'm sorry,” he said, “but that is n't enough. I—” Henrietta looked at him steadily for a moment and then let her eyes fall. “I know what you mean,” she said. “You mean you can't trust my words. You mean I am a liar.” “I have to be frank,” Carter said. “Gay has told me about William Vane. She does not believe there is a William Vane. When I told her
  • 57. —” “You told her I had said Freeman has a wife?” asked Henrietta. “And you promised not to tell, Carter!” “I told her.” “Well?” “She said, 'Perhaps Henrietta is romancing again.'” Across the street Gay came out upon her porch. She waved a hand, and Henrietta returned the salutation, but the next moment she guessed it had not been meant for her, for Freeman came around the house, waving to Gay as he came. Henrietta put her hand on Carter's arm. “No, I can't tell you more,” she said breathlessly. “I'm sorry—only it is true he has a wife. It is true, Carter.” Carter's eyes hardened. He walked down the steps of the porch and toward Freeman, until he faced him. “You are a sneak and a cur and a cad,” he said, “and I am going to give you this every time I see you.” He shot out his fist and it struck Freeman on his cheek, throwing him to the ground. An instant he lay there and then he was on his feet and, mad with rage, had leaped for Carter. Henrietta screamed. From across the street Gay came, her palms pressed to her cheeks. The fight was all over before she reached the two men. Bruce stood arranging his tie, but Freeman lay where the last blow had sent him, prone on the grass. Carter laughed, pantingly. “Every time I meet you, remember,” he said, and turned to Gay. “I thrashed him,” he said, but Gay dropped to her knees beside the prostrate man. “Freeman! Freeman!” she cried; and then to Carter, “You brute! You cruel brute!” “Oh, just as you wish!” said Carter Bruce, and laughed again, and went across the yard to the steps and out of the gate.
  • 58. “Get up!” Henrietta said, coldly, to Freeman. “Oh! how can you be so cruel!” Gay cried, but Henrietta did not change her tone. “Get up!” she repeated. “Get up and go into the house.” “How can you speak to him like that!” cried Gay, and she helped Freeman to arise. He was rather badly battered, and tried to hide the side of his face where the worst blows had fallen. He laughed thinly. “He's bigger than I am,” he said. “He hit me before I expected it.” “He's a brute!” said Gay again. “Go in the house!” Henrietta ordered; and without more ado Freeman picked up his hat and went into the house. Henrietta followed him. For a minute more Gay stood where she was, and then she went homeward. “The brute! The big bully! I'll never speak to Carter Bruce again as long as I live. Never!”
  • 59. N CHAPTER XX ow, don't you go an' let on to your Aunt Sue, Lem,” Harvey told the boy that night when Lem came begging to be taken back. “You just keep your mouth shut, an' in a week or so you come to Burlin'ton an' hunt me up. You won't have no trouble findin' where the post-office in Burlin'ton is, an' when you git there you go to the window, an' ask if there's a letter for Lemuel Redding. It'll tell you where to find me, an' then you come to where it says.” “I'd ruther go with you,” Lem said wistfully. “I ain't ever been on a train. I don't know how to do on a train.” “You don't need to do nohow. You buy a ticket an' you git on the train an' sit down in a seat. That's all you do. When the conductor comes around, you hand him your ticket an' let him punch a hole in it, an' when you git to Burlin'ton you ask where the post-office is. That's all there is to it.” “Why can't I go with you, pop? I'm sort o' scared of it.” “I can't take no chances, Lem. If we was to go together, man an' boy, your aunt would sure think I took you an' she would n't rest until she fetched us back. She's got to think you've runned away. On your own hook. I got to keep clear of you awhile. If she got a notion I'd stole you out o' pawn she'd raise the dod-basted dickens against me. She'd make me hand over every red cent I've got, an' I need it to start the new business I aim to go into once I get away from here.” He took a fat roll of bills from his pocket. “I'm goin' to give you twenty-five dollars, Lem,” he said solemnly. “That's more'n enough to see you through easy. Don't you lose it. An' don't you ever let on I give it to you.” “I won't,” Lem promised.
  • 60. Harvey had planned carefully. He meant to depart the next night, and the next day he trudged up the hill and paid Miss Sue twenty- five dollars on account of his debt. That might quiet her for a while in case she learned of his departure too soon. Miss Sue took the money, and the severe expression she had worn when Harvey appeared softened. “Well, I will say, Harvey, you've done better at keeping your word than I ever thought you would. Bein' a saint has n't hurt you any—I 'll say that. I'll mark this down on the back of your note, and keep good track of it, and I only hope you keep on the same way.” “So do I,” said Harvey. “How's Lem carryin' on?” “He's a trial,” Miss Susan said, “but I'll bear him.” “You don't want I should take him away?” “Harvey Redding, that boy stays until you get me paid the last cent you owe me. A bargain is a bargain.” Harvey sighed. “Well—” he said, and went away. That night he departed from Riverbank and Miss Sue put the saint's five crisp bills in her purse. A week later, Miss Susan, going to her room to retire after a hard day, picked up her purse. It was lying on her bureau. Lorna had just paid a week's board and Miss Sue took the money from her pocket and opened the purse. Her eyes saw at once that the purse was empty, the five crisp five-dollar bills Lem's father had given her were gone. For a moment or two she stood, her hand laid along her cheek, thinking. No, she had not taken the money from the purse. She could remember putting it there, but not taking it out again. She opened her door and walked toward Lem's room. At Lem's door she paused, for she heard the boy moving about. She opened the door suddenly. Lem stood, as he had stood on that other night, fully dressed and his ragged straw hat on his head. In his hand was a handkerchief,
  • 61. tied together by the four corners and bulging with the food he had purloined to sustain him on his journey. As the door opened he leaped for the window, but Miss Susan overtook him and dragged him back into the room. He kicked and struck at her, but she held fast. Lorna and Henrietta came to the door, and a minute later Johnnie Alberson also came, all fully clad, for these pleasant nights all sat late. Freeman did not appear; he was with Gay, across the street, on her porch. “You hold the little rat!” Susan cried, and Johnnie grasped the boy from behind. Miss Susan's hands felt the boy's pockets. Unlike that other time Lem did not struggle now. “You leave me alone!” he kept repeating. “You better leave me alone!” Not until Miss Susan took the five crisp bills from his pocket did he begin to cry. “Don't you take that; that's my money, you old thief, you!” he sobbed helplessly. “You stole my dollar, and you want to steal everything, you old thief!” “Quiet, Lem!” Henrietta said, but this time the boy paid no heed. If she meant to suggest that he “go stiff” again, the hint was lost. All the fight, all hope, all belief that anything would ever be right again in his unhappy life seemed to have deserted the boy. It was Johnnie Alberson who tried to comfort him. “Oh, here! Come now!” he said, still holding fast to Lem, however. “Don't cry. That's not how big boys do. What's the trouble all about, anyway?” “He stole from me,” said Miss Susan, holding up the money. “I didn't! She's an old liar!” sobbed Lem, “and I don't care if I do say it! She wants to steal all my money all the time—” “Look at him,” said Miss Susan. “All packed up and ready to run away! And my money in his pocket! This time there'll be no nonsense, I tell you. He'll go packing off to reform school, where he belongs.”
  • 62. “That's all right,” said Johnnie soothingly. “We'll see about that in the morning. The reform schools won't all close to-night. I'll go bail for Lem to-night; I 'll take him into my room. If he gets away, Miss Susan, you can send me to reform school in his place.” There seemed nothing better to do and Johnnie led the boy away. “Good-night, Miss Bates,” Johnnie called to Henrietta, for the affair had interrupted their tête-à-tête on the porch. “I've got to keep this young man company.” Henrietta went down. She sat in her dark corner of the porch, staring across the street at the porch where Gay and Freeman, she knew, were sitting, and waited for Freeman. Henrietta and Freeman had had one heated interview that night. About ten o'clock, when Henrietta was still in her room, Freeman had thrown his cigarette end from the porch and had entered the house. Miss Susan was at work in the kitchen, where he heard her, and he went up the stairs softly. While smoking his cigarette on the porch, he had come to a decision. It was clear to him that he could not long remain in Riverbank with Carter Bruce on his trail and ready to beat him up whenever they met. Just what Carter Bruce knew he could not guess with any certainty, but he had enough respect for the young lawyer's fists and enough dread of his own past to believe that if Bruce kept on, his whole situation at Riverbank would be as unpleasant as possible, and, being so hard put to it to raise any money whatever, he saw no satisfactory reason why he should remain in the town. He went up the stairs with a coldly formed and complete intention to see whether Miss Susan had left any money in her room. If she had left any there, he meant to take it and get away from Riverbank as quickly and as thoroughly as possible, and he meant to take Gay with him if she would go. Freeman Todder was in Miss Susan's room and had already taken the money from her purse when Henrietta opened the door. Freeman turned to look at her. “What are you doing here, Freeman?” Henrietta asked.
  • 63. Her husband waved his hand carelessly. “Tapping the till, dearest,” he said. “Breaking the bank. Getting the cash.”
  • 64. Henrietta advanced into the room. She spoke calmly enough.
  • 65. “Now, this I will not have!” she said. “You may be a thief and a rascal, but you must not play your tricks in this house. If you have taken anything, put it back. Freeman, did you take any money?” “This,” he said defiantly, and he held up the fold of crisp bills, slipping it into his pocket again, but as he moved he looked past Henrietta and saw Lem, surprised and wide-eyed, standing in the doorway. Lem had come to the room to get his “other” shirt, preparatory to his departure. “I found it,” said Freeman slowly. “Finders is keepers, you know, dear.” He let his eyes glare into Lem's. “And you know what I am when I am angry, Henrietta. Any one who tells on me I'll kill. I'm desperate, you see. I'll murder any one who tells on me.” Lem slid back into the darkness of the hall and fled to his room. Nothing in this house brought him anything but trouble, and he only wanted to get away as soon as he could. “That is nonsense,” Henrietta told Freeman. “You will never kill any one. You are too great a coward. Now, put that money back and get out of here before some one comes.” For answer Freeman pushed past her. “I 'll put nothing back,” he said. “I need this. You don't get any for me; I've got to get for myself.” “Freeman!” He had gone into the hall. She followed him, and he could not throw her hand from his arm without causing a struggle and a noise that he did not at all desire. His wife drew him into her room. “All right, go on with the lecture,” he said, with a laugh, “but make it short. It won't do any good. I'm going to keep this money, and I 'm going to get away from here to-night. I 'm going so far you'll never see me again.” Henrietta sat on the bedside and, with her eyes on his face, let her mind touch upon the possibilities. If Freeman went, and went forever, her lot in life would be far simpler, far easier! But, if he fled, and the money was gone, Miss Susan would know he had taken it,
  • 66. and she already knew he was Henrietta's husband. That would besmirch Henrietta even worse than she was now. It would be the last straw. And even if Freeman went, it would not mean perfect freedom for her, for he would always remain a menace, always liable to appear again to work his husbandly blackmail and make trouble for her. She felt unutterably depressed. “You must put the money back now—at once,” she said wearily, “before any one knows it is gone.” “Too late now, Et,” he said. “Somebody knows. The only thing for your little Freeman-boy to do is to skip out while the skipping is good. That Lem saw me.” “Lem?” “Yes. He was at the door while your back was turned. He saw, and heard, too. So there you are! Nothing left but to clear out.” Henrietta pleaded with him. “But not this way, Freeman! Wait. Take the money back and to- morrow I'll borrow some. I 'll coax it out of Lorna, or Gay. Or even Johnnie Alberson; I believe I could get some out of him. Please, Freeman!” “Et, you make me tired,” Freeman said. “I've got the cash and I'm going to skip out before this night is over. That's flat, and if you don't like it, you can lump it, and if you don't like it lumped, you can roll it out and fry it. I'm sick of this and I'm going to vamoose. I'm going over to say good-bye to Gay and then I'm going.” “Freeman!” she cried, “I knew you were a despicable creature, but I never, never, never thought you were quite as low as this!” “Oh, cut the melodrama, Et!” he said, and while she sat looking at him helplessly he went out of the room. It was after this scene that she had to sit listening to Johnnie Alberson, making conversation with him while her thoughts were on Freeman. From where she sat she could see Gay's white dress as a spot against the dark brick of the house across the way, and that spot
  • 67. she watched, all her plans in chaos, knowing only that if the spot disappeared she must rush across and keep Gay safe, no matter what else happened. When she returned from Lem's room, she looked across with fear, and breathed her thanks, for Gay was still there. Almost immediately Freeman came across the street. He was not in a pleasant mood. “Freeman,” Henrietta said. “My God! Again? What is it now?” he asked. “What is it now? Throwing the blame for your thievery on that poor boy! Hasn't he enough to bear without that? You are low—that is the only name for it—low!” “Fine! Fine and oratorical and everything, Et!” Freeman said carelessly. “Only—I did not throw any blame on him. Not that I care, you know,” he added. “Freeman, don't lie to me. You put that money in his pocket.” “Oh, no, I did n't!” Freeman laughed, and he held up Miss Susan's bank-notes. “I need this money. And I have this money, and I am going to keep this money.” “I don't understand,” said Henrietta. “How did you get it again? Did you take it from her a second time?” “Oh, quit it!” Freeman said disgustedly. “Don't be stupid. This is not the money Lem had. I've had this all the while. I don't know where the little devil got his. What does it matter? Maybe she had two wads. What do I care?” “I care,” Henrietta said. “I'm going to clear out,” Freeman said. “Last you'll ever see of me.” He turned toward the door leading into the house. “Freeman, what about Gay?” “None of your dear business, Et,” he said. Henrietta heard him tiptoe softly up the stairs. She sat a minute longer, thinking, and then went into the house herself, and up the stairs.
  • 68. There are times when heroic actions seem the only solution of great difficulties, but, however much a heroic act might add to the glory of this narrative, it was not Henrietta's fortune to rise to great heights now. She paused at Freeman's door and listened, then opened his door. Freeman sat on a chair at the end of his bed, in shirt and underwear, changing his socks. On a chair close to Henrietta's hand lay his two pairs of trousers—the one pair crumpled on the seat of the chair; the other, newly pressed, laid carefully across the chair back. With a sweep of her arm Henrietta gathered up both pairs of trousers, backed from the room, and closed the door. For a few moments, perhaps, Freeman did not realize the full extent of the catastrophe, but in another moment he did. What locked doors, tears, and pleadings cannot do, the loss of a man's trousers can do. In the dark hall, before Freeman could reach his door, Henrietta disposed of her gleanings. “Et!” Freeman whispered: “Et! Bring those back!” “Bring what?” she answered. “My pants. Bring them back, and mighty quick.” “I don't know what you are talking about,” she said. “You must be drunk. I know nothing about your pants. Go to bed.” From down the hall she heard the loud breathing of Johnnie Alberson—call it a light snore if you choose. Henrietta hesitated. Ill- fitting as Johnnie's short, wide trousers might be on slender-waisted Freeman, she knew a man will wear any garments in a crisis, and that Freeman would not be beneath stealing what he needed from the sleeper. Too, through her mind flashed the thought, “If John is awake, Freeman will not dare to make a loud fuss,” and she walked to Johnnie's door and rapped sharply upon it. “We—well? Well?” came Johnnie's voice, slumber heavy. “What? What is it?” “It's Henrietta,” she answered. “I want Lem. I want Lem to come to me.”
  • 69. She heard Lem whine, “You leave me alone, you!” and then the reassuring voice of Johnnie, and the door opened a wide crack, and Lem, rubbing his eyes, stepped out. Freeman's door closed. “Come with me, Lem,” she said, and led the half-awakened boy to her room. He staggered to her bed and threw himself upon it, asleep the moment he touched it. “Lem!” she called sharply, standing over him. The boy opened his eyes slowly, looking up into her face. “Hello!” he said. “I—I been asleep, I guess—” “Yes. That does n't matter. You will be all right presently. I want you to tell me the truth—the honest-to-God, cross-your-heart truth, Lem—about that money. Where did you get it, Lem?” “I ain't goin' to tell you,” the boy said. Henrietta took his hand. She spoke kindly. “Yes; you must tell me, Lem,” she urged. “Did you steal it?” “No, I did n't steal it.” “That's honest-to-God, cross-your-heart, Lem?” “Yes. I did n't steal it an' anybody that says I did is an old liar, that's what she is, an' I don't care who knows it. She's a mean, old liar—” “Wait, Lem. Maybe nobody is a liar. Can I believe that you did n't steal it? Can I bet my bottom dollar on that, Lem?” “Yes; you bet you can bet your bottom dollar on it. You can bet your boots on it. I don't steal—only old junk. I don't steal money—” “No, I know you don't, Lem. But Miss Susan found the money in your pocket, did n't she?” “I don't care where she found it. I don't care what that old devil finds. I 'll get even with her!” “Did she find it in your pocket, Lem?” “Yes. Only that old Alberson had to hold me. I bet if he had n't held me—” “Of course. And who put the money in your pocket, Lem?”
  • 70. “None of your—I mean, I won't say.” “Did you?” Henrietta urged. “Did you put it in?” “I won't say.” “But, listen to me, Lem. Somebody stole some of Miss Susan's money—” “I know. He did it,” Lem said. “Freeman Todder did it.” “But never mind that now. Miss Susan does n't know that. Did Freeman, here, put the money in your pocket?” “I won't say. I tell you I won't say. Nobody can get me to say.” “Lem,” said Henrietta seriously, “you don't understand what all this means. I'm trying to help you. If Miss Susan keeps on thinking you stole her money she will send you away. She'll send you to jail and to reform school and you'll be sad and unhappy all your life. I want you to be happy—” “I 'll bust out of jail if she sends me, drat her old hide!” Lem declared. “No; you can't. You'll be watched every minute. Boys never do break out of jail, Lem. They just stay there and are so miserable. So what I want to do is to help you now. So you need n't be sent away at all.” “If she won't send me I'm goin'away, anyway,” Lem declared. “I won't stay in any old house with such an old hyena pickin' on me all the time.” “Miss Susan doesn't understand you, Lem, and you don't understand her. But that does n't matter now. If you go away you must not go with the name of a thief fastened on you—” The door opened and Freeman Todder came into the room. “Look here,” he said angrily, “I want my pants. I won't stand any nonsense. You give them to me.” “You're insane!” said Henrietta. “I know nothing about them.” “Oh! that's it, is it?” he said. “All right!” He began searching the room.
  • 71. “Well, I ain't a thief, an' I don't care who says I am,” Lem was saying. “I did n't take her old money. She took mine, an' she's an old thief, an' I'll tell her so to her face. An' I'll make her give it back to me. I 'll set the police on her.” “Listen, Lem, won't you please try to help me? Won't you tell me where you got that money?” “No, I won't!” the boy declared stubbornly. “But I 'll tell her who stole her money. I 'll tell her he stole it, an' when she searches him she'll find it.” “I 'll be hanged if she will, unless she finds my pants,” Freeman growled. “If you won't help me, I can't help you, Lem,” said Henrietta. “Just to tell on Mr. Todder will not help at all. Won't you just whisper to me where you got the money?” “No, I won't! I'd rather be killed first!” Freeman was throwing articles of clothing from Henrietta's closet upon the bedroom floor. She hardly glanced at him. “Of course! I know where you got the money, Lem,” she said. “Your father gave it to you. Is n't that so?” She saw the startled look in the boy's eyes. “I won't say, I tell you!” he declared. “Then your father did give it to you?” “I won't tell you!” “And I can tell Miss Susan your father gave it to you?” “No. He said—no; I won't tell you who gave it to me! I won't tell you what he said!” “What did your father say?” “I won't tell you what he said! None of your old business what he said!” “I see!” said Henrietta. “Your father is going away and he gave you the money to follow him. Is that it?” “I won't tell you!”
  • 72. “You need n't tell me, Lem,” Henrietta said. “No more, at any rate. You have told me all about it.” She turned to Freeman. “What you are hunting is not here,” she said, “and you are only making yourself ridiculous. Go back to your room. When I am ready I will give you what you are hunting, but first, Freeman, you will have to tell Miss Susan who took her money.” Freeman looked at his wife with hatred in his eyes. He opened his mouth to speak, but thought better of it and went out and into his own room. The moment her door was dosed, Henrietta took Miss Susan's money from her waist and hid it carefully, where she felt sure it would be safe. Poor Lem was already sound asleep and Henrietta removed her shoes and a few of her outer garments, wrapped herself in her bathrobe, and in a minute she too was asleep.
  • 73. H CHAPTER XXI enrietta's first act on awakening was to look for Lem and, as she might have expected, the boy was gone. Her next was to look at her watch. She felt she must have slept until midday, so different was her physical and mental condition than when she had thrown herself on the bed. For some quite unaccountable reason she felt tremendously strong and buoyant. For a few moments she could not grasp why she felt so, and then she suddenly realized that her cheer of mind was due to the fact that Freeman, for the only time in years, was not a threatening menace, but absolutely under her control. Until she chose to permit him to be clad, he was her prisoner, and as her prisoner, subject to her orders. When she had drawn on her kimona and tiptoed out of her room on her way to the bath, she glanced at Freeman's closed door and smiled. No need to worry about Freeman for an hour or two. Half an hour later, fully garbed, she stepped from her room again, and this time she tapped on Freeman's door, gently at first and then more vigorously. There was no response. Henrietta opened the door and looked into the room. It was empty; Freeman was gone. In the hall, in the corner nearest Henrietta's door, stood a wood box, receptacle for the wood used in the winter stoves, and above this the plaster and lath had been broken. It was in the hole in the wall thus made that Henrietta had thrust Freeman's trousers, crowding them down out of sight. They were still there, and as if in answer to another query that came into Henrietta's mind at the moment, she heard Gay's voice, brisk and happy, speaking to Lorna below. If Freeman had fled, he had not persuaded Gay to fly with him. Probably he had fled with such covering as he could improvise, hoping to arouse one of his boon companions and beg what was necessary, Henrietta thought.
  • 74. When she reached the hall below she found Gay, Lorna, and Johnnie Alberson there, laughing over some item in the morning Eagle. “Lem has gone,” she said. “Good for Lem,” said Johnnie, and he handed her the paper, pointing to a headline. “Riverbank Loses Only Saint,” the headline said. “Little Brother of Stray Dogs Departs for Parts Unknown. Holy Life Too Strenuous For Saint Harvey of Riverbank.” Lorna and Johnnie, it seemed, had already breakfasted. Henrietta, leaving the three to laugh over the article in the paper, went to the dining-room and through it into the kitchen, where Miss Susan was thumping at a piece of wet wood in her stove, using the lid-lifter. “Lem has run away,” Henrietta said without preliminaries. “And good riddance. Hope I never set eyes on him again, the mean thief! Him and his pa, indeed! Robbin' and cheatin'!” “No, Lem's not a thief. Here is the money you missed.” Miss Susan looked at the bills. “What's that money? I got mine off of him. He did n't go and steal it over again? You don't mean to tell me that young—” “No. It wasn't your money you found on him. That was money his father gave him—to run away with, I suppose. He did not take your money at all. Miss Susan, Freeman has gone.” Miss Susan put down the lid-lifter and turned to Henrietta. “Gone? Run off, you mean? Well, a nice kettle of fish him and you are, I must say, you and your fine husband, lyin' and fightin' with Carter Bruce all over my front yard, and makin' love to Gay and Johnnie! I never heard of such go-ings-on in all my born days. What'd that worthless husband of yours run of! for?” She looked at Henrietta keenly. “It was him stole my money, was n't it?” she said. “Yes.”
  • 75. “Then he's good riddance, and that's all I've got to say about that,” said Susan. “And the farther that worthless Lem goes and the longer he stays, the better I 'll like it. When you going?” “Now. Any time. Whenever you wish,” said Henrietta. “You can't go too soon to suit me,” said Miss Susan. “I've had enough and a plenty of the whole lot of you. If you want to get yourself some breakfast you can, and if you don't want to, you need n't, but I hope I won't see you around too long. I've got to get your room ready for the next boarder that comes, and I'd like to have it empty by noon.” Henrietta hesitated, but only for a moment. “Of course I'll go if you want me to go, Miss Susan,” she said cheerfully. “You've been very kind and patient with me. I just want to thank you for that. I 'll never forget that. I will have breakfast before I go. I'm ravenous this morning.” She found the coffee-pot on the back of the stove, and Miss Susan grudgingly opened the oven door and let Henrietta see where her breakfast had been kept warm. Henrietta carried it to the dining- room. She was eating when Johnnie Alberson came in and took a seat opposite her. “I'm going away,” she said. “You! Going away! Where? What for?” he asked. “Miss Susan needs my room; she expects another boarder.” “But, hold on! You don't mean it, do you? Where are you going?” “I don't know—yet. Away from Riverbank, I suppose. I have n't had time to think yet. She just told me.” “But, look here!” he said. “You mean she is sending you away?” “It seems to be that.” “It does, does it?” said Alberson, and he was out of his chair and on his way to the kitchen, and did not wait, although she called, “Johnnie, wait!” after him. Henrietta ate her breakfast slowly. She could hear Johnnie's briskly cheerful tone and Miss Susan's voice—at first hard and obstinate,
  • 76. and then yielding. Johnnie came back into the din-ing-room and sat opposite Henrietta again. “That's all right now,” he said. “You don't have to go unless you want to. She's willing to have you stay.” “She is? Miss Susan is? Whatever did you say to her?” Johnnie leaned forward and smiled at Henrietta. “I'm an Alberson, you know; one of the River-bank Albersons,” he said. “We are used to having our way.” “But that's no reason—that's—she would not let that change her mind. You said something else.” “Why, yes; I did,” said Johnnie. “I told her you were going to marry an Alberson. I told her you were going to marry me.” Henrietta put down her fork and looked at him squarely. “But I told you I had a husband. You know I have a husband in Colorado. I told you so.” “Of course. I remember that. I honor you for that, Henrietta. But of course it was all a lie. You have no husband in Colorado. Have you?” Henrietta tried to look into his eyes and say she had, but his eyes would not look into hers seriously. They twinkled mischievously and looked through her eyes into her heart. She drew a deep breath, like one drowning, and looked down. “No,” she said. “I have no husband—in Colorado.”
  • 77. M CHAPTER XXII oses Shuder, having paid Saint Harvey of Riverbank his good money, went back to his own junkyard feeling high elation. The great ambition that had urged him ever since he had begun, a raw immigrant, was consummated. He was the mightiest Junk King of Riverbank. He need fear no paltry competition. He could put prices down and he could buy or refuse to buy, and he could put prices up, and no one would interfere. He saw himself the future great man of his people, bringing his downtrodden compatriots from Russia, sending them out upon the roads of free America to glean the waste metals and rags, setting them up in small trades, financing them, being a father to them. He had eliminated Harvey Redding. But as he considered the transaction he began to worry. It is the duty of every man, in making a bargain, to make a good bargain—in fact, the best possible bargain—and Shuder began to fear he had not done that. Saint Harvey had accepted his offer almost too promptly. His knowledge of values quieted this fear somewhat. The junk he had bought was worth more than he had paid for it, he knew, and the yard was worth more than one hundred dollars per year. Suddenly the awful thought came to him that, although he had paid Saint Harvey cash money, he had nothing to show for it. He had no “paper,” no receipt, no lease, nothing! Not even a witness! The cold perspiration oozed from his every pore. He had been cheated! Moses Shuder, lying beside his soundly sleeping—and snoring— wife, squirmed with shame at the thought that he had been such a fool. He pulled at his beard angrily. So be it! He would find this Harvey Redding and make him give a paper. In the morning— He suddenly sat bolt upright.
  • 78. “Rosa, hush!” he whispered, putting his palm under her chin and closing her mouth. “What is it, Moses? Fire? Thieves?” “Hush! Thieves,” he whispered. He slid out of bed and drew on his trousers. From the lean-to where he kept his most precious junk—his copper and his lead—came the subdued clink of metal. Stealthily Shuder glided to his back door. He glided to the door of the lean-to. “Thief! I got you!” he cried, and pounced upon Lem. “You leave me alone! You let go of me!” the boy cried. But Shuder had him fast, and scolding in Yiddish he dragged the boy from the lean-to and into the shack. Rosa lit the oil lamp. “Sure!” panted Shuder. “Young Redink! Stealing chunk! Sure!” Lem was in a panic. Fear, such as he had never experienced, cowed him. To the mind of youth the strange foreigner seems a thing to be jeered and hooted in the open day, but in the homes and churches and synagogues of the foreigners are believed to lurk strange mysteries; deep, unfathomable, blood-curdling, weird ways and doings, especially dire when wrought upon boys. Lem, in Shuder's grasp, did not see the poor shack with its grotesque furnishings rescued from purchases of offcast second-hand things. He did not see the tawdry intimate surroundings of a poor Jew struggling to wrest comfort and life from a none too friendly environment. Lem saw a perilous twilight in which might be worked strange tortures, awful incantations, black wizardry. Lem was scared stiff. “Stealink!” said Shuder bitterly. The poor man was, indeed, almost in tears. His natural anger was all but lost in a feeling of hopelessness that he would ever be able to protect his property in this land of scorn. “You should gif him by a policemans right avay,” said Rosa. “He should go to chail. Stealink at night!”
  • 79. “Vait!” said Shuder, upraising his free hand. “Boy, vere is your fadder?” “I don't know,” Lem whimpered. “How do I know where he is? He don't have to tell me, does he? You let me go, I tell you!” “Should you tell me vere is your fadder, I let you go,” said Shuder. “Stop viggling. I don't hurt you. Why you steal my chunk?” “I did n't steal it. I just took some.” “Why?” Shuder insisted. Lem looked up at the Jew. “I won't tell,” he said. “Then to chail!” said Shuder. “Well—I wanted it,” said Lem reluctantly, and suddenly he broke down and began to ay. “I wanted to go to pop. I wanted to go to him. He said I could go where he is.” “Rosa, hush!” said Shuder when his wife tried to speak again, and he began patiently, and with the little English he could command, to comfort Lem and let him know nothing dire was to happen to him. Slowly, Lem's fear of some mysterious fate was lessened, and again and again he heard that Shuder, too, wished to find Saint Harvey. Not to harm him, Shuder assured Lem; only to get a “paper” that Saint Harvey had forgotten to leave. The importance of this paper to Shuder loomed vast as the Jew spoke of it again and again. In spite of his fear and hatred, Lem felt that the “paper” was something Shuder should not be robbed of—that it was some sort of Magna Charta of his life which Harvey had carried away by mistake. “You won't get a policeman after me?” Lem begged. “Sure, no! I gif you right by it. Sure, no!” “Well, I ain't goin' to tell you. Pop he told me not to tell. But I can't help it if you go where I go, can I?” “Nobody could,” said Shuder. “How could you?” “Well, then, you let me go an' I'll go. I'll go right where he told me to, because that's what he said for me to do. And I can't help it if
  • 80. you follow me. Only you better get ready to walk a long ways, because it's sixty miles, I guess. Anyway, I guess it is.” Shuder stroked his beard. “Could a man go by the railroad?” “Sure he could, if he had the money. Was n't that what I wanted some junk for—to sell it, so I could go on the train? But I have n't got any money. So I got to walk.” “Mebby I should pay,” said Shuder. Lem considered this. “I guess that's all right,” he said, “if you want to. We'd get there sooner, anyway.” Lem would not, however, tell where they were to go even then, and the next morning Shuder had to press close behind the boy at the ticket window to overhear him ask for a ticket to Burlington. He sat beside the boy all the way, too, never moving far from him even when they changed cars at the junction. At noon he fed Lem from the lunch Rosa had provided, and he bought Lem two apples from the train-boy. Shuder was close behind the boy when Lem asked at the post-office window for a letter for Lemuel Redding. Although he could not read, he peered over Lem's shoulder as Lem read the letter the clerk handed out. “Pa ain't here no more,” said Lem, looking up at Shuder. “He's gone somewheres.” Shuder grasped the letter from Lem's hand and stared at it, turning it over and over. “Please, misder,” he begged of a man who passed, “you should read this to me.” The man took the letter. “Dear Lem,” he read. “I'm going on from here because the Jews have the junk business all tied up here from what I can see, and it's no place for me. No telling where I 'll land up at. You better go back to your Aunt Susan and wait until I send for you. Maybe it won't be as long as it looks like now.”
  • 81. “And the name? The name?” cried Shuder. “Redding; it looks like Henry Redding, or something like that.” “Well, I won't go back,” said Lem. “I don't care what he says. I won't go back to that old aunt. I don't care if I starve to death, I won't go back to her.” Shuder had heard about Miss Susan on the way down from Riverbank, for Lem had been full of a sense of injustice and had had to talk to some one about it or burst. Lem and his troubles were none of Shuder's affair, but, on the other hand, Saint Harvey and the “paper” were, and Lem was Shuder's only link with Saint Harvey now. “Do I ask you to go back by her, Lem'vel?” Shuder demanded. “No! But why should you vorry? Ain't I got two houses? Ain't I got two chunkyards? Ain't I got plenty room? I esk you, come by me awhile, Lem'vel.” “Say, what you mean?” Lem asked. “You want me to go an' live at your house?” “Sure!” said Shuder. Lem looked at the Jew. “All right,” he said. “Until I get a word from pop. I bet you don't have so many dishes to wash, anyway.” Shuder raised a hand. “Listen! Listen, Lem'vel!” he said solemnly. “I gif you my word you should n't wash even your face if you don't want to.” “All right, I'll come,” said Lem.
  • 83. T CHAPTER XXIII o his very considerable surprise, Lem did not find residing with the Shuders a painful experience. Rosa, for all her strange ways of doing things and her incomprehensible objection to chickens killed in any but a certain way, was a better cook than Saint Harvey, and knew how to prepare things that a boy's appetite found delicious. Lem had to sleep in the lean-to, on an old iron cot set among the piles of junk, but it was summer and hot and he enjoyed that. Shuder made him work, but it was work that Lem liked; the kind he had always done for his father, and he had only about half as much of it to do as his father had made him do. He enjoyed helping with the horse, harnessing and unharnessing it. There was only one thing Lem refused to do—he would not go out of the junkyard. For a week he kept under close cover. Then, one night, he stole away, and, keeping in the alley shadows, made his way to Miss Susan's back gate. He did not risk the rusty hinges creaking, but climbed the fence, and dodged to the shadow of the house. Miss Susan was in the kitchen. Lem went around the house. On the porch Lorna sat, on one of the steps as usual, and Henrietta and Johnnie Alberson had chairs. It was Henrietta Lem wanted. He seated himself under the drooping spirea bushes that edged the porch, and waited. Presently Lorna went up. Lem heard a chair move on the porch and hoped Johnnie Alberson was going, but he was to have no such luck. He heard Johnnie speak. “Henrietta,” he said, “when are we going to be married?” “Never,” Henrietta answered, but not as if the question had offended her.
  • 84. “But I'm not going to take that for an answer,” he said. “I can't. It would make a liar of me. I told Miss Susan I was going to marry you, and she rather depends on it, poor soul.” “I told you, Johnnie, I have a husband. It is ridiculous, sinful, for you to talk to me of marrying.” “I see! Which husband do you mean, Etta? The Colorado one who was and then was n't?” “Oh! please don't!” Henrietta begged. “I can't tell you. Not now. Not yet. Perhaps never. I—” “If you don't mean the Colorado myth,” said Johnnie, quite unabashed, “you must mean Freeman. Do you?” There was a momentary silence. “Yes, I do mean Freeman,” Henrietta said then. “How did you know he was my husband?” “Well, you see,” said Johnnie slowly but wickedly, “he sold you to me. The night of the row about Lem stealing Miss Susan's money, Freeman came to my room after you had taken Lem, and we had a frank talk—quite a frank talk. So I bought you.” “John!” “Yes; I did. You cost me three hundred dollars, too—a lot of money to pay for a wife these days. You cost me two hundred—the money he stole from me—and another hundred in cold cash that I gave him to get away on. And my very best pants. That's three hundred dollars plus. So that settles that.” “He is still my husband.” “But not for long. He threw in a promise to that effect. I made him. He's getting a divorce now.” “But he can't. I've always been more than faithful.” “Yes, he can. You stole his trousers. That's grounds for the strongest kind of divorce. That's cruelty de luxe. So that's settled. When are you going to marry me?” Henrietta, in spite of herself, laughed, but was serious again instantly.
  • 85. “Never, John,” she said. “I'm not going to do any more marrying. I'm going to do penance for the marrying I have done in the past. If what you say is true and Freeman frees me, I—” “What?” “I want to take that poor Lem boy and make a good man of him. I want to do in Lem what I undid in Freeman. I want that to be my penance.” Johnnie laughed, and arose. “All right! We'll leave it that way to-night. Good-night, Henrietta. You've some penance ahead of you, if I know that boy! Good-night.” Henrietta sat thinking after Johnnie was gone. She had many things she wished to let drift through her mind, trying each as it came up. Johnnie Alberson first of all. If Freeman did get a divorce— “Say!” Henrietta, although seldom nervous, was startled by this voice coming from the bushes. “Who is that?” she asked, her heart standing still for a moment. Her first thought was that it was Freeman returned. “It's Lem,” the boy whispered. “Is he gone? Can I come out?” “Oh, Lem! You did frighten me! Yes, come here. Where have you been? You poor child—” “I ain't been anywhere,” Lem said. “I'm to Shuder's—to his junkyard. I'm junkin' for him an' he's keepin' me.” “Shuder is? Who is Shuder?” Lem came and stood by her side. “He's the Jew. He's the one that pop could n't abide. He's all right, though, Shuder is. Say—” “Yes?” “You know my pop—well, he went away. So I went. But he was n't there. He said he'd send word to me when he was somewhere else —he said he'd send it here to Aunt Susan's house. But he did n't, did he?” “No; I'm quite sure he has not.”
  • 86. Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com