Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

Game From Scratch C++ Edition The Introduction


I have decided to take a quick detour from my primary game development, to illustrate how to create a more simplistic 2D game using C++. I am going to cover it over a number of posts, each building on the last and if you follow along, hopefully at the end you will be well on the road to creating your own games.



Why in C++, I thought you hated C++?



That is a good question with a bad answer. I am writing it in C++ because regardless to all the people say “DON’T DO THAT IN C++!” the vast majority of people still do. The problem is so many of these people follow outdated or just downright bad examples and establish a horrific coding style right from day one.



So often questions come up like “how do I split my code up into multiple files” or people state things like “I hate OOP, I’ll just use functions”. Both of these statements illustrate the failing of many tutorials. Using C++ without objects is like using a hammer only as a nail extraction tool; while functional you are entirely missing the point of the tool. One last thing that many new developers get hung up on… we are writing a game, not a game engine! Don’t overwhelm yourself with unneeded complexity when you are just starting out.



This tutorial is going to span a number of posts so that I can go into the detail necessary. I am going to make some decisions for the sake of readability, but for the most part this should be code that you can take away and develop a success game upon. Along the way I will try to explain things to the best of my ability. With each post I will include a download link with the project, source code, etc. I have this nack for going off topic or into detail and frankly that is part of what I enjoy about writing.  That said, it can be confusing or distracting for people that just want the facts.  In this case I will box such comments into “Optional Information” sections that you can freely skip and still keep up. 



One last thing, this post will not teach you to program. I am going to make certain assumptions about my audience, the biggest of which is that you have a few weeks of learning under your belt. I assume you know the very basics in one language like how to declare a variable or how to use an if statement. If you have absolutely no exposure to programming I suggest you head over here for some getting started advice.




What game are we going to create?


We are going to create a downright amazing game about two intrepid paddles in space, called PANG!



Yeah yeah, we are going to create a Pong clone. Frankly every first game should be something simple and fairly easy to complete. That said, if things in this post go according to plan, Pang should provide us a few interesting opportunities, as with each additional post we can add a few more features like 2 player hot-seat, AI, nuclear missiles, networking, etc.



Doing most of the heavy lifting will be the excellent SFML libraries. They are well designed and do a very good job of keeping you away from a lot of the harmful aspects of C++.




Stuff you need to follow along



Before we begin, there are a few things you need to download and install.



This tutorial is going to work entirely with Microsoft C++ Express 2010. If you have another version or different IDE, you can still follow along, but directions will be explicitly for Visual C++ Express. So if you haven’t already head over here and click the Install Now button.


*** One word of warning, if you already have a Visual Studio 2010 product installed and patched to SP1, you will have to reapply the SP1 after you install Visual C++ Express. It takes a long time, and yes, it’s very annoying ***




Next head on over to SFML and download the SFML Windows - Visual C++ 2008 headers / libraries / external libraries package. This link is a zip file, just save it somewhere on your computer, we will address it again shortly.



One last catch ( explained here ) is that the SFML Visual C++ DLLs simply do not work with Visual Studio 2010. I have compiled them for you and you can download them here. Again, simply save that zip file somewhere and we will use it shortly.



Finally you are going to need a paint program of some form. MSPaint will work in a pinch, but I would recommend Paint.NET or the GIMP instead. Download links for both can be found here.



Ok, now that we have everything we need lets move on to Part 1.



  Forward to Part 1

blog comments powered by Disqus

Month List

Popular Comments

New Year, New Project! Or perhaps more accurately, a very old delayed project
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

Home > >

7. January 2014


So a new year is upon us; happy belated New Year everyone!



I figure now is as good of a time as any to get off my arse and work on something I have long been delaying… a complete game.  If you go wayyyyyy back in the annals of history, you will find this post.  My original intention with was to document, well… creating a game from scratch!  Somewhere along the way I sort of wandered off course into writing tutorials and books about game programming in general.  Don’t get me wrong, I absolutely loved the adventure and will continue to create future tutorial series ( and probably books ) as I go forward, but I also intend to go ahead and create that game I was talking about!


Funny enough, of the thousands and thousands of game ideas in my head, nearly three years later it’s still the same game that interests me.  I will flesh it out in a bit more detail in later posts.


What does this mean for


Well, first the negatives…  there probably won’t be any massive tutorial series like the C++, LibGDX, MOAI or Blender ones, at least for the next few months.  Truth of the matter is, each of these series when put into page form are about equivalent to a 200+ page book!  In fact, I am in the process of turning one of those series into a book and these page count is pushing 300 once converted.  Creating these series represents a massive investment of time and that time won’t be available while working on a game title.


That said, I will still continue to do smaller ( say… one to four part ) tutorials on a variety of subjects, it’s just the massive series that I won’t be undertaking.  I will also continue to do in-depth reviews/previews of shiny new gaming technologies like I have in the past.  Of course, I will also be cherry picking the news I think will be of most interest to indie developers.  There are a couple of new site ideas I have as well that hopefully you will find interesting. So, at the end of the day, things won’t be all that different around these here parts.


Now the good change, from this point on you are going to have access to a developer blog that goes MUCH MUCH MUCH deeper than almost any I can think of on the net.  I am ultimately creating a product I intend to sell at the end, so I am not going to be working completely open source ( at least, not before release… may open up source code and assets after the fact ).  I am however going to be as open as I possibly can be.  In fact, I’d like to keep a HTML5 playable version of the game available here as I develop!  ( If HTML doesn’t end up being a complete pain in the ass that is…  big if that! ).  So, what’s keeping people from just ripping off my ideas, code, art style etc… and essentially cloning my game?  Nothing I suppose, except karma.  Should your house be visited by a plague of locusts… totally wasn’t me!


Along the way, I intend to show behind the curtain for just about everything…  share the more interesting code I develop, show the design process, works in progress, etc…  I will also be documenting all the business process behind the game too, the stuff most of us ignore ( and possibly hate! ).  Things like submitting to the app stores, setting up servers, promoting the product through various means ( ewwwwww ) maybe even topics like dealing with DLC or hosting ads.


In many ways, it will be a lot like the site currently is.  The major difference is, the topics I will be focused on in my writing are going to be topics I am actually facing in the real world.  The other big difference is going to be the depth of coverage.  For example, one immediate problem I am going to have to work on is rendering 3D models in realtime for a 2.5D game.  I intend to share the code for how I accomplish this and maybe even a bit of an explanation.  It will not however be a tutorial, so I won’t be going into detail about how I do things… of course, the comments are always available should you have a question.


If I pull this off, hopefully it will result in a very clear, detailed, hopefully interesting insight into the entire game development process, from concept to shipping ( hopefully money making! ) product!  Oh and hopefully it will result in one damned fun game too.


Hope you enjoy the ride.  Oh, and if there are any shorter tutorial series you are interested in, please let me know!

blog comments powered by Disqus

Month List

Popular Comments