Learning iOS Game Programming: A Hands-On Guide to Building Your First iPhone Game potx

440 1.3K 4
Learning iOS Game Programming: A Hands-On Guide to Building Your First iPhone Game potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ptg Download from www.wowebook.com ptg Praise for Learning iOS Game Programming “An excellent introduction into the world of game development explaining every aspect of game design and implementation for the iPad, iPhone, and iPod touch devices. A great way for anyone interested in writing games to get started.” —Tom Bradley, Software Architect, Designer of TBXML “A great developer and a great game.That’s everything you can find in this book to learn how to write an awesome game for iPhone. Maybe you’re the next AppStore hit!” —Sebastien Cardoso “With Learning iOS Game Programming, you’ll be writing your own games in no time. The code included is well explained and will save you hours of looking up obscure stuff in the documentation and online forums.” —Pablo Gomez Basanta, Founder, Shifting Mind “I always thought that to teach others one has to be an expert and a person with an established reputation in the field. Michael Daley proved me wrong. He is teaching oth- ers while studying himself. Michael’s passion in teaching and studying, ease of solutions to problems, and a complete game as a resulting project makes this book one of the best I have ever read.” —Eugene Snyetilov “If you’re interested in 2D game programming with the iOS using OpenGL and OpenAL directly, this book walks you through creating a complete and fun game without getting bogged down in technical details.” —Scott D. Yelich “Michael Daley brings clarity to the haze of iPhone application development. Concrete examples, thorough explanation, and timesaving tips make this book a must have for the up and coming iPhone game developer.” —Brandon Middleton, Creator of Tic Tac Toe Ten “This is the A-Z guide to iOS game development; Michael’s book takes you from the basics and terminology to using the techniques in practice on a fully working game. Before you know it, you will find yourself writing your own game, fueled by a firm grasp of the principles and techniques learned within. I could not ask for a better refer- ence in developing our own games.” —Rod Strougo, Founder Prop Group Download from www.wowebook.com ptg This page intentionally left blank Download from www.wowebook.com ptg Learning iOS Game Programming Download from www.wowebook.com ptg This page intentionally left blank Download from www.wowebook.com ptg Learning iOS Game Programming Michael Daley Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City Download from www.wowebook.com ptg Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publish- er was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omis- sions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk pur- chases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact: International Sales international@pearson.com Visit us on the Web: informit.com/aw Library of Congress cataloging-in-publication data is on file. Copyright © 2011 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited repro- duction, storage in a retrieval system, or transmission in any form or by any means, elec- tronic, mechanical, photocopying, recording, or likewise. For information regarding permis- sions, write to: Pearson Education, Inc. Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671-3447 ISBN-13: 978-0-321-69942-8 ISBN-10: 0-321-69942-4 Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana. First printing September 2010 Senior Acquisitions Editor Chuck Toporek Senior Development Editor Chris Zahn Managing Editor Kristy Hart Project Editors Barbara Campbell and Jovana San Nicolas-Shirley Copy Editor Water Crest Publishing Indexer Lisa Stumpf Proofreader Sheri Cain Publishing Coordinator Romny French Cover Designer Chuti Prasertsith Download from www.wowebook.com ptg ❖ Dedicated to my mum, Jen ❖ Download from www.wowebook.com ptg Contents at a Glance Preface xxi 1 Game Design 1 2 The Three Ts: Terminology, Technology, and Tools 13 3 The Journey Begins 39 4 The Game Loop 73 5 Image Rendering 97 6 Sprite Sheets 137 7 Animation 153 8 Bitmap Fonts 165 9 Tile Maps 183 10 The Particle Emitter 223 11 Sound 249 12 User Input 285 13 The Game Interface 299 14 Game Objects and Entities 325 15 Collision Detection 357 16 Putting It All Together 369 Index 395 Download from www.wowebook.com ptg Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi 1 Game Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 The Game That Started It All (For Me) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 So, What’s the Big Idea? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 A Game That Fits with the iPhone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 The Storyline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 What’s in a Name? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 The Game’s Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Game Play Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Lives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Health . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Doors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Weapons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2 The Three Ts: Terminology, Technology, and Tools . . . . . . . . . . . . . . . . . . 13 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Sprite Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Bitmap Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Tile Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Particle System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Collision Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Artificial Intelligence (AI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Game Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Cocoa Touch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 OpenGL ES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 OpenAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Download from www.wowebook.com [...]... the Amiga A5 00 Never having lost a passion for game programming, Michael got inspired to learn Objective-C when the iPhone came out, and he set out to learn how to build games for the iPhone Having written many games for his children over the years, the launch of the iPhone inspired him to create games for the platform that would be available to more than his children Michael has a passion for learning. .. currently available for free download from the App Store, and is the game you learn how to build as you work your way through this book Download the Game! You can download Sir Lamorak’s Quest from the App Store: http://itunes.apple.com/us/app/sir-lamoraks-quest-thespell/id368507448?mt=8 The game is freely available, so go ahead and download the game, start playing around with it, and help Sir Lamorak escape... Halo 10), I ended up with a classic 2D game based in a haunted castle.The castle is inhabited by ghosts and ghouls, and it is a place where only the foolhardy dare to venture.With this in mind, I wrote a storyline to the game to help me build an image of how it was going to look and also give me something to refer back to as I programmed the game Tip In the past, I’ve found it easy to wander off track... decided to implement an onscreen joypad to control the main character It was important, though, to allow the player to swap the position of this joypad so that both left- and right-handed players found the game comfortable As for the game play itself, I decided to take a number of design ideas from games I played in the ‘80s and went with a top-down scroller, in which the player is trapped in a haunted castle... forward, and it helps build the game s identity Download from www.wowebook.com 6 Chapter 1 Game Design You would not think that naming your game could cause problems, but you need to be aware of a couple of important issues when it comes to deploying your game to the App Store.At the time of writing, there are over 150,000 apps in the App Store.That’s a lot of apps and a lot of names that have already... be a real pain to be asked to take down your game because of copyright issues.This goes for all content in your game, really.You are asked during the process of loading your app onto the App Store whether all the content is yours so as to make sure you are not infringing any copyrights It’s worth checking As for the name, all you can do is keep checking the App Store for the name you want to use and... change as the game developed, it was important to lay down ideas and start plotting the course Time Time can either be used to limit the amount of time a player has to carry out a task or used to measure how long something has taken For this game, I decided to use time to record how long it takes the player to complete the game Having both a score and a time gives players a couple of different measurements... the game finished on time Ryan Sumo is a freelance video game artist residing in Manila,The Philippines He created all the artwork used in Sir Lamorak’s Quest that gives the game its retro look He is a true professional and a pleasure to work with His rapid delivery of art and great feedback and suggestions really helped give the game its great look If you ever run into Ryan in Manila and show him a. .. by the baddies), it would make someone want to play the game again to better their high score as well as Download from www.wowebook.com Game Play Components 7 their time.That meant that the parchment pieces for the Spell of Release would have to be placed around the castle randomly, so that each time the game is played, the player would need to hunt for the parchment all over again, rather than memorizing... considerations are needed to create a 2D game engine.This enables you to take the same game engine developed in this book and use it in your own games, or simply use the knowledge you have gained about creating games in general and use one of the many game engines available for the iPhone, such as Cocos2D Who This Book Is For If you are already developing applications for the iPhone for other platforms, but want . him to create games for the platform that would be available to more than his children. Michael has a passion for learning new technologies and how to apply. Michael has taken on the task of learning how to build games for the iPhone. Michael started writing adventure games in BASIC on a Sinclair Spectrum 48k and

Ngày đăng: 22/03/2014, 15:21

Từ khóa liên quan

Mục lục

  • Table of Contents

  • Preface

  • 1 Game Design

    • The Game That Started It All (For Me)

    • So, What’s the Big Idea?

      • A Game That Fits with the iPhone

      • The Storyline

      • What’s in a Name?

      • The Game’s Objective

      • Game Play Components

        • Time

        • Lives

        • Health

        • Objects

        • Doors

        • Weapons

        • Entities

        • Player

        • Summary

        • 2 The Three Ts: Terminology, Technology, and Tools

          • Terminology

            • Sprite

            • Sprite Sheet

            • Animation

            • Bitmap Fonts

Tài liệu cùng người dùng

Tài liệu liên quan