1. Trang chủ
  2. » Giáo án - Bài giảng

pro android games trường đại học công nghiệp thực phẩm tp hồ chí minh

7 10 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 866,79 KB

Nội dung

This book also shows you how to port other classic freeware/shareware games like Doom and Wolfenstein™ 3D from C using the Java Native Interface (JNI) for Android.. This book is al[r]

(1)

Silv a Andr oid G ames Pro Companion eBook Available

COMPANION eBOOK SEE LAST PAGE FOR DETAILS ON $10 eBOOK VERSION

US $39.99 Shelve in Mobile Computing User level: Intermediate-Advanced www.apress.com SOURCE CODE ONLINE

BOOKS FOR PROFESSIONALS BY PROFESSIONALS®

ISBN 978-1-4302-2647-5

9 781430 226475

5 39 9

this print for content only—size & color not accurate

CYAN

MAGENTA YELLOW BLACK PANTONE 123 C

SPOT MATTE

Do you remember landmark games like Wolfenstein™ 3D,Doom, and As-teroids™? Well, here’s an exciting opportunity to build and/or port these games to one of the hottest mobile and netbook platforms today: Google’s Android Pro Android Games teaches you how to build cool games like Space Blaster and the classic Asteroids™ from scratch on the latest Android plat-form This book also shows you how to port other classic freeware/shareware games like Doom and Wolfenstein™ 3D from C using the Java Native Interface (JNI) for Android

This book is all about a unique perspective in Android game development: a well-balanced, powerful combination of pure pure Java and hybrid game development, mixing Java and C I believe that in the world of gaming, per-formance is critical, and that by combining the elegant object-oriented fea-tures of Java and the raw power of C, there is no limit to the types of games that you can build for the platform With actionable real-world source code in hand, this book dives you right into Games development on Android In this book you’ll learn how to:

setup a Linux system for hybrid game compilation

combine Java and C code in an elegant manner by building a simple Java application on top of a native library

tackle pure Java gaming with two practical games: Space Blaster and the arcade classic Asteroids™

mix OpenGL API calls in Java and C for high performance 3D graphics using the 3D cubes sample by Google

bring two of the greatest PC 3D shooters to the Android platform:

Wolfenstein™ 3D and Doom using Java and C

By the end of this book, you will have learned how easy it is to bring native PC games alive on the Android platform, which is now growing in popularity at an amazing rate Pro Android Games is the ultimate helper tool for your hybrid game development needs, so you’ll be developing games quickly on

Google’s Android Pro

Android Games

Trim: 7.5 x 9.25 spine = 0.875" 320 page count

Create and port cool games like Space Blaster, classic Asteroids™,

Doom and Wolfenstein™ 3D using Android

(2)

Pro Android Games

■ ■ ■

(3)

Pro Android Games

Copyright © 2009 by Vladimir Silva

All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher

ISBN-13 (pbk): 978-1-4302-2647-5 ISBN-13 (electronic): 978-1-4302-2648-2

Printed and bound in the United States of America

Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark

President and Publisher: Paul Manning Lead Editor: Steve Anglin, Douglas Pundick

Technical Reviewer: Kunal Mittal and Vikram Goyal

Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic

Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Fran Parnell

Copy Editors: Heather Lang and Marilyn Smith Formatter: Nancy Wright

Compositor: LaurelTech

Indexer: BIM Indexing and Proofreading Services Artist: April Milne

Cover Designer: Anna Ishchenko

Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax 201-348-4505, e-mail

orders-ny@springer-sbm.com, or visit http://www.springeronline.com

For information on translations, please e-mail info@apress.com, or visit http://www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales The information in this book is distributed on an “as is” basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work

(4)

iii

Contents at a Glance

Contents iv

About the Author x

About the Technical Reviewer xi

Introduction xii

Chapter 1: Welcome to Android Gaming

Chapter 2: Compiling Native Code in Android 27

Chapter 3: Building a Java Game from Scratch 55

Chapter 4: Java Games Continued: Fun with Polygons 81

Chapter 5: Hybrid 3D Graphics with OpenGL and JNI 117

Chapter 6: 3D Shooters Episode I: Wolfenstein 3D for Android 161

Chapter 7: 3D Shooters Episode II: Doom for Android 221

Appendix: Deployment and Compilation Tips 271

(5)

■ CONTENTS

iv

Contents

Contents at a Glance iii

About the Author x

About the Technical Reviewer xi

Introduction xii

Chapter 1: Welcome to Android Gaming

What Skills Do You Need?

A Solid Foundation of Android

A Basic Knowledge of Linux and Shell Scripting

What Software Tools Do You Need?

Setting Up Your Machine

Getting the Android Source

Extracting Native Android Libraries

Installing the GNU Toolchain for ARM Processors

Writing Custom Compilation Scripts 11

Setting Up Your Development Environment 18

You Have Taken the First Step 26

Chapter 2: Compiling Native Code in Android 27

Your First Native Android App 27

(6)

■ INDEX

297 Strings.xml file, 98

struct XColor class, 262

Surface View class, for GL Cubes sample, 124—127

surfaceChanged( ) method, 125 surfaceCreated( ) method, 125 surfaceDestroyed( ) method, 125 SurfaceHolder.addCallback( ) class, 124 SurfaceHolder.Callback callback, 124 swap buffers, 138

SYS_DEV variable, 15 SYS_ROOT variable, 15 /system/bin/linker file, 49 /system/lib folder, 7, 51 System.load( ) method, 34

System.loadLibrary( ) method, 216

T

testing, Java game, 79—80 testlib target, 45

testlib.c file, 33

text message, miscellaneous, 166 Timertask:run( ) method, 66 tnt.wad file, 242

Toggle Screen option, 172 TOOLCHAIN_ROOT variable, 15 Tools class, 98

Tools.java class, 58

touch events, 76—78, 110—113, 174 touch handlers, 227

U

Ubuntu Linux VMware appliance, UI widget, 236

up class variable, 110

updateBounds( ) method, 86 updateShip( ) method, 106

V

-v argument, 272 va_end command, 45 va_list command, 45 va_start command, 45

-validity <valdays> argument, 272

variable-arguments function in C, defining, 44—45

verbose argument, 273 vgadict.wl1 file, 176 vgagraph.wl1 file, 176 vgahead.wl1 file, 176

vi_null.c file, 203, 206, 207, 208 video buffer update callback, 206 VL_SetPalette ( ) function, 209 VL_Startup( ) method, 206, 207, 208 VMware Linux image, 276

VMware Player software,

VMware Virtual Appliance Marketplace, void drawFrame(GL10 gl) method, 130 void initialize( ) method, 99

void jni_fatal_error( ) method, 251 void jni_printf( ) function, 42 void jni_send_pixels( ) method, 250

void jni_set_music_volume ( ) method, 251 void jni_start_music ( ) method, 251 void jni_start_sound ( ) method, 251 void jni_stop_music ( ) method, 251 void onDraw( ) method, 99

void sizeChanged( ) method, 131 void startSound( ) method, 193 void surfaceCreated( ) method, 132 void updatePhysics( ) method, 100 vswap.wl1 file, 176

VW_UpdateScreen( ) method, 208—209

W

Wall flag, 264

WebDownload.java class, 227 width argument, 235, 242 wolf game ID, 176

wolf_jni_Natives.h file, 203

wolf.audio.SoundNames class, 191 Wolfd3D.apk argument, 273 Wolfenstein 3D game

coding native layer, 203—213 initializing game loop, 204

making C to Java callbacks, 206—208, 206—213, 208—209, 211—213 compiling libraries with Android NDK,

(7)

■ INDEX

298

compiling native library generating JNI headers, 215 writing Makefile, 213—214 game architecture, 165—167 Java classes for

creating game loop, 175—176 creating main menu, 172

creating movement controller, 182— 189

creating movement controller handlers, 180—181

creating sound and music handlers, 179

handling key and touch events, 174 making native callbacks, 177—178 native interface class (Natives.java

class), 200—202 sound classes, 190—197 WolfLauncher class, 168—172 testing in emulator, 215—217

tools, 161—162

wolf.jni.Natives method, 191

wolf.jni.Natives.OnStartMusic( ) method, 211

wolf.jni.Natives.OnStartSound( ) method, 191, 211

WolfLauncher activity, 165 WolfLauncher class, 167, 168—172 wolfsw game ID, 176

WolfTools class, 168

wolf.util.ScanCodes class, 200 Workstation software,

X, Y, Z

x argument, 235 XImage class, 261 XML parser (EXPAT), 15 y argument, 235

http://www.springeronline.com http://www.apress.com b page at http://www.apress.com/info/bulksales

Ngày đăng: 01/04/2021, 16:15

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w