Book Image

Marmalade SDK Mobile Game Development Essentials

By : Sean Scaplehorn
Book Image

Marmalade SDK Mobile Game Development Essentials

By: Sean Scaplehorn

Overview of this book

Modern mobile devices are capable of supporting video games of amazing quality but there are so many different devices and platforms how can you support them all? The answer is to use the Marmalade SDK to write your code once and deploy it to all popular mobile platforms at the touch of a button.Marmalade SDK Mobile Game Development Essentials will provide you with everything you need to know to transfer your existing C++ videogame programming knowledge to mobile devices. From graphics and sound to input methods and actual deployment to device, this book covers the lot.Learn how to make use of keys, touch screen and accelerometer inputs for controlling your game.Take the pain out of supporting a varied range of target devices, both across multiple platforms and multiple specifications.Step by step from "Hello World" to a complete game, this book will show how to use the Marmalade SDK to develop games for mobile devices.Learn how to make dazzling 2D and 3D games complete with fully animated characters, music and sound effects that can be deployed to all the leading mobile platforms, whilst ensuring it can run on a wide range of possible devices, from low specification to high end.If you want to join the exciting world of mobile videogames then Learning Mobile Game Development with Marmalade will show you how to do so, fast!
Table of Contents (17 chapters)
Marmalade SDK Mobile Game Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The modern mobile device is an immensely powerful piece of equipment. Technology has advanced to such an extent that the current generation of cell phones and tablets are able to host games and applications that are both graphically and sonically impressive, and can even be compared to the titles available on home consoles and computers.

However, writing a game that will run on the plethora of available devices is difficult. There are a number of different platforms to support (for example, Android and iOS) and each platform can have devices that range considerably in terms of capabilities and processing power.

This is where the Marmalade SDK comes to the rescue! Marmalade is a cross-platform solution that allows us to write the source code for a video game once in C++ (a language that most video game developers will already be familiar with) and then deploy it to a number of different platforms, including iOS, Android, and BlackBerry PlayBook.

In this book we shall be learning how to use the Marmalade SDK to implement all the features demanded of a modern mobile video game.

What this book covers

Chapter 1, Getting Started with Marmalade: We start our journey into the world of the Marmalade SDK by learning how to install the SDK and build a simple "Hello World" application. We will then discover how to deploy and run the finished program to a number of different mobile platforms.

Chapter 2, Resource Management and 2D Graphics Rendering: Most video games are media-rich experiences packed full of superb graphics and stunning sound effects and music. In this chapter we will first look at how Marmalade makes it easy for us to load graphics and other resources into memory by using the built-in resource handling system. We will then discover how to render simple two-dimensional graphics on the screen.

Chapter 3, User Input: Our games will need to allow the user to provide input to control the action; so in this chapter we will be looking at how to respond to keypad, touch screen, and accelerometer inputs.

Chapter 4, 3D Graphics Rendering: Mobile devices now feature graphics processing units that enable them to easily render beautiful 3D graphics. After a brief overview of the basics of 3D rendering, we will then learn how to use Marmalade to render a spinning cube, first by generating the 3D model data in code and later by discovering how we can use a 3D modeling package to create and export a 3D model that can be loaded and drawn in a Marmalade application.

Chapter 5, Animating 3D Graphics: Building on the foundation of the previous chapter, we will then cover how to make our 3D graphics more interesting by making them animated.

Chapter 6, Implementing Fonts, User Interfaces, and Localization: Before a user can even play the first level of our game, they will first need to navigate its menu system. This chapter covers Marmalade's support for font rendering, the ways in which a user interface can be constructed, and finishes up with a look at how to localize a game so it can support multiple languages.

Chapter 7, Adding Sound and Video: Sound and music are both very important aspects of a video game and can make a game feel much more immersive and exciting, so learning how to add these elements to a game is the main aim of this chapter. Marmalade. also allows us to display full motion video clips, so we'll take a brief look at this too.

Chapter 8, Supporting a Wide Range of Devices: Different mobile devices have different capabilities and can also vary in terms of both main processor and graphics rendering power. In this chapter we look at ways in which Marmalade helps us to support as wide a range of devices as possible by allowing our game to adapt to the hardware it is running on. We'll also look at using Marmalade's built-in support for compressing and decompressing files to reduce the size of our game's installation package.

Chapter 9, Adding Social Media and Other Online Services: Since most devices are now permanently connected to the Internet, this chapter explores some of the options available to us for adding online features to our games, from integration with Facebook to displaying adverts as a possible revenue stream.

Chapter 10, Extending Marmalade with the Extensions Development Kit (EDK): While the Marmalade SDK does a great job of standardizing most of the normal requirements of writing a videogame, such as displaying graphics or playing sounds, there sometimes comes the requirement to access a device feature that Marmalade does not support directly. This chapter shows how we can get access to the underlying SDK on Windows, iOS, and Android in order to access device features that we would otherwise not be able to.

What you need for this book

You will need the following in order to make full use of the content of this book:

  • An Internet-connected PC with at least 1GB RAM running Windows XP Service Pack 2, Vista, or Windows 7

  • Microsoft Visual Studio 2005/2008/2010 (C++ Express editions are suitable for this)

  • A licensed copy of the Marmalade SDK

The first chapter will explain how to install a suitable version of Microsoft Visual Studio, and how to obtain Marmalade and purchase a license for it.

For making iOS deployments, you will also need to have signed up to Apple's iOS Developer Program; further details on this are also provided in the first chapter.

For the chapters on 3D graphics, it will also be beneficial if you have one of the supported modeling packages available. Marmalade provides direct support for Autodesk 3DS Max and Autodesk Maya, but a cheaper alternative is the open source Blender package.

Who this book is for

This book is intended to show you how to use Marmalade to implement the features required by a video game. It is not intended as a guide on how to write a video game, although there is sample code provided for a simple game that grows alongside each chapter of the book.

Since the Marmalade SDK is implemented in C++, you are expected to already be able to code in this programming language.

You are also expected to have a working knowledge of the concepts involved in both 2D and 3D graphics rendering. Brief overviews are provided in the relevant chapters, but they are intended merely as a refresher and to introduce terminology used in later parts of the book.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The value used for platform is normally just the name of the operating system."

A block of code is set as follows:

{OS=IPHONE}
Message="Hello iOS!"
{}
{OS=QNX}
Message="Hello BlackBerry!"
{}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

{OS=IPHONE}
Message="Hello iOS!"
{}
{OS=QNX}
Message="Hello BlackBerry!"
{}

Any command-line input or output is written as follows:

C:\PlayBook> blackberry-debugtokenrequest -cskpass <password> -keystoresigtool.p12 -storepass <password> -deviceId 0x<device id> debugtoken.bar

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: ""

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/3363OT_images.pdf

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.