This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do.
A Boy Who Wanted To Create Worlds
Once there was a boy who fell in love with this magical device that could bring things to lifeinside a glaring screen. He spent endless hours exploring imaginary worlds, fighting strangecreatures, shooting pixelated spaceships, racing boxy cars. The boy kept pondering. How is thismade? I want to create my own worlds.
Then he discovered programming. I can finally do it! - he thought. And he tried. And failed. Thenhe tried harder. He failed again and again. He was too naive to realize that those worlds he wastrying to create were too sophisticated, and his knowledge was too limited. He gave up creatingthose worlds.
What he didnt give up is writing code for this magical device. He realized he isnt smart enoughto create worlds, yet he found out he could create simpler things like small applications - web,desktop, server side or whatnot. Few years later he found himself getting paid to make those.
Applications got increasingly bigger, they spanned across multiple servers, integrated witheach other, became pats of huge infrastructures. The boy, now a grown man, was all into it.It was fun and challenging enough to spend over 10000 hours learning and building what otherswanted him to build.
Some of these things were useful, some where boring and pointless. Some were never finished. Therewere things he was proud of, there were others that he wouldnt want to talk about, nonethelesseverything he built made him a better builder. Yet he never found the time, courage orreason to build what he really wanted to build since he was a little boy - his own worlds.
Until one day he realized that no one can stop him from following his dream. He felt that equippedwith his current knowledge and experience he will be able to learn to create worlds of his own. Andhe went for it.
This boy must live in many software developers, who dream about creating games, but instead selltheir software craftsmanship skills to those who need something else. This boy is me, and you. Andits time to set him free.
Welcome to the world of game development that was waiting for you all these years.
Why Ruby?
When it comes to game development, everyone will tell you that you should go with C++ or some otherstatically typed language that compiles down to bare metal instructions. Or that you should go withfull blown game development platform like Unity. Slow, dynamic languageslike Ruby seem like the last choice any sane game developer would go for.
A friend of mine said Theres littlereason to develop a desktop game with Ruby, and he was absolutely right. Perhaps this is thereason why there are no books about it. All the casual game action happens in mobile devices, anddesktop games are for seasoned gamers who demand fast and detailed 3D graphics, motion-capturedanimations and sophisticated game mechanics - things we know we are not going to be able to buildon our own, without millions from VC pockets and Hollywood grade equipment.
Now, bear with me. Your game will not be a 3D MMORPG set in huge, photo realisticrepresentation of Middle-earth. Lets leave those things to Bethesda, Ubisoft and Rockstar Games.After all, everyone has to start somewhere, and you have to be smart enough to understand, thateven though that little boy in you wants to create an improved version of Grand Theft Auto V, wewill have to go for something that resembles lesser known Super Nintendo titles instead.
Why not go mobile then? Those devices seem perfect for simpler games. If you are a true gamer atheart, you will agree that touch screen games you find in modern phones and tablets are only goodfor killing 10 minutes of your time while taking a dump. You have to feel the resistance when youclick a button! Screen size also does matter. Playing anything on mobile phone is a torture forthose who know what playing real games should feel like.
So, your game will have to be small enough for you to be able to complete it, it will have to havesimple 2D graphics, and would not require the latest GeForce with at least 512MB of RAM. Thisfact gives you the benefit of choice. You dont have to worry about performance that much. You canchoose a friendly and productive language that is designed for programmer happiness. And this iswhere Ruby starts to shine. Its beautiful, simple and elegant. It is close to poetry.
What You Should Know Before Reading This Book
As you can read on the cover, this book is for those who write code for living. Itsnot a requirement, and you will most likely be able to understand everything even if you are astudent or hobbyist, but this book will not teach you how to be a good programmer. If you want tolearn that, start with timeless classic: The Pragmatic Programmer: From Journeyman toMaster.
You should understand Ruby at least to some extent. There are plenty of books and resourcescovering that subject. TryWhys Poignant Guide To Ruby orEloquent Ruby. You can also learn itwhile reading this book. It shouldnt be too hard, especially if you already write code for living.After all programming language is merely a tool, and when you learn one, others are relativelyeasy to switch to.
You should know how to use the command line. Basic knowledge of Git can alsobe handy.
You dont have to know how to draw or compose music. We will use media that isavailable for free. However, knowledge of graphics and audio editing software wont hurt.
What Are We Going To Build?
This question is of paramount importance. The answer will usually determine if you will likely tosucceed. If you want to overstep your boundaries, you will fail. It shouldnt be too easy either.If you know something about programming already, I bet you can implement Tic Tac Toe, but will youfeel proud about it? Will you be able to say Ive built a world!. I wouldnt.
Graphics
To begin with, we need to know what kind of graphics we are aiming for. We will instantly rule out3D for several reasons:
- We dont want to increase the scope and complexity
- Ruby may not be fast enough for 3D games
- Learning proper 3D graphics programming requires reading a separate book that is several timesthicker than this one.
Now, we have to swallow our pride and accept the fact that the game will have simple 2D graphics.There are three choices to go for:
- Parallel Projection
- Top Down
- Side-Scrolling
Parallel Projection (think Fallout 1 & 2) is pretty close to 3D graphics, it requires detailed artif you want it to look decent, so we would have a rough start if we went for it.
Top Down view (old titles of Legend of Zelda) offers plenty of freedom to explore the environmentin all directions and requires less graphical detail, since things look simpler from above.
Side Scrolling games (Super Mario Bros.) usually involve some physics related to jumping andrequire more effort to look good. Feeling of exploration is limited, since you usually move fromleft to right most of the time.