Copyright
Copyright 2016 Annette Godtland
FIRST EDITION
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the author.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and the author was aware of a trademark claim, the designations have been printed in initial caps or all caps.
No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein.
You may use and redistribute example code and image files from this book only for non-commercial purpose and as long as you acknowledge its source and authorship. The source of the code should be noted in any documentation as well as in the code itself (as a comment). The attribution should include author: Annette Godtland, title: Advanced Do-It-Yourself Java Games, and publisher: Godtland Software Corporation.
All images and image files used in this book were created by Annette Godtland.
All sound files used in this book are in the public domain. The sound file for Three Blind Mice was recorded by Paul Godtland. All the other sound files were downloaded from Pdsounds.org, then edited by Annette Godtland.
The dictionary files used for the Speed Words program are subsets of the file, enable1.txt, a public domain file, downloaded from http://www.puzzlers.org/dokuwiki/doku.php?id=solving:wordlists:about:start&s=word%20list.
First Published on August 16,2016
Last Updated on August 16,2016
Published by:
Godtland Software Corporation, Publishing Division
Rochester, MN
Advanced Do-It-Yourself Java Games
An Introduction to Java Threads and Animated Video Games
by Annette Godtland
Godtland Software Corporation, Publishing Division
Rochester, Minnesota
TABLE OF CONTENTS
Introduction
This is the third book in the Do-It-Yourself Java Games series. The first book's programs were text-based so you could develop basic Java programming skills. The second book, More Do-It-Yourself Java Games, covered a wide variety of to perform automated, simultaneous activities, whether the user takes an action or not.
This book introduces several advanced programming techniques:
- Use threads to .
- Understand the used by Java's graphical user interface.
- Use advanced Java types: and interfaces.
- Use to manage all the game activity.
- Separate the user interface from the program logic by using design.
The games in this book will also serve as a great foundation for many other games. Once you complete a project, feel free to modify it to create other games. Half the fun of programming is making programs do what you want them to do.
As in the previous books in this series, the lessons in each project are presented using a try-it approach: do the steps shown and see what happens. You'll be given programming tasks, each followed by a program . The listings have fill-in blanks to allow you to write much of the code yourself. But don't worry if you're unsure of how to fill in the blanks; simply click the completed listing's link to see the missing code.
Don't skip any lessons. Each lesson explains a new programming technique, which may be used again in later lessons. Doing all the lessons will make later lessons easier.
link to the word in the glossary.
The Do-It-Yourself Java Games books are designed for e-readers. Click the image below or follow this link to watch a video showing the features in these electronic books that would not be possible in a print book.
The Programs
You'll create eight computer programs that use Java threads:
My Timer
Learn how to create, start, and stop a thread that continually updates the display, and how to add sound to a program.
My Timer counts down the number of seconds from any start time and beeps when the timer reaches zero.
Speed Words
Learn how to move objects with the mouse and how to integrate the timer created for the previous program into this program's game.
Make as many other words as possible from the letters of a random seven-letter word, in sixty seconds.
Match Three
Learn how to use a thread to automatically move objects.
Swap balls to form chains of three or more matching balls. Completed chains will be removed and replaced by new balls. Score more points for longer chains.
Baby Bird
Learn to create continuous motion using a .
Flap the baby bird's wings to guide the bird through the gaps in the walls. More points are given for flying through smaller gaps.
Falling Bricks
Learn to use abstract classes.
Move, rotate, and drop falling bricks to complete rows. Earn more points by completing multiple rows with a single brick.
Gravity Well
Learn to use state-driven programming for managing game activity and to detect collisions of irregularly-shaped objects.
Softly land a spaceship without crashing into walls or using up all the fuel. The softer and the more difficult the landing pad, the more points are awarded and the more fuel is replenished.
Cat and Mouse
Learn to use an for more efficient state-driven code.
Guide the mouse to eat cheese without getting caught by the cat. Be careful - the cat can hear when the mouse moves and will try to hunt it down.