Introduction to Java Through Game Development: Learn Java Programming Skills by Working with Video Games 1st Edition Victor G. Brusca pdf download
Introduction to Java Through Game Development: Learn Java Programming Skills by Working with Video Games 1st Edition Victor G. Brusca pdf download
https://ebookmeta.com/product/introduction-to-video-game-engine-
development-learn-to-design-implement-and-use-a-cross-
platform-2d-game-engine-1st-edition-victor-g-brusca/
https://ebookmeta.com/product/advanced-unity-game-development-
build-professional-games-with-unity-c-and-visual-studio-victor-g-
brusca/
https://ebookmeta.com/product/advanced-unity-game-development-
build-professional-games-with-unity-c-and-visual-studio-1st-
edition-victor-g-brusca-2/
https://ebookmeta.com/product/cisco-software-defined-access-
networking-technology-1st-edition-srilatha-vemula-jason-gooley-
roddie-hasan/
My Name Is Iris A Novel 1st Edition Brando Skyhorse
https://ebookmeta.com/product/my-name-is-iris-a-novel-1st-
edition-brando-skyhorse/
https://ebookmeta.com/product/cuet-ug-section-ii-domain-specific-
subject-economics-business-economics-entrance-test-guide-2023rd-
edition-rph-editorial-board/
https://ebookmeta.com/product/the-collectin-protein-family-and-
its-multiple-biological-activities-1st-edition-uday-kishore/
https://ebookmeta.com/product/my-lonely-shifter-match-love-bites-
dating-agency-1-1st-edition-skye-alder/
https://ebookmeta.com/product/agile-methodologies-in-depth-1st-
edition-sudipta-malakar/
Quantum Mechanics for Electrical Engineers 1st Edition
Isaak D Mayergoyz
https://ebookmeta.com/product/quantum-mechanics-for-electrical-
engineers-1st-edition-isaak-d-mayergoyz/
Introduction to Java
Through Game
Development
Learn Java Programming Skills by
Working with Video Games
Victor G. Brusca
Introduction to Java Through Game Development: Learn Java Programming Skills
by Working with Video Games
Victor G. Brusca
Edison, NJ, USA
Introduction����������������������������������������������������������������������������������������������������������� xiii
Chapter 1: Introduction�������������������������������������������������������������������������������������������� 1
About This Text������������������������������������������������������������������������������������������������������������������������������ 1
Notes on Formatting��������������������������������������������������������������������������������������������������������������������� 2
Notes on Conventions������������������������������������������������������������������������������������������������������������������� 4
Objectives������������������������������������������������������������������������������������������������������������������������������������� 6
Java Fundamental Topics�������������������������������������������������������������������������������������������������������� 6
Java Advanced Topics�������������������������������������������������������������������������������������������������������������� 7
Game Development Topics������������������������������������������������������������������������������������������������������ 8
Setting Up Your Environment�������������������������������������������������������������������������������������������������������� 9
Getting the Game Projects Setup������������������������������������������������������������������������������������������ 13
Checking Out the Games������������������������������������������������������������������������������������������������������������� 20
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 26
What We Covered������������������������������������������������������������������������������������������������������������������ 27
v
Table of Contents
Chapter 3: Variables����������������������������������������������������������������������������������������������� 43
Data Types����������������������������������������������������������������������������������������������������������������������������������� 43
Basic Data Types������������������������������������������������������������������������������������������������������������������� 44
Using Basic Data Types��������������������������������������������������������������������������������������������������������� 46
Challenge: Basic Data Types�������������������������������������������������������������������������������������������������� 49
Challenge Solution����������������������������������������������������������������������������������������������������������������� 51
Advanced Data Types������������������������������������������������������������������������������������������������������������������ 52
The var Keyword and Dynamic Typing����������������������������������������������������������������������������������� 52
Arrays������������������������������������������������������������������������������������������������������������������������������������ 54
Using Arrays�������������������������������������������������������������������������������������������������������������������������� 56
Challenge: Arrays������������������������������������������������������������������������������������������������������������������� 63
Challenge Solution����������������������������������������������������������������������������������������������������������������� 65
Lists��������������������������������������������������������������������������������������������������������������������������������������� 66
Using Lists����������������������������������������������������������������������������������������������������������������������������� 69
Challenge: ArrayLists������������������������������������������������������������������������������������������������������������� 72
Challenge Solution����������������������������������������������������������������������������������������������������������������� 73
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 73
What We Covered������������������������������������������������������������������������������������������������������������������ 74
vi
Table of Contents
vii
Table of Contents
Stacks��������������������������������������������������������������������������������������������������������������������������������������� 122
Declaring Stacks����������������������������������������������������������������������������������������������������������������� 123
Using Stacks������������������������������������������������������������������������������������������������������������������������ 124
Queues�������������������������������������������������������������������������������������������������������������������������������������� 128
Parameterized Types and Data Structures�������������������������������������������������������������������������������� 130
Challenge: Stacks��������������������������������������������������������������������������������������������������������������������� 131
Challenge Solution�������������������������������������������������������������������������������������������������������������������� 132
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 134
What We Covered���������������������������������������������������������������������������������������������������������������� 134
viii
Table of Contents
ix
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 243
x
About the Author
Victor Brusca is an experienced software developer specializing in building cross-
platform applications and APIs. He regards himself as a self-starter with a keen eye for
detail, an obsessive protection of systems/data, and a desire to write well-documented,
well-encapsulated code. With over 14 years' software development experience, he has
been involved in game and game engine projects on J2ME, T-Mobile SideKick, WebOS,
Windows Phone, Xbox 360, Android, iOS, and web platforms.
xi
Introduction
In this book, “Learning Java Through Game Development,” you will learn the
fundamentals of the Java programming language through a detailed review of the
language’s features, including data structures and OOP, reenforced by coding challenges
throughout the text. Get started today by downloading the book’s projects and source
code here: http://github.com/apress/introduction-to-java-through-gamedev/
Using the associated game projects along with topic specific coding challenges you
will gain experience and knowledge working with the Java programming language, the
NetBeans IDE, a 2D game engine, and three different 2D games! This introductory text
will give you a solid foundation of experience in Java and video game programming for
you to build on.
xiii
CHAPTER 1
Introduction
In this book, Introduction to Java Through Game Development, you will learn the
fundamentals of the Java programming language through hands-on game development
tasks. Through the completion of topic-specific coding challenges, focused on a
particular aspect of one of the three games included with the text, you will gain
experience and knowledge working with the Java programming language, the NetBeans
IDE, a 2D game engine, and three different 2D games. And without further ado, allow me
to provide some details about this book starting with information on the structure and
conventions used in this text.
• Pong Clone
• Memory Match
• Dungeon Trap
Each game is written in a proprietary 2D game engine included with the text. The
engine is open source and can be accessed here if you want to take a look at the code
involved:
github.com/apress/intro-java-through-game-dev
The source code associated with this game project can be found in the same repo.
1
© Victor G. Brusca 2023
V. G. Brusca, Introduction to Java Through Game Development, https://doi.org/10.1007/978-1-4842-8951-8_1
Chapter 1 Introduction
Each project includes a fully functioning version of the game with full source code as
well as coding challenges. As you progress through this text, you will be given challenges that
apply certain Java programming language knowledge to the game project at hand. There will
be specific copies of the game project preconfigured for the current chapter’s challenge.
Generally speaking, this text will not require you to be connected to the Internet for
prolonged periods of time outside of downloading a copy of this text and its associated
code and programs. You will need only a small amount of computing resources to run
the associated software and games. You should have a computer with resources at least
equal to the following minimum requirements:
Any relatively modern computer should be able to handle the workload without
a sweat. When working with any modern programming language, a decision must be
made as to how to code in that language. Oftentimes, you can just use Notepad and a few
command-line tools to write and build programs. In our case, however, we would like to
use more advanced tools, so we’ll require the use of an IDE.
An IDE is an Integrated Development Environment and is a fairly complex program
whose job it is to make some of the tasks of the software developer easier so they can
take on larger projects and focus on the coding at hand. Games are complex programs
that often have a lot of moving parts, literally. As such, we stand to benefit greatly by
using an IDE, so we chose the NetBeans IDE for our purposes.
Each example game in this text is written for a simple Java 2D game engine. The
experience gained from working through the coding challenges in this text will go a long
way to giving the reader a solid foundation to create some of their own 2D games in Java
using the included game engine.
Notes on Formatting
Throughout the text there are some consistent formatting patterns I would like to
discuss. First off, each chapter follows a similar, general structure, listed as follows:
• Chapter Introduction
• Topic #1
2
Chapter 1 Introduction
• Topic #2
• Challenge Description
• Challenge Solution
• Chapter Conclusion
The “Topic” and “Challenge” sections are repeated as necessary to touch upon all
the chapter’s topics and will sometimes vary slightly in their construction. In general,
though, each chapter will have a structure close to that outlined previously. In addition
to the text, each chapter will have a namespace entry in the associated game project for
each challenge in that chapter.
There will be more on this to come. For now, the main takeaway is that each
challenge will have a little sandbox copy of the game for you to work with and a
completed example to look at. The structure of the code challenges themselves is present
in the chapter outline, but in any case, let’s discuss them a little bit before we move on.
• Challenge Description
• Challenge Solution
The general structure of the coding challenges presented in the text is listed
previously. The challenge will be presented with a detailed description and a clue,
if any is provided. Of course, there will be variations in the sections and section
titles. The challenges themselves are designed to apply the knowledge learned in the
current programming language topic. Challenges can vary but will always be a small
development task using the Java programming language topic at hand.
Following every challenge section will be an explanation of the correct way to solve
the challenge including screenshots or other resources to demonstrate the proper
functionality. We’ll also indicate clearly where to look for the completed challenge’s
code, so you don’t have to worry about not understanding how a problem was solved.
That sums up the general structure of the chapters and challenge sections of the
text. The overall cadence of the text starts with the fundamental aspects of the Java
programming language and works toward more advanced topics and language features.
3
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Warwick,
Leamington & Kenilworth: A Sketch-Book
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English