Learning Java by building Android games learn Java and Android from scratch by building six exciting games

Get ready for a fun-filled experience of learning Java by developing games for the Android platform Key Features Learn Java, Android, and object-oriented programming from scratch Build games including Sub Hunter, Retro Pong, Bullet Hell, Classic Snake, and a 2D Scrolling Shooter Create and design yo...

Descripción completa

Detalles Bibliográficos
Otros Autores: Horton, John, 1920- author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham ; Mumbai : Packt Publishing 2018.
Edición:Second edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630724206719
Tabla de Contenidos:
  • Cover
  • Copyright
  • Contributors
  • Table of Contents
  • Preface
  • Chapter 1: Java, Android and Game Development
  • What's new in the second edition?
  • Why Java, Android and Games?
  • Java: The first stumbling block
  • The games you will build
  • Sub' Hunter
  • Pong
  • Bullet Hell
  • Snake Clone
  • Scrolling Shooter
  • Open-World Platformer
  • How Java and Android work
  • Setting up Android Studio
  • Final step
  • Starting the first project: Sub' Hunter
  • Extra step 1
  • Extra step 2
  • Android Studio and our project - A very brief guided tour
  • The Project panel
  • The Editor window
  • Locking the game to full-screen and landscape orientation
  • 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
  • Actions flowchart/diagram
  • Code comments
  • Mapping out our code using comments
  • Introduction to Java methods
  • Overriding methods
  • Structuring Sub' Hunter with methods
  • Introduction to Object Oriented Programming
  • Classes and Objects
  • The important thing about OOP, Classes, and Objects
  • Classes, objects, and instances
  • Final word on OOP, Classes, and Objects - for now
  • Using Java packages
  • Adding classes by importing packages
  • Linking up our methods
  • Summary
  • Chapter 3: Variables, Operators and Expressions
  • Handling syntax and jargon
  • Java Variables
  • Different types of variables
  • Primitive types
  • Reference variables
  • How to use variables
  • Declaring variables
  • Initializing variables
  • Making variables useful with operators
  • Most used operators in this book
  • Casting
  • Concatenation
  • 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: Initialising the variables
  • Errors, warnings, and bugs
  • Printing Debugging Information
  • Testing the game
  • Summary
  • Chapter 4: Structuring Code with Java Methods
  • Methods
  • Methods revisited and explained further
  • The method signature
  • Modifier
  • Return type
  • A closer look at method names
  • Parameters
  • Doing things in the method body
  • Method Overloading by Example
  • Creating a new project
  • Coding the method overloading mini-app
  • Running the method overloading mini-app
  • Scope: Methods and Variables
  • Revisiting the code and methods we have used already
  • Generating random numbers to deploy a sub
  • The Random class and the nextInt method
  • Adding Random based code to newGame
  • Testing the game
  • Summary
  • Chapter 5: The Android Canvas Class - Drawing to the Screen
  • Understanding the Canvas class
  • Getting started drawing with Bitmap, Canvas, and ImageView
  • Canvas and Bitmap
  • Paint
  • ImageView and Activity
  • Canvas, Bitmap, Paint and ImageView quick summary
  • Using the Canvas class
  • Preparing the objects of classes
  • Initializing the objects
  • Setting the Activity content
  • Canvas Demo app
  • Creating a new project
  • Coding the Canvas demo app
  • Drawing on the screen
  • Android Coordinate system
  • Plotting and drawing
  • Drawing the Sub' Hunter graphics and text
  • Preparing to draw
  • Initializing a Canvas, Paint, ImageView, and Bitmap
  • Drawing some grid lines
  • Drawing the HUD
  • Upgrading the printDebuggingText method
  • Summary
  • Chapter 6: Repeating Blocks of Code with Loops
  • Decisions, decisions
  • Keeping things tidy
  • More operators
  • Loops
  • While loops
  • Breaking out of a loop
  • Do while loops
  • For loops
  • Nested loops
  • Using for loops to draw the Sub' Hunter grid
  • Summary.
  • 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
  • Continue...
  • Making sense of the 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
  • Summary
  • Chapter 8: Object-Oriented Programming
  • Basic Object-Oriented Programming
  • Humans learn by doing
  • Introducing OOP
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Why 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
  • Remember that encapsulation thing?
  • Controlling class use with access modifiers
  • Class access in a nutshell
  • Controlling variable use with access modifiers
  • Variable access summary
  • Methods have access modifiers too
  • Method access summary
  • 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
  • Summary
  • Chapter 9: The Game Engine, Threads, and The Game Loop
  • Coding the PongActivity class
  • Coding the PongGame class
  • Coding the PongGame class
  • Adding the member variables
  • Coding the PongGame constructor
  • Coding the startNewGame method
  • Coding the draw method
  • Adding the printDebuggingText method.
  • Understanding the draw method and the SurfaceView class
  • The game loop
  • 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
  • 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
  • Running the game
  • Summary
  • 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
  • Running the game
  • Summary
  • Chapter 11: Collisions, Sound Effects and Supporting Different Versions of Android
  • Handling collisions
  • Collision detection options
  • Rectangle intersection
  • Radius overlapping
  • Crossing number algorithm
  • Optimizations
  • Multiple hitboxes
  • Neighbour checking
  • 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
  • Java Method chaining explained
  • Back to initializing SoundPool (the new way)
  • Initializing SoundPool the old way
  • Loading sound files into memory
  • Playing a sound
  • Stopping a sound
  • 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
  • Summary
  • Chapter 12: Handling Lots of Data with Arrays
  • Planning the project
  • Starting the project
  • Change the AndroidManifest.xml to lock in landscape and full-screen
  • Creating the classes
  • Reusing the Pong engine
  • Coding the BulletHellActivity
  • Coding the BulletHellGame class
  • Coding the member variables
  • Coding the BulletHellGame constructor
  • Coding the BulletHellGame methods
  • Coding draw and onTouchEvent
  • Coding pause, resume, and printDebuggingText
  • Testing the Bullet Hell engine
  • Coding the Bullet class
  • Spawning a bullet
  • 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
  • Running the game
  • Summary
  • Chapter 13: Bitmap Graphics and Measuring Time
  • The Bob (player's) class
  • Adding the Bob graphic to the project
  • Coding the Bob class
  • Using the Bob class
  • Adding Bob to the collision detection
  • Drawing Bob to the screen
  • Adding the sound effects
  • Activating Bob's teleport
  • Coding the printDebuggingText method
  • Coding the spawnBullet method (again)
  • Coding the startGame method
  • Running the game
  • Summary
  • Chapter 14: The Stack, the Heap, and the Garbage Collector
  • Managing and understanding memory
  • Variables revisited
  • The stack and the heap
  • A quick break to throw out the trash
  • Stack and Heap quick summary
  • Introduction to the Snake game
  • Looking ahead to the Snake game
  • Getting started with the Snake game
  • Make full screen and landscape.
  • Adding some empty classes.