Download Full Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit 2nd Edition James Goodwill PDF All Chapters
Download Full Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit 2nd Edition James Goodwill PDF All Chapters
com
https://textbookfull.com/product/ios-apprentice-eighth-edition-
beginning-ios-development-with-swift-and-uikit-raywenderlich-tutorial-
team/
textbookfull.com
https://textbookfull.com/product/game-programming-in-c-
creating-3d-games-creating-3d-games-sanjay-madhav/
textbookfull.com
https://textbookfull.com/product/employability-via-higher-education-
sustainability-as-scholarship-alice-diver/
textbookfull.com
Reasoning Web Semantic Interoperability on the Web 13th
International Summer School 2017 London UK July 7 11 2017
Tutorial Lectures 1st Edition Giovambattista Ianni
https://textbookfull.com/product/reasoning-web-semantic-
interoperability-on-the-web-13th-international-summer-
school-2017-london-uk-july-7-11-2017-tutorial-lectures-1st-edition-
giovambattista-ianni/
textbookfull.com
https://textbookfull.com/product/implicit-bias-and-philosophy-
volume-1-metaphysics-and-epistemology-1st-edition-brownstein/
textbookfull.com
https://textbookfull.com/product/psychology-14e-carole-wade/
textbookfull.com
https://textbookfull.com/product/sase-for-dummies-versa-networks-
special-edition-kumar-mehta/
textbookfull.com
https://textbookfull.com/product/where-the-party-rules-the-rank-and-
file-of-china-s-communist-state-daniel-koss/
textbookfull.com
Industrial chemistry of oxides for emerging applications
First Edition Blanchart
https://textbookfull.com/product/industrial-chemistry-of-oxides-for-
emerging-applications-first-edition-blanchart/
textbookfull.com
Beginning
Swift Games
Development for iOS
Develop 2D and 3D games Using Apple’s
SceneKit and SpriteKit
—
Second Edition
—
James Goodwill
Wesley Matlock
Beginning Swift Games
Development for iOS
Develop 2D and 3D games Using Apple’s
SceneKit and SpriteKit
Second Edition
James Goodwill
Wesley Matlock
Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple’s SceneKit and SpriteKit
James Goodwill Wesley Matlock
Highlands Ranch, Colorado, USA Kansas City, Missouri, USA
ISBN-13 (pbk): 978-1-4842-2309-3 ISBN-13 (electronic): 978-1-4842-2310-9
DOI 10.1007/978-1-4842-2310-9
Library of Congress Control Number: 2017942793
Copyright © 2017 by James Goodwill and Wesley Matlock
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with
reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed
on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or
parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its
current version, and permission for use must always be obtained from Springer. Permissions for use may be
obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under
the respective Copyright Law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Aaron Black
Development Editor: James Markham
Technical Reviewer: Bruce Wade
Coordinating Editor: Jessica Vakili
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special
Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this text is available to readers
at www.apress.com/978-1-4842-2309-3. For detailed information about how to locate your book’s source
code, go to www.apress.com/source-code/.
Printed on acid-free paper
To Christy Goodwill,
my awesome wife, you have supported me all of these years.
I could not have done a fraction of what I have without you. I love you.
■
■Part I: Introduction to Spritekit���������������������������������������������������������� 1
■
■Chapter 1: Setting Up Your Game Scene and Adding Your First Sprites���������������� 3
■
■Chapter 2: SpriteKit Scenes and SKNode Positioning������������������������������������������ 19
■
■Chapter 3: Adding Physics and Collision Detection to Your Game���������������������� 33
■
■Chapter 4: Adding Scene Scrolling and Game Control����������������������������������������� 45
■
■Chapter 5: Adding Actions and Animations��������������������������������������������������������� 55
■
■Chapter 6: Adding Particle Effects to Your Game with Emitter Nodes����������������� 71
■
■Chapter 7: Adding Points and Sound������������������������������������������������������������������� 87
■
■Chapter 8: Transitioning Between Scenes��������������������������������������������������������� 103
■
■Chapter 9: SpriteKit Best Practices������������������������������������������������������������������� 115
v
vi Contents at a Glance
■
■Part II: Introduction to Scenekit����������������������������������������������������� 129
■
■Chapter 10: Creating Your First SceneKit Project���������������������������������������������� 131
■
■Chapter 11: Scenes and Nodes�������������������������������������������������������������������������� 143
■
■Chapter 12: Lighting, Camera, and Material Effects in SceneKit����������������������� 157
■
■Chapter 13: Render Loop, Physics, and Moving Around������������������������������������ 167
■
■Chapter 14: Collision Detection������������������������������������������������������������������������� 175
■
■Chapter 15: SceneKit Interaction with SpriteKit����������������������������������������������� 183
■
■Chapter 16: SceneKit Editor������������������������������������������������������������������������������ 191
Index��������������������������������������������������������������������������������������������������������������������� 203
Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii
About the Technical Reviewer���������������������������������������������������������������������������������xv
Acknowledgments�������������������������������������������������������������������������������������������������xvii
Introduction������������������������������������������������������������������������������������������������������������xix
■
■Part I: Introduction to Spritekit���������������������������������������������������������� 1
■
■Chapter 1: Setting Up Your Game Scene and Adding Your First Sprites���������������� 3
What You Need to Know and Have����������������������������������������������������������������������������������� 3
Introducing SuperSpaceMan�������������������������������������������������������������������������������������������� 3
Creating a Swift SpriteKit Project������������������������������������������������������������������������������������� 4
Starting from Scratch������������������������������������������������������������������������������������������������������� 7
The GameViewController Class������������������������������������������������������������������������������������������������������������� 11
The GameScene Class�������������������������������������������������������������������������������������������������������������������������� 13
vii
viii Contents
■
■Chapter 2: SpriteKit Scenes and SKNode Positioning������������������������������������������ 19
What Is an SKScene?����������������������������������������������������������������������������������������������������� 19
The SKScene Rendering Loop���������������������������������������������������������������������������������������� 20
Building the Scene’s Node Tree�������������������������������������������������������������������������������������� 22
Rendering the Node Tree���������������������������������������������������������������������������������������������������������������������� 24
Searching the Node Tree���������������������������������������������������������������������������������������������������������������������� 26
Summary������������������������������������������������������������������������������������������������������������������������ 32
■
■Chapter 3: Adding Physics and Collision Detection to Your Game���������������������� 33
What Is an SKPhysicsBody?������������������������������������������������������������������������������������������� 33
Adding Physics to Your Game World������������������������������������������������������������������������������� 34
Applying Forces to SKPhysicsBody�������������������������������������������������������������������������������� 35
Adding Collision Detection to Your SKNode�������������������������������������������������������������������� 37
Adding a Node to Collide Into��������������������������������������������������������������������������������������������������������������� 38
Adding Collision Detection�������������������������������������������������������������������������������������������������������������������� 38
Adding Bit Masks to Your SKPhysicsBody�������������������������������������������������������������������������������������������� 39
Removing the Orb When You Receive a Contact Message������������������������������������������������������������������� 41
Summary������������������������������������������������������������������������������������������������������������������������ 44
■
■Chapter 4: Adding Scene Scrolling and Game Control����������������������������������������� 45
Reorganizing the GameScene���������������������������������������������������������������������������������������� 45
Adding More Orbs to the Scene������������������������������������������������������������������������������������� 47
Scrolling the Scene�������������������������������������������������������������������������������������������������������� 50
Controlling Player Movement with the Accelerometer��������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������ 54
Contents ix
■
■Chapter 5: Adding Actions and Animations��������������������������������������������������������� 55
Refactoring the Orb Node Layout One Last Time������������������������������������������������������������ 55
Sprite Kit Actions������������������������������������������������������������������������������������������������������������ 58
Using Actions to Move Nodes in the Scene������������������������������������������������������������������������������������������ 59
Using SKActions to Animate Sprites����������������������������������������������������������������������������������������������������� 63
■
■Part II: Introduction to Scenekit����������������������������������������������������� 129
■
■Chapter 10: Creating Your First SceneKit Project���������������������������������������������� 131
SceneKit Primer����������������������������������������������������������������������������������������������������������� 131
SceneKit Animation���������������������������������������������������������������������������������������������������������������������������� 132
What You Need to Know��������������������������������������������������������������������������������������������������������������������� 133
Summary���������������������������������������������������������������������������������������������������������������������� 142
■
■Chapter 11: Scenes and Nodes�������������������������������������������������������������������������� 143
Scene Graph����������������������������������������������������������������������������������������������������������������� 143
SceneKit’s Built-in Model Classes�������������������������������������������������������������������������������� 145
SCNGeometry Objects������������������������������������������������������������������������������������������������������������������������ 145
Materials���������������������������������������������������������������������������������������������������������������������� 161
Applying Materials to Your Obstacles��������������������������������������������������������������������������� 164
Summary���������������������������������������������������������������������������������������������������������������������� 166
■
■Chapter 13: Render Loop, Physics, and Moving Around������������������������������������ 167
What Is the Render Loop?�������������������������������������������������������������������������������������������� 167
GameView: Moving the Hero���������������������������������������������������������������������������������������� 168
Writing the Callback Delegate Function��������������������������������������������������������������������������������������������� 169
Moving the Camera���������������������������������������������������������������������������������������������������������������������������� 170
Index��������������������������������������������������������������������������������������������������������������������� 203
About the Authors
James Goodwill is a ten-time published author of books about leading technologies such
as iOS, Swift, Objective C, Grails, Groovy, Java Servlets, JavaServer Pages (JSP), Tomcat,
and Struts. He is a senior enterprise iOS and Java consultant in the Denver metro area and
frequent speaker and article writer. You can find additional resources about Sprite Kit, Swift,
and James himself at his blog at www.jgoodwill.org. You can also follow James on Twitter at
https://twitter.com/jamesgoodwill.
Wesley Matlock is a professional independent iOS consultant in the Kansas City metro
area. He has more than 20 years of development experience in several different platforms.
He first started doing mobile development on the Compaq iPaq in the early 2000s. Today he
enjoys developing on the iOS platform and bringing new ideas to life.
xiii
About the Technical
Reviewer
Bruce Wade is a software engineer from British Columbia, Canada. He started software
development when he was 16 years old by coding his first website. He went on to study
Computer Information Systems ad DeVry Institute of Technology in Calgary, then to further
enhance his skills he studied Visual & Game Programming at The Art Institute Vancouver.
Over the years he has worked for large corporations as well as several start-ups. His
software experience has led him to utilize many different technologies including C/C++,
Python, Objective-C, Swift, Postgres, and JavaScript. In 2012 he started the company
Warply Designed to focus on mobile 2D/3D and OS X development. Aside from hacking out
new ideas, he enjoys spending time hiking with his Boxer Rasco, working out, and exploring
new adventures.
xv
Acknowledgments
This book could not have been written without the incredible folks at Apress. The idea of a
Swift iOS gaming book began with a conversation with Steve Anglin and came to life with a
great discussion about gaming and Apple with Michelle Lowman. Mark Powers and James
Markham kept the book on the rails and brought it safely into the station. Bruce Wade made
sure all of the technical statements made sense and the code compiled and ran successfully.
I thank you all.
I want to send out a special thanks to Wes Matlock for taking over the Scene Kit section
of the book when my father passed. I just did not have the time or energy to complete the
second section of the book, and Wes stepped in without hesitation.
I also want to thank Deborah Saez for the wonderful artwork in the book. I highly
recommend her. She is both very talented and a very hard worker. You can find her at
www.deborahsaez.com/. Look her up.
Finally and most importantly, I want to thank the three girls in my life: Christy (my wonderful
wife) and our daughters, Abby (who supplied a ton of inspiration) and Emma (who did a great
technical review of the book). You three are the most important people in my life.
—James Goodwill
xvii
Introduction
xix
xx Introduction
In Chapter 9, you’ll learn some Sprite Kit best practices; specifically, you will see how you
can create your own subclasses of SKSpriteNode so that you can better reuse your nodes.
You will then move on to changing your game to load all the sprites into a single texture
atlas that you can reference when creating all future sprites. After that, you will move on to
externalizing some of your game data so that designers and testers can change the game
play. Finally, you will close out the chapter when you prune your node tree of all nodes that
have fallen off the bottom of the screen.
In Chapter 10, you’ll learn about what Scene Kit is and how to create a new Scene Kit game
using Xcode. You will then dive in and create the beginnings of a Scene Kit game starting
from scratch. You will learn to about SCNScene and SCNodes with a Scene Kit primer.
In Chapter 11, you’ll learn more about the scene graph and some of the basics of Scene
Kit. You will start to create your game by loading the spaceman from his Collada file. You
will also learn about the Scene Kit primitive geometries by adding these as objects for the
spaceman to avoid.
In Chapter 12, you’ll learn how Scene Kit uses lighting and the type of lighting that is
available to you in Scene Kit. You will also examine how materials are added onto the
SCNNode, as well as how the camera is used within the scene.
In Chapter 13, you’ll learn about the basics of animating the objects in your game. You will
see a couple of different ways to animate the nodes to give you more than one way to do
your animations. Once you have completed this chapter, all your objects will move within the
scene.
In Chapter 14, you’ll learn about collision detection within the scene. You will learn how to
move the spaceman around the scene. Once you have the spaceman moving, you will learn
how to detect when the spaceman runs into an obstacle.
In Chapter 15, you’ll learn how to use a Sprite Kit scene within the Scene Kit scene. The
chapter will show you how to create a screen to show you a timer that you will start when
the user starts the game. The chapter will also show you how to display a “game over”
screen and then restart the game.
In Chapter 16, you will learn the basics of the SceneKit Editor. This chapter will give you
a basic understanding of creating a scene and various nodes visually in the editor. No
coding will be done, but rather drag and dropping nodes and using the various editors to
manipulate the objects.
Part I
Introduction to Spritekit
Swift and Sprite Kit
In this part of this book, we will cover the basics of Sprite Kit including how you render
and animate sprites, add physics and collision detection, and control your game play
with the accelerometer. You will also look at how you add particle emitters to enhance
the appearance of your game. We will cover everything you need to know to create
your own Sprite Kit game.
Chapter 1
Setting Up Your Game Scene
and Adding Your First Sprites
SpriteKit is Apple’s exciting 2D game framework that was first released in September 2013 with
iOS 7. It is an animation and graphics rendering framework that gives you the power to easily
animate textured images, play video, render text, and add particle effects. It also includes an
integrated physics library. SpriteKit is the first-ever game engine formally built into the iOS SDK.
In this chapter you will learn what SpriteKit is and how to create a new SpriteKit game using
Xcode. You will then move on and create the beginnings of a SpriteKit game starting from
scratch. You’ll learn about SKNodes and their subclasses and you’ll use an SKSpriteNode to
add both a background node and a player node to your game.
Introducing SuperSpaceMan
We feel the best way to learn anything is to do it. Therefore, in this book you are going to
dive right in and create your own game. You will start off with the basic code for a 2D game,
and you will add new features to the game as we introduce new topics with each chapter.
At the end of the book, you will have a complete game.
© James Goodwill and Wesley Matlock 2017 3
J. Goodwill and W. Matlock, Beginning Swift Games Development for iOS,
DOI 10.1007/978-1-4842-2310-9_1
4 CHAPTER 1: Setting Up Your Game Scene and Adding Your First Sprites
The game you are going to create is inspired by Sega’s popular Sonic Jump Fever (https://
itunes.apple.com/us/app/sonic-jump-fever/id794528112?mt=8). It is a vertical scroller that
accelerates the main character through obstacles and collectables, increasing your score as
you collect rings.
This game is similar in that it is a vertical scroller, but your main character is going to be a
spaceman who hurtles through space collecting power orbs while trying to avoid black holes
that will destroy him.
Note You will notice you are creating an iPhone-only game. That’s only because the game you are
creating lends itself better to the iPhone. Everything we cover in this book translates to the iPad just
as well.
6 CHAPTER 1: Setting Up Your Game Scene and Adding Your First Sprites
You now have a working SpriteKit project. Go ahead and click the Play button to see what
you have created. If everything went OK, you will see your new app running in the simulator.
Note The Xcode simulator may take a while to start on some slower machines. Simulating
SpriteKit apps can be very taxing on your processors.
It doesn’t do a whole lot yet, but there is more to it than displaying “Hello, World!” Tap
the simulator screen a few times. You will see rotating boxes displayed wherever you tap.
Depending on where you tapped, you should see something similar to Figure 1-3.
At this point, your target settings should look like Figure 1-4.
The next thing you need to do is delete the GameScene.sks and Actions.sks files. You will not
be using the level editor in this book. You can find these files in the SuperSpaceMan group,
as shown in Figure 1-5.
After you delete these files, open GameScene.swift and replace its contents with the class in
Listing 1-1.
import SpriteKit
super.init(coder: aDecoder)
}
super.init(size: size)
There is one more change you need to make before examining your baseline project. Open
GameViewController.swift and replace its contents with the Listing 1-2 version of the same
class.
import SpriteKit
super.viewDidLoad()
Save all your changes and click the Play button once more. Wow, um, that was not very
exciting. If you made all the changes, you should now be staring at a totally black screen
with only the current frame rate displayed. This was the intent. You truly are starting from
nothing.
Let’s take a moment and examine each component of your new game. First, open Main.
storyboard. Everything here should look pretty normal. You should see a single storyboard
with a single UIViewController. Expand Game View Controller Scene in the Storyboard
Explorer and select Game View Controller, as shown in Figure 1-6.
Random documents with unrelated
content Scribd suggests to you:
“Hm!” Tompkins frowned. “Sagebrush, that mesa up ahead would
make a fine place for a chicken-ranch, wouldn’t it?”
“Hell of a fine place,” affirmed the desert rat, squinting at the long
saddleback. “Danged fine place, Perfesser! Every wildcat and coyote
in the Chuckwallas would be pointin’ that way, inside of a week. If a
gent was feelin’ real philanthropic and wantin’ to help out the pore
desert critters, I’d say start him a chicken-and-egg factory right up
yonder. Yessir. That’s like Haywire Johnson done, time he was livin’
down to Meteorite. He started him a egg-ranch—done it to get
ahead of some other folks and kep’ it real quiet. Got all his chickens
clear from Phoenix and Yuma, danged near a hull carload of ’em,
and set up incubators and all that truck. Then he begun to figger on
how rich he’d be. Every oncet in a while he’d go out to look for eggs,
but dad blame if he got any. He fed them chickens on everything
from ground-up lizards to eggplant, and nary a egg come along.
Finally he got desp’rit and called in help—and durned if all them
birds wasn’t roosters! Yessir, not a female chicken in the lot. That’s
how come Haywire went broke and had to come over yere to work
for Hassayamp.”
With this rapid utterance, he turned abruptly from the girl and
walked back to Hassayamp, halting the latter’s advance with
upraised hand.
“Mr. Foster!” he said solemnly. “May I inquire, sir—ah, that is a
very interesting creature on your collar, very interesting indeed!”
Hassayamp screwed his head to look at himself, but could see
nothing.
“What is it?” he demanded nervously. “A beautiful little creature,
peculiar to our deserts,” said Tompkins in bland accents.
“Undoubtedly it has sought refuge from the sun under your shirt-
collar. You know, of course, that the solpugid is really an insect,
having tracheal tubes instead of the spider’s book lungs—”
“A spider!” exclaimed Hassayamp. “Git it off’m me, Puffesser,
quick!”
“Not a spider at all, my dear sir, and quite harmless, I assure you,
despite local superstition. Ah, there it goes about your collar—no
wonder the dear little creatures are called wind-scorpions or
vinegaroons—”
“A matavenado—wow! My gosh, git him off’m me!” Hassayamp let
out a yell and began to claw at himself. “I’m a dead man—git him
off’m me—”
Tompkins seized him and brushed vigorously at his back.
“There—he’s gone. Pay no more attention to the matter, I implore
you. I was about to ask whether you ever indulge in spiritous
liquors, Mr. Foster? In such case, I have in my pocket a small vial of
medicinal whisky. I understand that it is the custom in the desert to
offer a drink—”
Hassayamp, who like many another man with slight experience of
the harmless but frightful-looking vinegaroons believed them to be
deadly creatures, was pale with emotion. And with more than
emotion, too.
“If you got a drink, Puffesser,” he implored, “for gosh sake give it
here! I swallered my plug.”
Tompkins produced a small pocket flask and began to unscrew it.
Hassayamp became yet more pale and agitated.
“Oh, gosh!” he groaned. “I’ll never eat no more tobacker—”
He reached out and took the flask. He sniffed it, and into his
melancholic eyes came a glow of warmth and happiness. Tompkins
beamed upon him, as he lifted the flask.
“I forgot to mention, Mr. Foster, that you must use your mustache
as a strainer, because in that whisky I am preserving a very fine
specimen of rock scorpion which I recently discovered, and I should
be very sorry to have it lost—”
Hassayamp jerked the flask from his lips. He looked at the
Professor with slowly distending eyes, then thrust the flask at him;
and, with one agonized groan, retired among the near-by boulders.
Tompkins turned and rejoined Miss Gilman.
“Hassayamp will rejoin you shortly,” he said. “He unfortunately
swallowed his chew of tobacco—an accident which will unnerve the
strongest man, I assure you—” The girl looked at him with strained
and anxious eyes.
“But this—this paper! Do you mean to tell me that this man Alec
Ramsay was your brother?”
Tompkins nodded quietly. “Yes, Miss Gilman. I came here to trace
him—and by a stroke of sheer luck I found this cigarette case. You
have read that deed? Then I advise you to go on up the cañon and
see if the description fits. I haven’t been up there. Be very careful to
say nothing to Hassayamp about this. I’ll see you tonight, if I may,
and we’ll talk over what is to be done. Now I must get off—you’d
better keep a sharp lookout for rattlers among these rocks. Don’t
wait for Hassayamp; he’ll be along as soon as he’s able. Hasta la
vista!”
She made no response, but stood gazing after him thoughtfully as
he turned and departed.
CHAPTER VI
As Tompkins climbed down the rock-strewn cañon toward the
thorny growth which hid the flivver from sight, he came to a decision
upon his course of action, forcing himself to determine upon a
caution which was distasteful and yet necessary.
“Hasta mañana!” he resolved. “Until tomorrow, at least, I must
remain Percival and so forth Tompkins—and then I’ll become Pat
Ramsay once more, and get into action. The damned murderers! I
wonder how many men have gone the way of poor Alec? I wonder
how many people have been decoyed into this spiderweb to lose
everything they had? Alec must have gone investigating, must have
discovered the headquarters of this gang—and so they finished him.
He’s probably lying somewhere up that cañon now. Well, time
enough to look him up; just now I’ve got to watch my step mighty
close.”
He was now assailed by the problem of locating Sagebrush, since
he could not well run off with the car and leave his companion to
rusticate in the desert solitudes. As he came in sight of the patch of
piñon and cactus which enshrined the flivver, he caught no sign of
the desert rat. He knew that he could recall Sagebrush with a
smoke, but this he did not desire to do unless necessary.
When he drew near the clump, he perceived Hassayamp’s flivver
on the other side, with strips of canvas flung over the tires to protect
them. An unusual object beneath this car attracted his attention, and
upon closer approach he discovered it to be no other than
Sagebrush. He gave a hail, and the old desert rat crawled out into
the sunlight.
An exclamation broke from Tompkins, and he hurried forward.
The left arm of Sagebrush was out of its shirt-sleeve and roughly
bandaged, and the bandage was dark with blood.
“What happened?” he demanded. “How’d you hurt yourself, old-
timer?”. Sagebrush clawed at his whiskers and flung the inquirer a
pained look.
“You got it plumb wrong, Perfesser,” he observed. “I aint been
meanderin’ around these parts for fifteen year or more ’thout leamin’
how not to hurt myself. I aint no pilgrim, by gosh!”
“My humble apologies,” said Tompkins dryly. “May I ask, then,
who hurt you?” Sagebrush grinned.
“Another of these yere smart gents who think that ’cause a man’s
a prospector and don’t wear galluses, he’s a babe in arms. I aint
right certain as to this feller’s name, but when I was over to Mohave
six months ago, I seen a picture of him in the sheriff’s office. Name
was Joe Mendoza, or some such cholo name.”
The speaker enjoyed hugely the bewilderment of Tompkins.
“You don’t mean you had a scrap, Sagebrush?”
“Nope.” Sagebrush expectorated, wiped his lips and grinned. “I
was peckin’ away at a ledge in a cañon a couple mile east of yere,
when durned if that feller Mesquite Harrison didn’t come ridin’ down
the cañon on a hoss! Yessir! Right on top o’ me, ’fore I seen him,
too. He started throwin’ lead, and I covered up, and ’fore I could git
into action, the coyote was gone. Then along come another feller
that I hadn’t seen, this yere cholo, and durned if he didn’t pick on
me too. But I was ready for him, you betcha! I gives him jest one
crack from ol’ Betsy,”—here Sagebrush patted his waistband
significantly,—“and he flops. I walks over to him and seen he looked
like this cholo Mendoza, and then I come back yere and set down to
rest a spell.”
“Killed him?” asked Tompkins curtly.
“Hope so. He was some dead when I left him, anyhow, but you
never can tell ’bout them marihuana-eaters. I knowed a cholo over
to Mormon Wells, oncet, that et marihuana and smoked it likewise.
Fin’ly one night he got plumb filled up on it, and jumped into the
corral and begun to slash the hosses with his knife. Sheriff and two
other fellers sat on the bars and pumped lead into him for as much
as five minutes, but he didn’t quit till he’d slashed every hoss there;
then he quit. Sheriff allowed he’d been dead with the first shot, but
the marihuana had kep’ him goin’, same’s a rattler keeps a-twitchin’
till sundown after he’s dead. That there hop is powerful stuff,
Perfesser.”
She gave him a startled look. “You mean a man was killed out
there?”
“Yes, and another wounded. Several are going to be killed in the
near future, if I’m any judge. You needn’t look alarmed about it, Miss
Gilman; they’re outlaws. I’ve opened up the whole situation pretty
well, I think. Now, I hope you’ll take my advice and get out of this
town tomorrow morning on the stage. I expected to be gone about
sunrise, as I have work waiting for me out yonder, but if you think
you’ll need any moral backing in drawing out of the game, I’ll stay
and see you through.”
“No, thanks,” she returned quietly. “I’m staying.”
“After what I’ve told you and showed you?” he said with a frown.
“Yes. Now let me explain, and don’t get too bossy. Hassayamp
wanted to sell me that claim belonging to your brother; it’s one of
the most beautiful spots I ever saw. However, I made some excuse
about it not being suited to chickens, and I’m going to buy the five
acres adjoining it and just above. You wait till you see that place! It’s
got—”
“My dear girl,” said Tompkins, “don’t you know chickens can’t be
raised here, without large and expensive precautions?”
“Oh, I’m not quite a tenderfoot. Chickens or not, I’m going to own
that piece of land! And I’ve taken warning from you, too, because I’ll
not turn over the money until the title is clear and the deed
recorded. The five acres cost me three hundred dollars, mineral
rights and all. Hassayamp owns it. He showed me where a mine
used to be—it’s played out now. I don’t care a bit if the place is
never any real good to me; I’m going to keep it just to live on when
I get old, and enjoy it. Why, you get a wonderful view from the
upper cañon out over the desert!”
“Well,” said Tompkins reluctantly, “since your eyes are open, I
can’t of course make any more objections, though you can buy
plenty of desert cañon for less money. But what about transport?”
“I’ve bought Hassayamp’s car. It’s an old one, but I know all about
a flivver and it will do me. Then, I’m going to get a big tent set up
there—”
Tompkins groaned inwardly, but presently changed the subject. It
was no use whatever to raise up practical objections; the girl would
have to find things out for herself. She was obviously determined on
her course, and the more he saw of her, the more he began to feel
that she was a pretty competent young woman. In fact, as they
walked and spoke of cabbages surd kings, he was distinctly and
unpleasantly surprised to find that it had grown dark and very cold,
and that they must return to shelter immediately. When they had
reached the adobe cells that constituted the hotel, he paused at her
door and shook hands.
“From now on, Miss Gilman, my name’s Ramsay—only you’ll come
to calling me Pat, especially if we’re to be neighbors. If you have any
need of me, don’t hesitate to summon me. I believe Haywire
Johnson is a good sort, and you may confide in him any time. And
by the way, if you hear any queer noises early in the morning, don’t
call for help.”
“I usually don’t,” she said, smiling. “Why?”
“One of the men who murdered my brother is coming to call on
me, I hope.” The smile died on her lips. Her eyes widened on him.
“You mean it? But—but surely you—you don’t intend—”
“We’re going to have a talk; that’s all,” said Tompkins. “Good
night, and pleasant dreams! I’ll see you again. Don’t forget to look
through your blankets for stray lizards.”
He went on to his own cell, and in twenty minutes was sound
asleep.