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

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, ins...

Descripción completa

Detalles Bibliográficos
Otros Autores: Horton, John, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham : Packt Publishing 2021.
Edición:3rd ed
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009631709806719
Tabla de Contenidos:
  • 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
  • Summary
  • 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
  • Summary
  • 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
  • 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
  • Using the Canvas class
  • Preparing the objects of classes
  • Initializing the objects
  • Setting the Activity content
  • Canvas Demo app
  • Creating a new project
  • 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
  • Summary
  • 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
  • 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
  • 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
  • Summary
  • Chapter 8: Object-Oriented Programming
  • Basic object-oriented programming
  • Humans learn by doing
  • Introducing OOP
  • 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
  • Amending the code to use the full screen and the best Android class
  • Summary
  • 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
  • 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
  • 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
  • Summary
  • 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
  • Amending the code to use the full screen and the best Android class
  • 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
  • Running the game
  • Summary
  • 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)
  • Running the game
  • The Android Studio Profiler tool
  • Summary
  • 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
  • Locking the game to fullscreen and landscape orientation
  • 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 run method
  • Coding the updateRequired method
  • Coding the update method
  • Coding the draw method
  • Coding the OnTouchEvent method
  • Coding pause and resume
  • Running the game
  • Summary
  • 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
  • Summary
  • Chapter 16: Collections and Enumerations
  • Adding the graphics
  • Coding the Apple class
  • The Apple constructor
  • Using the Apple class
  • Running the game
  • Using arrays in the Snake game.
  • Understanding ArrayList class.