Java Game Development with LibGDX (eBook)
XIX, 433 Seiten
Apress (Verlag)
978-1-4842-3324-5 (ISBN)
- Create 12 complete video game projects
- Master advanced Java programming concepts, including data structures, encapsulation, inheritance, and algorithms, in the context of game development
- Gain practical experience with game design topics, including user interface design, gameplay balancing, and randomized content
- Integrate third-party components into projects, such as particle effects, tilemaps, and gamepad controllers
Lee Stemkoski is a professor of computer science and mathematics. He earned his Ph.D. from Dartmouth College in 2006. He has been teaching at the college level since then, with an emphasis on Java programming, computer graphics, and video game development for the past eight years. He has refined the set of topics covered and the progression of material in this book based on years of experience helping students overcome their difficulties with these particular topics. He has authored another game development book, Game Development with Construct 2, in addition to many scholarly articles and game development tutorials.
Learn to design and create video games using the Java programming language and the LibGDX software library. Working through the examples in this book, you will create 12 game prototypes in a variety of popular genres, from collection-based and shoot-em-up arcade games to side-scrolling platformers and sword-fighting adventure games. With the flexibility provided by LibGDX, specialized genres such as card games, rhythm games, and visual novels are also covered in this book. Major updates in this edition include chapters covering advanced topics such as alternative sources of user input, procedural content generation, and advanced graphics. Appendices containing examples for game design documentation and a complete JavaDoc style listing of the extension classes developed in the book have also been added.What You Will LearnCreate 12 complete video game projectsMaster advanced Javaprogramming concepts, including data structures, encapsulation, inheritance, and algorithms, in the context of game developmentGain practical experience with game design topics, including user interface design, gameplay balancing, and randomized contentIntegrate third-party components into projects, such as particle effects, tilemaps, and gamepad controllersWho This Book Is ForThe target audience has a desire to make video games, and an introductory level knowledge of basic Java programming. In particular, the reader need only be familiar with: variables, conditional statements, loops, and be able to write methods to accomplish simple tasks and classes to store related data.
Lee Stemkoski is a professor of computer science and mathematics. He earned his Ph.D. from Dartmouth College in 2006. He has been teaching at the college level since then, with an emphasis on Java programming, computer graphics, and video game development for the past eight years. He has refined the set of topics covered and the progression of material in this book based on years of experience helping students overcome their difficulties with these particular topics. He has authored another game development book, Game Development with Construct 2, in addition to many scholarly articles and game development tutorials.
Part I: Fundamental Concepts The first part of the book explains basic material that will be needed throughout the rest of the book: rendering graphics and animations, processing user input (continuous and discrete), basic physics (movement and collision detection), displaying text, and playing audio (sound effects and background music).1. Getting started with Java and LibGDXThis chapter explains how to set up a Java development environment (BlueJ), which is chosen for simplicity and user-friendliness. The standard first program (which prints “Hello, World!” to the text console) is given. Next, instructions for setting up the LibGDX library are given, and a visual “Hello, World!” program is demonstrated (which displays an image of the world in a window). Finally, the benefits of using LibGDX for game development are explained in some detail. 1.1 Choosing a development environment 1.2 Setting up BlueJ 1.3 A “Hello World” program 1.4 Advantages to using LibGDX 2. The LibGDX FrameworkThis chapter presents the minimal code needed to create a basic game: rendering textures, detecting user input, and collision detection. The game Starfish Collector is introduced, which will be a recurring example throughout the book: features will be added on when introducing new topics (in chapters 3, 5, 6, 10, and 13). 2.1 Understanding the Life Cycle of a Game 2.2 Managing the Action (actors and stages, screens and games) 2.3 The Basics: Graphics, User Input, and Collisions2.4 Game Project: Starfish Collector 3. Extending the FrameworkThe LibGDX framework simplifies many elementary tasks required in game development, while providing users a variety of ways to extend their framework to facilitate creation of different types of games. This chapter creates a series of classes (BaseActor, BaseScreen, BaseGame) which extend core LibGDX classes, which will streamline the games created in the following chapters. The new classes are used in refactoring the Starfish Collector game from the previous chapter. 3.1 Extending the Actor class 3.2 Animations 3.2.1 Value-based Animations 3.2.2 Image-based Animations 3.3 Physics and Movement 3.4 Polygons and Collisions 3.5 Lists of Actors 4. Shoot-em-up gamesTo demonstrate the convenience and flexibility of the extended classes created in the previous chapter, this chapter uses the new base classes to create a game called Space Rocks, inspired by the classic arcade game Asteroids. New concepts introduced in this chapter include a new style of movement (relative to the character perspective, rather than the player perspective), spawning new objects, attaching objects to other objects, and adversaries that target the main character.4.1 Game Project: Space Rocks4.2 Spaceship Setup4.3 Lasers, Rocks, and Explosions 4.4 Endgame Conditions 4.5 Extra Features: Shields and Enemies5. Text and User InterfacesThis chapter introduces classes that are used to generate image-based fonts and display text using labels, enabling the developer to show the player important game related information (such as score, time left, health points, item counts) and menus containing instructions. The creation of buttons (to change screens or start/pause/quit the game) is also explained. Tables are introduced to automatically manage the layout of these elements. The creation of signpost-like objects is discussed, which can serve as an in-game tutorial or to provide hints or guidance to the player. These concepts are illustrated by adding features to the previously created game Starfish Collector. The dialog boxes created in this chapter are then used as the basis for creating cutscenes and creating a visual-novel style game. 5.1 Bitmap Fonts and Labels 5.2 Buttons 5.3 Organizing Layouts with Tables 5.4 Creating a Dialog Box class 5.5 Guiding the Player with Signs 5.6 Creating Cutscenes 5.7 Game Project: Visual Novel6. AudioThis chapter explains how to load and play audio files for sound effects and background music, demonstrating by incorporating the sounds into the game Starfish Collector. The chapter goes on to demonstrate how to create a rhythm game, in which the player taps a set of keys in synchronization with background music. The first part of this project involves creating a class that enables the developer to record the timing of a sequence of key presses in a text file; the second part details creating the game itself, which uses the text file data and animates a series of visual cues corresponding to the keys that should be pressed. 6.1 Sounds and Music 6.2 Game Project: Rhythm Tapper 6.3 Recording Beat Data with Text Files 6.4 Synchronizing the Music and the Action Part II: Intermediate ExamplesNow that the reader has a solid foundation in the fundamental concepts and classes needed to create a game, the next part consists of a variety of game projects, each with different mechanics. The chapters in this part are independent of each other may be read in any order, except for chapters 11 and 12 (platform and adventure games), which rely on tilemaps, introduced in chapter 10.7. Side-Scrolling GamesIn this chapter, the reader creates an infinite side-scrolling game called Plane Dodger, inspired by the smartphone game Flappy Bird. This project is the first side-view game, and shows how to create the illusion of movement with scrolling backgrounds, explains the concept of parallax to create a sense of depth, and simulate the force gravity using the acceleration vector. Difficulty ramps are also discussed in relation to the spawn rate and speed of obstacles, as well as measuring player performance and storing high scores.7.1 Game Project: Plane Dodger7.2 Infinite Scrolling7.3 Simulating Gravity7.4 Obstacles and Collectibles8. Bouncing and Collision GamesThis chapter describes how to create the game Rectangle Destroyer, inspired by brick-breaker style games such as Breakout and Arkanoid. Particular attention is given to determining the angle at which the ball bounces off the paddle and the bricks. Collectible items (which may have a positive or negative effect on the player) are implemented, and their relation to changing game feel and maintaining player interest, while maintaining gameplay balance, are discussed at length.8.1 Game Project: Rectangle Destroyer8.2 Paddles, Walls, Bricks, and Balls8.3 Making the Ball Bounce8.4 Power-ups and Other Items9. Drag and Drop GamesThe chapter focuses on mouse-controlled drag-and-drop style games. Two fairly different types of games are created; the common functionality required by both is encapsulated within the new DragAndDropActor class, extending the previously created BaseActor class. Visual effects (change in apparent size and drop shadows) are implemented to make the objects appear as though they are being lifted. The first game project is a jigsaw puzzle style game, which demonstrates how to associate draggable objects with target positions. The second game project is a solitaire-style card game, in which the targets are other draggable objects, subject to a set of conditions (the rules that state on which other cards a given card may be played). 9.1 Creating a Drag and Drop Actor Class 9.2 Game Project: Jigsaw Puzzle 9.3 Game Project: Solitaire Card Games10. TilemapsThis chapter introduces tilemaps and how to create them using third-party software (the Tiled map editor, freely available). For easier reuse, a TilemapActor class is developed which simplifies loading tilemap data into LibGDX projects built with the extended framework in this book. Earlier game projects with different player perspectives (one top-view, one side-view) are revisited to demonstrate how tilemaps can be incorporated to simplify level design. 11.1 Using the Tiled Map Editor 11.2 Creating a Tilemap Actor Class 11.3 Layout for a Top-View Game (Starfish Collector) 11.4 Layout for a Side-View Game (Rectangle Destroyer)11. Platform GamesThis chapter explains how to create a platform-style game in the style of the original Super Mario Bros games. This chapter features the first actor with multiple animations (standing, walking, jumping, climbing). There are many surprisingly sophisticated elements to creating these games, such as detecting when the player is standing on the ground, determining which part of the player collides with an object (top, bottom, or side), allowing the player to be carried by moving platforms, enabling the player to jump through certain types of platforms from below, and enabling the player to climb up and down ladders. Each of these aspects will be discussed at length. 12.1 Game Project: Jumping Jack 12.2 Walking and Jumping 12.3 Incorporating a Tilemap 12.4 Interactive Objects (e.g. Bricks, Springs, Keys, Doors, Spikes, Coins, Hearts, Timers, Goal) 12.5 Moving and Jump-Thru Platforms 12.6 Climbing Ladders12. Adventure GamesThis chapter explains how to create an adventure-style game in the style of the original Legend of Zelda game. Once again, the main character has multiple animations (walking in the directions north, south, east, and west). The main form of combat is swordfighting, and the placement/movement of the sword object (with respect to the player object) requires particularly careful planning. Additional new topics covered in this chapter include transitioning between different screens, and implementing an “item shop” mechanic. 13.1 Game Project: Treasure Quest 13.2 Movement and Fighting 13.3 Incorporating a Tilemap 13.4 Interactive Objects (e.g. Bushes, Coins, Chest, Bomb, Rock) Part III: Advanced TopicsThis final part of the book contains some additional optional features that can be added to many of the previous projects, such as gamepad controller input, and special effects made with particle systems (an efficient method for creating unique, non-repeating). Some game projects involving advanced algorithms and 3D objectsare also included in this part of the book.13. Alternative Sources of User InputThis chapter demonstrates how to add alternative control systems to games, namely, gamepad controllers and touch-screen controls. Both sections build on the Starfish Collector example. 13.1 Gamepad Controllers< 13.2 Touch-Screen Controls 14. Procedural Content Generation This chapter includes a maze-based collection game, inspired by PacMan. The initial example illustrates grid-based movement and basic player-tracking enemies on a predesigned tilemap. Later examples are randomly generated, and enemy movement algorithms are improved to find the shortest path to the player using the A-Star pathfinding algorithm. Finally, random item placement (such as keys and locked doors) is discussed, with an emphasis on verifying that the resulting game can be successfully completed by the player.14.1 Game Project: Maze Runman (three modes: pregenerated maze, random maze, dungeon style exploration)14.1.1 Grid-Based Movement14.1.2 Enemy Movement Patterns14.2 Generating Random Mazes14.3 A-Star Pathfinding14.4 Generating Random Dungeons15. Advanced GraphicsThis chapter explains how to create advanced graphical effects in two different ways: particle systems, and graphics programming. Particle systems are used to simulate fire, explosions, and bursts of sparkles in the Space Rocks game. Graphics programming involves writing code (in OpenGL) that runs directly on the GPU. Examples given include image filters (grayscale, glow, and hue shift) and distortion effects (such as wave distortions). 15.1 Particle Systems15.1.1 Designing Special Effects with the LibGDX Particle Editor15.1.2 Creating a Particle Actor Class 15.2 Graphics Programming 15.2.1 The GPU and the Graphics Pipeline 15.2.2 Vertex and Fragment Shaders 15.2.3 Examples of Visual Effects16. Introduction to 3DThis chapter introduces the 3D graphics capabilities of LibGDX, including how to position objects in three dimensions, how to create lights, how to create geometric objects and import models, and create Actor-like and Scene-like classes to manage 3D objects. This chapter concludes with a 3D version of the Starfish Collector game featured throughout the book. 16.1 Explaining 3D Concepts and Classes 16.2 Creating a Minimal 3D Demo 16.3 Re-creating the Actor/Stage Framework 16.4 Game Project: Starfish Collector 3D17. The Journey ContinuesThis final chapter consists of advice for readers that wish to progress further in the game development field. 17.1 Continuing Your Development 17.2 Broadening Your Horizons 17.3 Disseminating Your GamesAppendix 1: Game Design DocumentationThis appendix contains a suggested series of questions to consider and an outline to follow when planning a game development project, and illustrates with two examples that document games from previous chapters. A1.1 Guiding Questions A1.2 Sample Document: Space Rocks A1.3 Sample Document: Treasure QuestAppendix 2: Summary of Java concepts needed for this bookThis appendix describes the expected Java programming knowledge a reader will need to be familiar with in order to understand the concepts in this book. A2.1 Data Types and Operators A2.2 Control Structures A2.3 Methods A2.4 Objects and ClassesAppendix 3: JavaDoc for Extended Actor ClassesThe appendix contains a JavaDoc-style reference for all the extension classes created in this book, for the convenience of the reader. A3.1 BaseScreen Class A3.2 BaseGame Class A3.3 BaseActor Class A3.4 DialogBoxActor Class A3.5 ParticleActor Class A3.6 DragAndDropActor Class A3.7 TilemapActor Class
Erscheint lt. Verlag | 17.1.2018 |
---|---|
Zusatzinfo | XIX, 433 p. 127 illus., 108 illus. in color. |
Verlagsort | Berkeley |
Sprache | englisch |
Themenwelt | Informatik ► Programmiersprachen / -werkzeuge ► Java |
Informatik ► Software Entwicklung ► Spieleprogrammierung | |
Schlagworte | 2D games • Adventure Games • Arcade Games • Game Design • Game Development • Game Programming • Java • Java programming • LibGDX • platform games • UI Design |
ISBN-10 | 1-4842-3324-7 / 1484233247 |
ISBN-13 | 978-1-4842-3324-5 / 9781484233245 |
Informationen gemäß Produktsicherheitsverordnung (GPSR) | |
Haben Sie eine Frage zum Produkt? |
Größe: 9,4 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich