Watch_me

Develop cross-platform mobile games with Corona using the Lua programming language! Corona is experiencing explosive growth among mobile game developers, and this book gets you up to speed on how to use this versatile platform. You’ll use the Corona SDK to simplify game programming and take a fun, no-nonsense approach to write and add must-have gameplay features. You’ll find out how to create all the gaming necessities: menus, sprites, movement, perspective and sound effects, levels, loading and saving, and game physics. Along the way, you’ll learn about Corona’s API functions and build three common kinds of mobile games from scratch that can run on the iPhone, iPad, Kindle Fire, Nook Color, and all other Android smartphones and tablets.

The book is now compatible with Corona versions 2013.2076 or greater. The current public release, 2013.2100, is also compatible with the book.

Printed in full color.

Printed in full color.

Out of Print

This book is currently out of print.

About this Book

  • 268 pages
  • Published:
  • Release: P2.0 (2014-01-15)
  • ISBN: 978-1-93778-557-4

Get a crash course in cross-platform mobile game programming using the Corona SDK. Corona, one of the easiest to use mobile gaming platforms, makes this often-difficult process both quick and easy to master.

If you’re familiar with programming but new to game development, you’ll feel comfortable as we begin with fundamentals before building examples of the most common kinds of games on the market today. You’ll develop arcade, side scroller, and tower defense games from start to finish, and Corona will automatically turn them into apps that can run on both iOS and Android devices. These finished apps can be used as ready-to-go frameworks for your own future projects. You’ll learn how to write clean, easily maintainable, and easily expandable game code. You’ll also find out how to make money with games: enabling in-app purchases and in-game ads as well as how to get apps into the iTunes App Store, Google Play, and the Amazon Android Marketplace.

This book focuses on getting quick and effective results. Every page teaches by example and explanation, not with abstract lists of functions and variables. By the time you’re done, you’ll have learned most of what there is to know about mobile game programming and about the Corona SDK.


Q&A with Silvia Domenech, author of Create Mobile Games with Corona

Why did you write Create Mobile Games with Corona?

When I started programming, I had access to lots of books for traditional programmers that taught the basics (loops, classes, etc.), but then they moved on to topics that aren’t really necessary for game development. I wanted to make games, so learning how to code yet another phone agenda or scheduling application wasn’t really interesting to me.

I did read game programming books, but many of them felt like university lectures: Here’s a detailed description of the theory; learn to apply it by yourself. Good luck. That was really frustrating, and it made learning slower than reading online forums that had applied examples. Many years later, I stumbled upon a Pragmatic book, and I instantly fell in love with it. I thought, “If somebody uses this style to write about game programming, everyone will be able to learn!”

I waited, and waited, and waited, but no Pragmatic game programming books appeared. During my wait, a few friends and acquaintances asked me how they could learn to make games, and I couldn’t point them to a hands-on resource. I decided to write the book then, in order to help my friends and anyone else who wanted to learn to code games with Corona.

Mobile games are really popular right now, so it is great to be able to teach how to code games using an easy-to-learn engine like the Corona SDK.

What does Corona offer mobile developers that other systems don’t offer?

First of all, Corona makes coding very quick and easy. Many programming languages require you to use extra libraries (or write your own code) to handle common game-related functions such as sprite management or collision detection. Coders can write one or two lines of code to get many game-related things done in Corona, so it really reduces development time.

Corona also comes with lots of resources: documentation, tutorials, and even forums. This is great, because it means that you won’t be alone when coding. Have you found a bug in the Corona compiler? Somebody may have posted about it in the forums. Do you want to code something but it doesn’t work? See if there’s a walkthrough for it. Other languages don’t have so many resources.

Apart from those two advantages, Corona makes it easy to port an iOS game to Android or vice versa. Writing game code twice to use it on two platforms can be boring, and Corona solves this by giving us developers an environment that builds on both iOS and Android.

What kind of games would I be able to make with this book?

Ideally, this book will teach you the basics of Corona so that you can move on to make any game you like. Since we’re making games from the start, we’ll learn how to load and draw images, make them move, and interact with them. Then we’ll move on to more complex topics, like making units find their way around the screen, adding sound effects, and loading and saving data.

The book is divided into several projects so that you can work on more than one game from scratch. You can make a planet defense game, a vertical-scrolling shooter, a tower defense game with pathfinding algorithms, and a physics-based app with advertising and in-app purchase options. That’s roughly the core toolset that any aspiring game programmer will need.

What do you suggest I look at next after this book?

I suggest looking at furniture catalogues to find a comfortable chair to sit on! Oh, you already have one of those? Great! Then you’re ready to learn some advanced game development topics, such as advanced physics, multiplayer games, and even game balancing.

To learn physics, you can take a look at the Box2D documentation (it’s the physics engine used in Corona). You can learn about gravity, velocities, different types of collision handling, constraints, and many other topics that can let you make complex physics-based games. Once you start making games, if you haven’t already made games in other languages, you might also need to get used to game balancing. It’s important to make games challenging but not too challenging, and learning how to balance your games will help you along the way.

If you want to take your learning to the next level, you can look for books or resources on multiplayer game programming. The good part about multiplayer programming is that you can code the server using any language. I personally code many of my multiplayer servers using Java, which makes it quick and easy to code a server from scratch. Corona lets you open sockets to communicate with a server, so it can be lots of fun to make anything ranging from a multiplayer version of tic-tac-toe to a complex MMO. I’d suggest starting with tic-tac-toe or another simple game, though!

What You Need

You need either a Windows or Mac development environment and the downloadable free starter edition of the Corona SDK.

Contents and Extracts

  • Getting Started
    • Hello Corona!
      • Introduction
      • A Word on Game Development
      • Getting Started
      • Building Our First App
      • What We’ve Learned
  • Planet Defender
    • The Game Loop excerpt
      • In this Chapter
      • A Crash Course in Corona Programming
      • Designing Our First Game: Planet Defender
      • Creating the Project
      • Coding the Game Loop
      • What We’ve Learned
    • Sprites and Movement
      • What We’ll Learn
      • Displaying Images
      • Animated Sprites
      • Handling Many Images
      • Moving Images
      • Adding Spaceships to the Game
      • Exercises
      • What We’ve Learned
    • Input and Menus excerpt
      • What We’ll Learn
      • Touch-Based Input
      • Displaying Scenes Using the Storyboard API
      • Adding Buttons
      • Adding Lives and Difficulty
      • What We’ve Learned
      • Expansion Options
  • Vertical-Scrolling Shooter
    • Representing Movement and Perspective
      • What We’ll Learn
      • Designing a Basic Scroller
      • Adding Menus and the Basic Framework
      • Adding and Removing Units
      • Displaying Scrolling Backgrounds and Parallax Effects
      • Generating Random Backgrounds
      • What We’ve Learned
      • Exercises and Expansion Options
    • Adding Shooting, Collisions, and Power-Ups
      • In this Chapter
      • Shooting
      • Checking for Collisions
      • Adding Animated Explosions
      • Adding Power-Ups
      • Ending the Game
      • What We’ve Learned
      • Exercises and Expansion Options
    • Adding Sound excerpt
      • What We’ll Learn
      • Finding Game Sounds
      • Understanding the Corona Sound API
      • Adding Sound Effects
      • Playing Background Music
      • What We’ve Learned
      • Exercises and Expansion Options
  • Tower Defense
    • Displaying Maps and Sorting Depths
      • What We’ll Learn
      • Designing a Tower Defense Game
      • Defining Tile-Based Maps
      • Building Towers
      • Sorting Depths in Corona
      • What We’ve Learned
      • Exercises and Expansion Options
    • Adding Movement and Artificial Intelligence
      • What We’ll Learn
      • Adding Enemies
      • Implementing Enemy Movement
      • Adding Tower AI
      • What We’ve Learned
      • Exercises and Expansion Options
    • Loading and Saving
      • What We’ll Learn
      • Loading Levels
      • Loading and Saving the Game
      • What We’ve Learned
      • Exercises and Expansion Options
  • Physics and Distribution
    • Physics and the Accelerometer
      • What We’ll Learn
      • Defining The Project
      • Adding User Input
      • Adding Physics
      • Using the Accelerometer
      • Debugging
      • What We’ve Learned
      • Expansion Options
  • Appendices
    • Corona Resources
      • Corona Development Tools
      • Art Resources
      • Game Sounds

About the Author

Silvia Domenech has developed games for more than a decade. A respected consultant, she specialized in game development for major entertainment companies, and her games have been played by millions. Naturally, in her free time she likes to… code even more games!

Comments and Reviews

  • It’s straightforward, it’s thorough, and it walks new users through all of the basics. I especially like how the book explains full game templates for popular genres in an easy-to-understand way.

    —Brent Sorrentino developer liaison Corona Labs
  • I’ve wanted to make an iPhone game since the launch of the App Store, and now I feel like I’m closer to my goal. The Corona SDK is a powerful tool, but good tutorials are hard to find; I feel much more prepared having read Silvia’s book!

    —Stephen Orr, lead developer Made Media
  • Looking for a way into programming mobile devices? What could be more fun than making a game (or three)? Create Mobile Games with Corona inspired me to get a little further with an idea I had for a mobile app, and Corona offers lots of speed and versatility for creating such things.

    —Stephen Wolff Django developer
  • Do you want to develop games for the Android platform? Look no further. This book teaches you to create ready-to-distribute games in Lua in no time. Highly recommended!

    —Brian Schau developer coach at TechTalk, creator of SpecFlow Rovsing Applications