Beginning Android Games
معرفی کتاب «Beginning Android Games» نوشتهٔ Mario Zechner, Robert Green، منتشرشده توسط نشر Apress : Distributed to the Book trade worldwide by Springer Science+Business Media در سال 2011. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Beginning Android Games» در دستهٔ بدون دستهبندی قرار دارد.
Beginning Android Games offers everything you need to join the ranks of successful Android game developers. You'll start with game design fundamentals and programming basics, and then progress towards creating your own basic game engine and playable games. This will give you everything you need to branch out and write your own Android games. The potential user base and the wide array of available high-performance devices makes Android an attractive target for aspiring game developers. Do you have an awesome idea for the next break-through mobile gaming title? Beginning Android Games will help you kick-start your project. The book will guide you through the process of making several example games for the Android platform, and involves a wide range of topics: The fundamentals of game development The Android platform basics to apply those fundamentals in the context of making a game The design of 2D and 3D games and their successful implementation on the Android platform What you’ll learn How to set up and use the development tools for developing your first Android application The fundamentals of game programming in the context of the Android platform How to use the Android's APIs for graphics (Canvas, OpenGL ES 1.0/1.1), audio, and user input to reflect those fundamentals How to develop two 2D games from scratch, based on the Canvas API and OpenGL ES. How to create a full-featured 3D game How to publish your games, get crash reports, and support your users How to complete your own playable 2D OpenGL games Who this book is for This book is for people with a basic knowledge of Java who want to write games on the Android platform. It also offers information for experienced game developers about the pitfalls and peculiarities of the platform. Table of Contents Android, the New Kid on the Block First Steps with the Android SDK Game Development 101 Android for Game Developers An Android Game Development Framework Mr. Nom Invades Android OpenGL ES: A Gentle Introduction 2D Game Programming Tricks Super Jumper: A 2D OpenGL ES Game OpenGL ES: Going 3D 3D Programming Tricks Droid Invaders: the Grand Finale Publishing Your Game What’s Next? Cover......Page 667 Contents at a Glance......Page 3 Contents......Page 670 About the Author......Page 677 About the Technical Reviewer......Page 678 Acknowledgments......Page 679 How This Book Is Organized......Page 4 Getting the Source Code......Page 5 Android, the New Kid on the Block......Page 6 A Brief History of Android......Page 7 The Android Open Source Project......Page 8 The Android Market......Page 9 Challenges, Device Seeding, and Google I/O......Page 11 Android’s Features and Architecture......Page 12 The Runtime and Dalvik......Page 13 System Libraries......Page 14 The Application Framework......Page 15 The Software Development Kit......Page 16 Devices, Devices, Devices!......Page 17 Hardware......Page 18 First Gen, Second Gen, Next Gen......Page 19 A Gaming Machine in Every Pocket......Page 25 Always Connected......Page 26 Big Market, Small Developers......Page 27 Summary......Page 28 Setting Up the Development Environment......Page 29 Setting Up the Android SDK......Page 30 Installing the ADT Eclipse Plug-In......Page 32 A Quick Tour of Eclipse......Page 34 Creating the Project......Page 36 Exploring the Project......Page 37 Writing the Application Code......Page 39 Creating an Android Virtual Device......Page 42 Running an Application......Page 43 Debugging an Application......Page 46 LogCat and DDMS......Page 50 Using ADB......Page 52 Summary......Page 53 Genres: To Each One’s Taste......Page 55 Causal Games......Page 56 Puzzle Games......Page 58 Action and Arcade Games......Page 60 Tower-Defense Games......Page 63 Game Design: The Pen Is Mightier Than the Code......Page 64 Core Game Mechanics......Page 65 A Story and an Art Style......Page 67 Screens and Transitions......Page 68 Code: The Nitty-Gritty Details......Page 74 Application and Window Management......Page 75 Input......Page 76 File I/O......Page 79 Audio......Page 80 Graphics......Page 84 The Game Framework......Page 98 Summary......Page 105 Android for Game Developers......Page 106 Defining an Android Application: The Manifest File......Page 107 The Element......Page 108 The Element......Page 110 The Element......Page 112 The Element......Page 113 Android Game Project Setup in Ten Easy Steps......Page 115 Defining the Icon of Your Game......Page 117 Creating a Test Project......Page 119 The Activity Life Cycle......Page 123 Input Device Handling......Page 130 File Handling......Page 147 Playing Sound Effects......Page 153 Streaming Music......Page 157 Basic Graphics Programming......Page 161 Best Practices......Page 185 Summary......Page 186 Plan of Attack......Page 187 The AndroidFileIO Class......Page 188 AndroidAudio, AndroidSound, and AndroidMusic: Crash, Bang, Boom!......Page 189 AndroidInput and AccelerometerHandler......Page 194 AccelerometerHandler: Which Side Is Up?......Page 195 The Pool Class: Because Reuse is Good for You!......Page 196 KeyboardHandler: Up, Up, Down, Down, Left, Right . . .......Page 198 Touch Handlers......Page 202 AndroidInput: The Great Coordinator......Page 209 Handling Different Screen Sizes and Resolutions......Page 211 AndroidPixmap: Pixels for the People......Page 217 AndroidGraphics: Serving Our Drawing Needs......Page 218 AndroidFastRenderView: Loop, Strech, Loop, Stretch......Page 222 AndroidGame: Tying Everything Together......Page 225 Summary......Page 229 Creating the Assets......Page 230 MrNomGame: The Main Activity......Page 233 Assets: A Convenient Asset Store......Page 234 Settings: Keeping Track of User Choices and High Scores......Page 235 LoadingScreen: Fetching the Assets from Disk......Page 237 The Main Menu Screen......Page 238 The HelpScreen Class(es)......Page 242 Rendering Numbers: An Excursion......Page 244 Implementing the Screen......Page 246 Abstracting.........Page 248 Abstracting the World of Mr. Nom: Model, View, Controller......Page 249 The GameScreen Class......Page 260 Summary......Page 268 What Is OpenGL ES and Why Should I Care?......Page 269 The Programming Model: An Analogy......Page 270 Projections......Page 272 Matrices......Page 275 The Rendering Pipeline......Page 276 Before We Begin......Page 277 GLSurfaceView: Making Things Easy Since 2008......Page 278 GLGame: Implementing the Game Interface......Page 281 Defining the Viewport......Page 288 Defining the Projection Matrix......Page 289 Specifying Triangles......Page 292 Putting It Together......Page 296 Specifying Per Vertex Color......Page 300 Texture Coordinates......Page 304 Uploading Bitmaps......Page 306 Texture Filtering......Page 308 Disposing of Textures......Page 309 Putting It Together......Page 310 A Texture Class......Page 313 Indexed Vertices: Because Reuse Is Good for You......Page 315 Putting It Together......Page 316 A Vertices Class......Page 318 Alpha Blending: I Can See Through You......Page 321 More Primitives: Points, Lines, Strips, and Fans......Page 325 World and Model Space......Page 326 Matrices Again......Page 328 An First Example Using Translation......Page 329 More Transformations......Page 333 Measuring Frame Rate......Page 338 The Curious Case of the Hero on Android 1.5......Page 339 What’s Making My OpenGL ES Rendering So Slow?......Page 340 Removing Unnecessary State Changes......Page 341 Reducing Texture Size Means Fewer Pixels to Be Fetched......Page 343 Reducing Calls to OpenGL ES/JNI Methods......Page 344 The Concept of Binding Vertices......Page 345 In Closing......Page 348 Summary......Page 349 Before We Begin......Page 350 In the Beginning There Was the Vector......Page 351 Working with Vectors......Page 352 A Little Trigonometry......Page 354 Implementing a Vector Class......Page 356 A Simple Usage Example......Page 359 Newton and Euler, Best Friends Forever......Page 364 Force and Mass......Page 365 Playing Around, Theoretically......Page 366 Playing Around, Practically......Page 367 Collision Detection and Object Representation in 2D......Page 371 Bounding Shapes......Page 372 Constructing Bounding Shapes......Page 374 Game Object Attributes......Page 376 Broad-Phase and Narrow-Phase Collision Detection......Page 377 An Elaborate Example......Page 385 A Camera in 2D......Page 398 The Camera2D Class......Page 401 An Example......Page 402 Texture Atlas: Because Sharing Is Caring......Page 404 An Example......Page 406 The TextureRegion Class......Page 410 The SpriteBatcher Class......Page 411 Sprite Animation......Page 421 The Animation Class......Page 422 An Example......Page 423 Summary......Page 427 Core Game Mechanics......Page 428 A Backstory and Art Style......Page 429 Screens and Transitions......Page 430 Defining the Game World......Page 431 The UI Elements......Page 434 Handling Text with Bitmap Fonts......Page 436 The Game Elements......Page 438 Texture Atlas to the Rescue......Page 440 Music and Sound......Page 441 The Assets Class......Page 443 The Settings Class......Page 446 The Main Activity......Page 447 The Font Class......Page 448 The Main Menu Screen......Page 450 The Help Screens......Page 453 The High-Scores Screen......Page 456 The Simulation Classes......Page 458 The Game Screen......Page 474 The WorldRenderer Class......Page 481 To Optimize or Not to Optimize......Page 485 Summary......Page 486 Before We Begin......Page 487 Vertices3: Storing 3D Positions......Page 488 An Example......Page 490 Perspective Projection: The Closer, the Bigger......Page 493 Z-buffer: Bringing Order into Chaos......Page 496 Fixing the Last Example......Page 497 Blending: There’s Nothing Behind You......Page 498 Z-buffer Precision and Z-fighting......Page 501 Defining 3D Meshes......Page 502 A Cube: Hello World in 3D......Page 503 An Example......Page 506 Matrices and Transformations Again......Page 509 The Matrix Stack......Page 510 Hierarchical Systems with the Matrix Stack......Page 512 A Simple Camera System......Page 518 Summary......Page 522 Before We Begin......Page 523 Vectors in 3D......Page 524 How Lighting Works......Page 528 Light Sources......Page 530 How OpenGL ES Calculates Lighting: Vertex Normals......Page 531 In Practice......Page 532 Mipmapping......Page 546 The First-Person or Euler Camera......Page 551 An Euler Camera Example......Page 554 A Look-At Camera......Page 560 Loading Models......Page 562 The Wavefront OBJ Format......Page 563 Implementing an OBJ Loader......Page 564 Using the OBJ Loader......Page 568 A Little Physics in 3D......Page 569 Bounding Shapes in 3D......Page 570 Bounding Sphere Overlap Testing......Page 571 GameObject3D and DynamicGameObject3D......Page 572 Summary......Page 574 Core Game Mechanics......Page 575 A Backstory and Art Style......Page 577 Screens and Transitions......Page 578 Defining the Game World......Page 579 The UI Assets......Page 580 The Game Assets......Page 582 Sound and Music......Page 584 The Assets Class......Page 585 The Settings Class......Page 588 The Main Activity......Page 589 The Main Menu Screen......Page 590 The Settings Screen......Page 593 The Shot Class......Page 596 The Ship Class......Page 597 The Invader Class......Page 599 The World Class......Page 602 The GameScreen Class......Page 608 The WorldRender Class......Page 615 Optimizations......Page 620 Summary......Page 621 A Word on Testing......Page 622 Becoming a Registered Developer......Page 623 Sign Your Game’s APK......Page 624 Putting Your Game on the Market......Page 628 Uploading Assets......Page 629 Publishing Options......Page 630 The Developer Console......Page 631 Summary......Page 633 Location Awareness......Page 634 Frameworks and Engines......Page 635 Closing Words......Page 637 Special Characters and Numbers......Page 638 A......Page 639 C......Page 642 D......Page 644 F......Page 646 G......Page 647 H......Page 650 I......Page 651 L......Page 652 M......Page 653 N......Page 655 O......Page 656 P......Page 657 R......Page 659 S......Page 660 T......Page 662 V......Page 664 W......Page 665 Z......Page 666 Cover 667 Contents at a Glance 3 Contents 670 About the Author 677 About the Technical Reviewer 678 Acknowledgments 679 Introduction 4 A Word About the Target Audience 4 How This Book Is Organized 4 Getting the Source Code 5 Android, the New Kid on the Block 6 A Brief History of Android 7 Fragmentation 8 The Role of Google 8 The Android Open Source Project 8 The Android Market 9 Challenges, Device Seeding, and Google I/O 11 Android’s Features and Architecture 12 The Kernel 13 The Runtime and Dalvik 13 System Libraries 14 The Application Framework 15 The Software Development Kit 16 The Developer Community 17 Devices, Devices, Devices! 17 Hardware 18 First Gen, Second Gen, Next Gen 19 Mobile Gaming Is Different 25 A Gaming Machine in Every Pocket 25 Always Connected 26 Casual and Hardcore 27 Big Market, Small Developers 27 Summary 28 First Steps with the Android SDK 29 Setting Up the Development Environment 29 Setting Up the JDK 30 Setting Up the Android SDK 30 Installing Eclipse 32 Installing the ADT Eclipse Plug-In 32 A Quick Tour of Eclipse 34 Hello World, Android Style 36 Creating the Project 36 Exploring the Project 37 Writing the Application Code 39 Running and Debugging Android Applications 42 Connecting a Device 42 Creating an Android Virtual Device 42 Running an Application 43 Debugging an Application 46 LogCat and DDMS 50 Using ADB 52 Summary 53 Game Development 101 55 Genres: To Each One’s Taste 55 Causal Games 56 Puzzle Games 58 Action and Arcade Games 60 Tower-Defense Games 63 Innovation 64 Game Design: The Pen Is Mightier Than the Code 64 Core Game Mechanics 65 A Story and an Art Style 67 Screens and Transitions 68 Code: The Nitty-Gritty Details 74 Application and Window Management 75 Input 76 File I/O 79 Audio 80 Graphics 84 The Game Framework 98 Summary 105 Android for Game Developers 106 Defining an Android Application: The Manifest File 107 The Element 108 The Element 108 The Element 110 The Element 112 The Element 113 The Element 115 Android Game Project Setup in Ten Easy Steps 115 Defining the Icon of Your Game 117 Android API Basics 119 Creating a Test Project 119 The Activity Life Cycle 123 Input Device Handling 130 File Handling 147 Audio Programming 153 Playing Sound Effects 153 Streaming Music 157 Basic Graphics Programming 161 Best Practices 185 Summary 186 An Android Game Development Framework 187 Plan of Attack 187 The AndroidFileIO Class 188 AndroidAudio, AndroidSound, and AndroidMusic: Crash, Bang, Boom! 189 AndroidInput and AccelerometerHandler 194 AccelerometerHandler: Which Side Is Up? 195 The Pool Class: Because Reuse is Good for You! 196 KeyboardHandler: Up, Up, Down, Down, Left, Right . . . 198 Touch Handlers 202 AndroidInput: The Great Coordinator 209 AndroidGraphics and AndroidPixmap: Double Rainbow 211 Handling Different Screen Sizes and Resolutions 211 AndroidPixmap: Pixels for the People 217 AndroidGraphics: Serving Our Drawing Needs 218 AndroidFastRenderView: Loop, Strech, Loop, Stretch 222 AndroidGame: Tying Everything Together 225 Summary 229 Mr. Nom Invades Android 230 Creating the Assets 230 Setting Up the Project 233 MrNomGame: The Main Activity 233 Assets: A Convenient Asset Store 234 Settings: Keeping Track of User Choices and High Scores 235 LoadingScreen: Fetching the Assets from Disk 237 The Main Menu Screen 238 The HelpScreen Class(es) 242 The High-Scores Screen 244 Rendering Numbers: An Excursion 244 Implementing the Screen 246 Abstracting... 248 Abstracting the World of Mr. Nom: Model, View, Controller 249 The GameScreen Class 260 Summary 268 OpenGL ES: A Gentle Introduction 269 What Is OpenGL ES and Why Should I Care? 269 The Programming Model: An Analogy 270 Projections 272 Normalized Device Space and the Viewport 275 Matrices 275 The Rendering Pipeline 276 Before We Begin 277 GLSurfaceView: Making Things Easy Since 2008 278 GLGame: Implementing the Game Interface 281 Look Mom, I Got a Red Triangle! 288 Defining the Viewport 288 Defining the Projection Matrix 289 Specifying Triangles 292 Putting It Together 296 Specifying Per Vertex Color 300 Texture Mapping: Wallpapering Made Easy 304 Texture Coordinates 304 Uploading Bitmaps 306 Texture Filtering 308 Disposing of Textures 309 A Helpful Snippet 310 Enabling Texturing 310 Putting It Together 310 A Texture Class 313 Indexed Vertices: Because Reuse Is Good for You 315 Putting It Together 316 A Vertices Class 318 Alpha Blending: I Can See Through You 321 More Primitives: Points, Lines, Strips, and Fans 325 2D Transformations: Fun with the Model-View Matrix 326 World and Model Space 326 Matrices Again 328 An First Example Using Translation 329 More Transformations 333 Optimizing for Performance 338 Measuring Frame Rate 338 The Curious Case of the Hero on Android 1.5 339 What’s Making My OpenGL ES Rendering So Slow? 340 Removing Unnecessary State Changes 341 Reducing Texture Size Means Fewer Pixels to Be Fetched 343 Reducing Calls to OpenGL ES/JNI Methods 344 The Concept of Binding Vertices 345 In Closing 348 Summary 349 2D Game Programming Tricks 350 Before We Begin 350 In the Beginning There Was the Vector 351 Working with Vectors 352 A Little Trigonometry 354 Implementing a Vector Class 356 A Simple Usage Example 359 A Little Physics in 2D 364 Newton and Euler, Best Friends Forever 364 Force and Mass 365 Playing Around, Theoretically 366 Playing Around, Practically 367 Collision Detection and Object Representation in 2D 371 Bounding Shapes 372 Constructing Bounding Shapes 374 Game Object Attributes 376 Broad-Phase and Narrow-Phase Collision Detection 377 An Elaborate Example 385 A Camera in 2D 398 The Camera2D Class 401 An Example 402 Texture Atlas: Because Sharing Is Caring 404 An Example 406 Texture Regions, Sprites, and Batches: Hiding OpenGL ES 410 The TextureRegion Class 410 The SpriteBatcher Class 411 Sprite Animation 421 The Animation Class 422 An Example 423 Summary 427 Super Jumper: A 2D OpenGL ES Game 428 Core Game Mechanics 428 A Backstory and Art Style 429 Screens and Transitions 430 Defining the Game World 431 Creating the Assets 434 The UI Elements 434 Handling Text with Bitmap Fonts 436 The Game Elements 438 Texture Atlas to the Rescue 440 Music and Sound 441 Implementing Super Jumper 443 The Assets Class 443 The Settings Class 446 The Main Activity 447 The Font Class 448 GLScreen 450 The Main Menu Screen 450 The Help Screens 453 The High-Scores Screen 456 The Simulation Classes 458 The Game Screen 474 The WorldRenderer Class 481 To Optimize or Not to Optimize 485 Summary 486 OpenGL ES: Going 3D 487 Before We Begin 487 Vertices in 3D 488 Vertices3: Storing 3D Positions 488 An Example 490 Perspective Projection: The Closer, the Bigger 493 Z-buffer: Bringing Order into Chaos 496 Fixing the Last Example 497 Blending: There’s Nothing Behind You 498 Z-buffer Precision and Z-fighting 501 Defining 3D Meshes 502 A Cube: Hello World in 3D 503 An Example 506 Matrices and Transformations Again 509 The Matrix Stack 510 Hierarchical Systems with the Matrix Stack 512 A Simple Camera System 518 Summary 522 3D Programming Tricks 523 Before We Begin 523 Vectors in 3D 524 Lighting in OpenGL ES 528 How Lighting Works 528 Light Sources 530 Materials 531 How OpenGL ES Calculates Lighting: Vertex Normals 531 In Practice 532 Some Notes on Lighting in OpenGL ES 546 Mipmapping 546 Simple Cameras 551 The First-Person or Euler Camera 551 An Euler Camera Example 554 A Look-At Camera 560 Loading Models 562 The Wavefront OBJ Format 563 Implementing an OBJ Loader 564 Using the OBJ Loader 568 Some Notes on Loading Models 569 A Little Physics in 3D 569 Collision Detection and Object Representation in 3D 570 Bounding Shapes in 3D 570 Bounding Sphere Overlap Testing 571 GameObject3D and DynamicGameObject3D 572 Summary 574 Droid Invaders: the Grand Finale 575 Core Game Mechanics 575 A Backstory and Art Style 577 Screens and Transitions 578 Defining the Game World 579 Creating the Assets 580 The UI Assets 580 The Game Assets 582 Sound and Music 584 Plan of Attack 585 The Assets Class 585 The Settings Class 588 The Main Activity 589 The Main Menu Screen 590 The Settings Screen 593 The Simulation Classes 596 The Shield Class 596 The Shot Class 596 The Ship Class 597 The Invader Class 599 The World Class 602 The GameScreen Class 608 The WorldRender Class 615 Optimizations 620 Summary 621 Publishing Your Game 622 A Word on Testing 622 Becoming a Registered Developer 623 Sign Your Game’s APK 624 Putting Your Game on the Market 628 Uploading Assets 629 Listing Details 630 Publishing Options 630 Publish! 631 Marketing 631 The Developer Console 631 Summary 633 What’s Next? 634 Getting Social 634 Location Awareness 634 Multiplayer Functionality 635 OpenGL ES 2.0 and More 635 Frameworks and Engines 635 Resources on the Web 637 Closing Words 637 Index 638 Special Characters and Numbers 638 A 639 B 642 C 642 D 644 E 646 F 646 G 647 H 650 I 651 J 652 K 652 L 652 M 653 N 655 O 656 P 657 Q 659 R 659 S 660 T 662 U 664 V 664 W 665 X, Y 666 Z 666 Apress Beginning Android Games offers everything you need to join the ranks of successful Android game developers. You'll start with game design fundamentals and programming basics, and then progress towards creating your own basic game engine and playable games. This will give you everything you need to branch out and write your own Android games. The potential user base and the wide array of available high-performance devices makes Android an attractive target for aspiring game developers. Do you have an awesome idea for the next break-through mobile gaming title? Beginning Android Games will help you kick-start your project. The book will guide you through the process of making several example games for the Android platform, and involves a wide range of topics: The fundamentals of game development The Android platform basics to apply those fundamentals in the context of making a game The design of 2D and 3D games and their successful implementation on the Android platform For those looking to learn about Android tablet game app development or want Android 4 SDK specific coverage, check out Beginning Android 4 Games Development, now available from Apress. Android, The New Kid On The Block -- First Steps With The Android Sdk -- Game Development 101 -- Android For Game Developers -- An Android Game Development Framework -- Mr. Nom Invades Android -- Opengl Es : A Gentle Introduction -- 2d Game Programming Tricks -- Super Jumper : A 2d Opengl Es Game -- Opengl Es : Going 3d -- Programming Tricks -- Droid Invaders : The Grand Finale -- Publishing Your Game -- What's Next? Mario Zechner. Includes Index.
دانلود کتاب Beginning Android Games