Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Game engines


Long before the mobile-games era or even PC-gaming era, each game was created for a specific hardware. This means that if you wanted to create a game, you had to spend some time learning low-level details of hardware specification and take into account all of its characteristics, constraints, and sometimes, issues.

Then, when the game was completed and you wanted to create a different game, there was very little you could reuse from the previous games you created. We're not even speaking about porting your existing game to another platform. In this case, you just had to rewrite it almost from scratch.

But hey! We're very lucky to live in a different time. A game developer's life is much easier these days. In our time, we have a lot of different game engines at our disposal; these make our lives much easier.

So what is a game engine?

A game engine is a software framework that adds a level of abstraction between hardware, video drivers, sound drivers, and your code. Typical game engines provide the following functionalities:

  • Rendering: This is the main function of the majority of game engines. This function helps you actually draw something on the screen without the need to write any low-level code. In addition, a game engine sets up a lot of features for you, such as initializing graphics and loading textures. For example, using a modern game engine, you can draw a player character on screen with 2-3 lines of code compared to 30-50 lines of code if you're using OpenGL ES 2.0 directly. In addition to static drawing, game engines provide the ability to animate, scale, rotate, and do many other useful things just by changing an object property.

  • User input: There might be a few great games I don't know about, where you don't have to do anything and don't control the game flow in any way. You just watch what happens on the screen and enjoy (if you know of such games, let me know!). All the recent popular games take some kind of user input (cutting the rope with a finger swipe, touching to activate jetpack, and so on). A game engine lets you get that user input in a convenient manner and respond to it in the game.

  • Sound: Games with sound are so much better! Adding the right sound effects and music can turn a mediocre game into a real gem. Again, game engines come to the rescue and let you play sound effects and background music with only a few lines of code.

Some game engines provide additional functionalities such as physics engine, collision detection, scripting, artificial intelligence, networking and multiplayer support, and localization support. However, many great games were created only using the three functionalities mentioned earlier.

So what is this all about?

First, it is nice to know that you're lucky to live in a time when you can take a game engine and concentrate on making great games instead of spending time on learning hardware specification. So, you have no excuses to not start creating games right now!

Second, Cocos2D is a game engine, so it is a good idea to get a basic understanding of a game engine, its purpose, and its main functions.

Third, many developers including myself love to reinvent the wheel. If you're just beginning game development and considering whether you should invest your time in learning a game engine and using it, or learning low-level features such as OpenGL and possibly creating your own game engine with blackjack, I strongly advise you to start with a game engine such as Cocos2D.

You will learn a lot of game development concepts, and more importantly, you will be able to actually make games. After releasing your first game, you will get invaluable experience, and later, if you decide to dive deeper into low-level details, you will find it much easier after working with a game engine.

Also, it is nice to know that Cocos2D is based on OpenGL ES 2.0 and won't constrain you in any way. You will be able to write low-level code where you think it is required, but still leave all the routine work to Cocos2D.