My Account Log in

3 options

Learning Java by building Android games : learn Java and Android from scratch by building five exciting games / John Horton.

EBSCOhost Academic eBook Collection (North America) Available online

View online

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Horton, John, author.
Language:
English
Subjects (All):
Computer games--Development.
Computer games.
Video games--Programming.
Video games.
Physical Description:
1 online resource (xx, 660 pages) : illustrations
Edition:
3rd ed.
Distribution:
London : Bloomsbury Publishing (UK), 2024.
Place of Publication:
Birmingham : Packt Publishing, 2021.
System Details:
text file HTML
Summary:
Android is one of the most popular mobile operating systems today. It uses the most popular programming language, Java, as one of the primary languages for building apps of all types. Unlike most other Android books, this book doesn’t assume that you have any prior knowledge of Java programming, instead helps you get started with building Android games as a beginner. This new, improved, and updated third edition of Learning Java by Building Android Games helps you to build Android games from scratch. Once you've got to grips with the fundamentals, the difficulty level increases steadily as you explore key Java topics, such as variables, loops, methods, object-oriented programming (OOP), and design patterns while working with up-to-date code and supporting examples. At each stage, you'll be able to test your understanding by implementing the concepts that you’ve learned to develop a game. Toward the end, you’ll build games such as Sub Hunter, Retro Pong, Bullet Hell, Classic Snake, and Scrolling Shooter. By the end of this Java book, you'll not only have a solid understanding of Java and Android basics but will also have developed five cool games for the Android platform.
Contents:
Cover
Title Page
Copyright
Contributors
Table of Contents
Preface
Chapter 1: Java, Android, and Game Development
Technical requirements
Windows
Mac
Linux
What's new in the third edition?
Why Java, Android, and games?
The Java stumbling block
The games we will build
Sub' Hunter
Pong
Bullet Hell
Snake Clone
Scrolling Shooter
How Java and Android work together
Run that by me again - what, exactly, is Android?
Setting up Android Studio
Starting the first project - Sub' Hunter
Android Studio and our project - a very brief guided tour
The Project panel
The Editor window
Refactoring MainActivity to SubHunter
Locking the game to full screen and landscape orientation
Amending the code to use the full screen and the best Android class
Deploying the game so far
Running the game on an Android emulator
Running the game on a real device
Summary
Chapter 2: Java - First Contact
Planning the Sub' Hunter game
The actions flowchart/diagram
Mapping out our code using comments
Introducing Java methods
Overriding methods
Structuring Sub' Hunter with methods
Introducing OOP
Classes and objects
Classes, objects, and instances
A final word on OOP, classes, and objects - for now
Using Java packages
Adding classes by importing packages
Linking up our methods
Chapter 3: Variables, Operators, and Expressions
Handling syntax and jargon
Java variables
Different types of variables
How to use variables
Declaring variables
Initializing variables
Making variables useful with operators
Most used operators in this book
Declaring and initializing the Sub' Hunter variables
Planning the variables
Declaring the variables
Handling different screen sizes and resolutions.
Handling different screen resolutions, part 1 - initializing the variables
Errors, warnings, and bugs
Printing debugging information
Testing the game
Chapter 4: Structuring Code with Java Methods
Methods
Methods revisited and explained further
Method overloading by example
Creating a new project
Coding the method overloading mini-app
Running the method overloading mini-app
Scope - methods and variables
Method recursion
Revisiting the code and methods we have used already
Generating random numbers to deploy a sub
The Random class and the nextInt method
Chapter 5: The Android Canvas Class - Drawing to the Screen
Understanding the Canvas class
Getting started drawing with Bitmap, Canvas, and ImageView
Using the Canvas class
Preparing the objects of classes
Initializing the objects
Setting the Activity content
Canvas Demo app
Android coordinate system
Plotting and drawing
Drawing the Sub' Hunter graphics and text
Preparing to draw
Initializing Canvas, Paint, ImageView, and Bitmap objects
Drawing some gridlines
Drawing the HUD
Upgrading the printDebuggingText method
Chapter 6: Repeating Blocks of Code with Loops
Making decisions with Java
Keeping things tidy
More operators
Java loops
While loops
Do while loops
For loops
Using for loops to draw the Sub' Hunter grid
Chapter 7: Making Decisions with Java If, Else, and Switch
If they come over the bridge, shoot them
Else do this instead
Switching to make decisions
Switch example
Combining different control flow blocks
Using the continue keyword
Making sense of screen touches
Coding the onTouchEvent method
Final tasks
Coding the takeShot method.
Explaining the takeShot method
Coding the boom method
Drawing the shot on the grid
Running the game
Chapter 8: Object-Oriented Programming
Basic object-oriented programming
Humans learn by doing
Why do we do it like this?
Class recap
Looking at the code for a class
Class implementation
Declaring, initializing, and using an object of the class
Basic classes mini-app
Creating your first class
More things we can do with our first class
Encapsulation
Controlling class use with access modifiers
Controlling variable use with access modifiers
Methods have access modifiers too
Accessing private variables with getters and setters
Setting up our objects with constructors
Using "this
Static methods
Encapsulation and static methods mini-app
OOP and inheritance
Inheritance mini-app
Polymorphism
Abstract classes
Interfaces
Starting the Pong game
Planning the Pong game
Setting up the Pong project
Refactoring MainActivity to PongActivity
Locking the game to fullscreen and landscape orientation
Chapter 9: The Game Engine, Threads, and the Game Loop
Coding the PongActivity class
Coding the PongGame class
Thinking ahead about the PongGame class
Adding the member variables
Coding the PongGame constructor
Coding the startNewGame method
Coding the draw method
Understanding the draw method and the SurfaceView class
The game loop
Getting familiar with threads
Problems with threads
Java try-catch exception handling
Implementing the game loop with a thread
Implementing Runnable and providing the run method
Coding the thread
Starting and stopping the thread
The activity lifecycle.
A simplified explanation of the Android lifecycle
Lifecycle phases - what we need to know
Lifecycle phases - what we need to do
Using the activity lifecycle to start and stop the thread
Coding the run method
Chapter 10: Coding the Bat and Ball
The Ball class
Communicating with the game engine
Representing rectangles and squares with RectF
Coding the variables
Coding the Ball constructor
Coding the RectF getter method
Coding the Ball update method
Coding the Ball helper methods
Coding a realistic-ish bounce
Using the Ball class
The Bat class
Coding the Bat variables
Coding the Bat constructor
Coding the Bat helper methods
Coding the Bat's update method
Using the Bat class
Coding the Bat input handling
Chapter 11: Collisions, Sound Effects, and Supporting Different Versions of Android
Handling collisions
Collision detection options
Optimizing the detection methods
Best options for Pong
The RectF intersects method
Handling different versions of Android
Detecting the current Android version
The SoundPool class
Initializing SoundPool the new way
Generating sound effects
Adding sound to the Pong game
Adding the sound variables
Initializing the SoundPool
Coding the collision detection and playing sounds
The bat and the ball
The four walls
Playing the game
Chapter 12: Handling Lots of Data with Arrays
Planning the project
Starting the project
Refactoring MainActivity to BulletHellActivity
Locking the game to full-screen and landscape orientation
Creating the classes
Reusing the Pong engine
Coding the BulletHellActivity class
Coding the BulletHellGame class.
Testing the Bullet Hell engine
Coding the Bullet class
Spawning a bullet
Getting started with Java arrays
Arrays are objects
Simple array example mini-app
Getting dynamic with arrays
Dynamic array example
Entering the nth dimension with arrays
Multidimensional array mini app
Array out of bounds exceptions
Spawning an array of bullets
Chapter 13: Bitmap Graphics and Measuring Time
The Bob (player's) class
Add the Bob graphic to the project
Coding the Bob class
Using the Bob class
Coding the spawnBullet method (again)
The Android Studio Profiler tool
Chapter 14: Java Collections, the Stack, the Heap, and the Garbage Collector
Managing and understanding memory
Variables revisited
Introduction to the Snake game
Looking ahead to the Snake game
Getting started with the Snake game
Refactoring MainActivity to SnakeActivity
Adding some empty classes
Coding SnakeActivity
Adding the sound effects
Coding the game engine
Coding the members
Coding the constructor
Coding the newGame method
Coding the updateRequired method
Coding the update method
Coding the OnTouchEvent method
Coding pause and resume
Chapter 15: Android Localization - Hola!
Making the Snake game Spanish, English, or German
Adding Spanish support
Adding German support
Adding the string resources
Amending the Java code
Running the game in German or Spanish
Chapter 16: Collections and Enumerations
Adding the graphics
Coding the Apple class
The Apple constructor
Using the Apple class
Using arrays in the Snake game.
Understanding ArrayList class.
ISBN:
9781800563124
1800563124
OCLC:
1244623247

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account