Learning Java with Games
Book information
Description
Preface......Page 3 Contents......Page 10 --- Foundation with Games In-Text......Page 20 What is Programming?......Page 21 A Memory Hierarchy......Page 22 Programming Languages Are Needed for Communicating with Computers......Page 23 Java Programming Language and Object-Oriented Programming......Page 24 Programming in General......Page 25 A Programming Flow in Java......Page 26 We Selected Video Games as our Programming Target......Page 27 Why Are We Interested in Video Games?......Page 28 A Simplest Program HelloWorld......Page 29 Using the IDE NetBeans......Page 30 Learning Some Aspects of Java through the Project HelloWorld......Page 31 Exercises......Page 32 Basic Syntax, Semantics, and Conventions in Java: Revisit HelloWorld......Page 34 Variables: The Project HelloWorld2......Page 36 Variable Type......Page 37 Constructor Method of a Class......Page 38 Reprogramming HelloWorld2 with Methods: The Project HelloWorld3......Page 39 The First User-Defined lass: The Project ShowMessage......Page 40 The Problem of “Hard Coded”......Page 41 Adding an Input Portion: The Project ShowMessage2......Page 42 Designing and Implementing a New Project: The Project PrintXmasCard......Page 43 A New User-Defined lass: The Class XmasCard.java......Page 44 Using a Permanent Storage File: The Project PrintXmasCard2......Page 45 Absolute File Path and Relative File Path......Page 46 Setting Up the Channel from the Source File to the Destination File......Page 47 Method and Its Parameter......Page 49 Reference Data Type......Page 50 Primitive Data Type......Page 51 Exercises......Page 52 The Story of a Game In-Text: The Project GuessInt1......Page 56 Object-Oriented Programming Is Based on Objects: The Project GuessInt2......Page 57 The Control Statement “if-then-else”......Page 61 The Control Statement “while”......Page 62 Catching Exceptions for Possible Errors When Inputting Data......Page 63 Developing Our Own Error Detection Methods......Page 64 A Principal Strategy for Designing and Implementing an OOP Program......Page 67 Java Operators......Page 68 More Control Statements in Java......Page 70 The Modifier“Static” (Why main() Method Is a Static Method?)......Page 71 Exercises......Page 72 A Game WheelFortune In-Text......Page 76 A Linear Data Structure: Array......Page 77 Initializing the Game: The Project WheelFortune1......Page 79 Initializing Three Players......Page 81 Initializing the Board and the Wheel: The Project WheelFortune3......Page 84 Mimicking the Wheel Turning......Page 87 The Board Displays the Matched Characters......Page 88 Initializing the Given Sentence Through Reading a Text File......Page 89 Considering Special Cases and Error Cases: The Project WheelFortune4......Page 92 Terminating the Game......Page 96 Exercises......Page 97 --- Event-driven Games......Page 99 Java Provides a Rich Capacity for GUI Programming......Page 100 Constructing a Basis for GUIs......Page 101 Building Up a GUI Foundation: The Project PaintXmasCard1......Page 103 A Built-In Graphics Context......Page 104 Computations Involved: The Project PaintXmasCard2......Page 105 Arranging the Output Nicely......Page 106 Aligning Substrings Along the Center: The Project PaintXmasCard3......Page 110 Adding an Image into the Christmas Card: The Project PaintXmasCard4......Page 111 Decorating the Christmas Card: The Project PaintXmasCard5......Page 113 Superclass and Subclass......Page 115 Exercises......Page 119 The Design of the GUI......Page 121 Arranging Components Using Layout Managers......Page 122 A UML Sequence Diagram Illustrates an Action-Event Chain......Page 125 Making the Software Calculator Work......Page 126 The Register-Trigger-Execute for Making an Action-Event Chain......Page 129 Major Semantic Events and Their Event Listeners......Page 130 Alternative Approaches for Implementing Event Listeners......Page 131 Showing a Static Scene: The Project ImageSlider1......Page 132 Adding Dynamic Behaviors: The Project ImageSlider2......Page 133 Interface and Event Listener......Page 138 More Software Components: JRadioButton and JCheckBox......Page 139 Summary......Page 141 Exercises......Page 142 A Text Version of the Game Anagram: The Project AnagramText......Page 144 A UML Sequence Diagram of the Project AnagramText......Page 145 Adding a GUI to the Game Anagram: The Project AnagramGUI......Page 150 The Class PlayerPanel.java Implements the Sequence of Actions......Page 151 The Class Board.java Displays the Scrambled Word and the Guessed Word......Page 155 The Class GameCanvas.java Sets Up Communication Paths Among Classes......Page 160 Replacing the JRadioButton with a JComboBox......Page 162 Modifying the Class ReadFile.java......Page 165 Summary......Page 166 Exercises......Page 167 A Game Blackjack......Page 168 The Relationship “has” Between the Class Deck.java and the Class Card.java......Page 169 The Class Player.java Determines the Current Status of Each Player......Page 172 The Class PlayerPanel.java Implements the “core” of the Program......Page 176 The GUI and the Event-Driven in the Project Blackjack3......Page 180 Determining “when to show what” by Using Truth Tables......Page 188 The Class GameCanvas.java Sets Up Communication Paths......Page 191 Exercise......Page 192 The Story of the Game Sudoku......Page 194 Two-Dimensional Array......Page 195 A Composite Class Board.java: The Project Sudoku1......Page 196 Applying the Brute-Force Algorithm for Populating the Board: The Project Sudoku2......Page 199 Key Event and Key Event Listener......Page 207 Implementing the Key-Event-Update- Repaint Chain: The Project Sudoku3......Page 208 Exercises......Page 216 A Card Game Agnes......Page 218 Preparing Cards for the Game: The Project Agnes1......Page 219 Cards on the GUI Form a “Layout” and a “Foundation”: The Project Agnes2......Page 222 Mouse Event and Mouse Event Listener......Page 225 Dragging a Card to Anywhere: The Project TestDrag......Page 226 Implementing the Game Rules: The Projects Agnes4 and Agnes5......Page 232 Adding a Class PlayerPanel.java: The Project Agnes5......Page 239 Always Showing the Dragged Cards on Top: The Project Agnes6......Page 240 Exercises......Page 242 --- Animation Games......Page 244 Animation Programming......Page 245 How to Tick: The Projects ADigitClock1 and ADigitClock2......Page 246 Process and Mini-Process......Page 248 The Java Built-In Class Thread......Page 249 How to Use the Class Thread?......Page 250 Applying Thread for Ticking the Digital Clock: The Project ADigitClock3......Page 251 Trail and Flicker Problems: The Projects ADigitClock4 and ADigitClock5......Page 252 A GUI of an Analog Clock: The Project AnalogClock1......Page 255 Constructing a Superclass for Two Subclasses: The Project AnalogClock2......Page 260 Applying Animation to Tick the Analog Clock: The Project AnalogClock3......Page 262 Setting Clock Time Automatically: The Project AnalogClock4......Page 265 Summary......Page 267 Exercises......Page 268 Adding a GUI to the Game WheelFortune In-Text: The Project WheelVideo1......Page 269 The Class WheelGUI.java Constructs the Wheel with a Special Painting......Page 270 The Class Board.java Constructs a Displaying Board......Page 273 The Class PlayerPanel.java Provides a Control Panel for Players......Page 277 The Project TestWheel Rotates the Wheel with the Animation Technique......Page 281 The Collaborations of Classes in the Project WheelVideo2......Page 285 Exercises......Page 295 The Story of the Game Pong......Page 297 Constructing the GUI: The Project Pong1......Page 298 A Brief Introduction on JavaBeans Model......Page 299 The Class Ball.java Defines the Bouncing Ball in the Project Pong1......Page 300 The Class FieldWall.java Defines the Field-Wall in the Project Pong1......Page 301 The Class Paddle.java Defines the Paddle in the Project Pong1......Page 304 Applying the Collision Detection Technique: The Project Pong2......Page 305 Allowing the Player to Move the Paddle with Keys: The Project Pong3......Page 309 Adding a Score Counting Mechanism: The Project Pong3......Page 312 Increasing the Degree of Playing Difficuy: The Project Pong4......Page 313 Exercises......Page 316 Applying the CardLayout for Structuring Multiple Screens......Page 317 Adding a Splash Screen: The Project Pong5......Page 324 Formatting the Texts on the Splash Screen: The Project Pong6......Page 328 Increasing the Number of Ball Sprites: The Project Pong7......Page 332 Modifying the Game Story for Catching the Ball Sprites: The Project Pong8......Page 337 Exercises......Page 341 A Ball Sprite......Page 342 What If More Types of Sprites?......Page 343 It Is Necessary to Specify the Type When Getting Out of a Sprite from a Group......Page 344 Replacing Concrete Classes by Abstract Classes with Abstract Methods......Page 345 Constructing a Three-Layer Software Structure Framework for Games......Page 346 Deriving the Abstract Classes AbsSprite.java and AbsSprite2D.java......Page 347 Deriving the Abstract Class AbsGameCanvas.java......Page 348 Applying the Three-Layer Game Structure: The Project PongStruTwo......Page 349 Summary......Page 362 Exercises......Page 363 The Outline of the Project SymBall......Page 364 Applying the Three-Layer Game Structure for a New Project: SymBall1Init......Page 365 One Thread Supports Two Diferent Animation Tasks: SymBall2ToRight......Page 366 The Sprite Inheritance Hierarchy Eases Adding New Sprites: SymBall3ToRL......Page 370 Every Sprite Has a Thread to Change Its Color Randomly: SymBall4Twinkle......Page 375 A New Project Tornado......Page 377 Exercises......Page 384 A New Image Branch in the Sprite Inheritance Hierarchy......Page 385 Imaging in Java......Page 386 Arranging All Bricks in a 2D Format on the GUI: The Project Breakout1......Page 387 Detecting Collisions by Using PropertyChangeEvent: The Project Breakout2......Page 392 Using Mouse to Control the Paddle Sprite: The Project Breakout3......Page 397 Applying the UML State Machine to Describe Game States [Samek, M., ]......Page 398 Exercises......Page 405 Adding the Current Score Counting and the Ball Lost Counting: Breakout4......Page 407 Adding New Abstract Methods in the Class AbsGameCanvas.java: Breakout4......Page 410 Adding Sound Efect with the Game Breakout: Breakout4......Page 413 Constructing a Composite Sprite: Breakout5......Page 419 Modifying the Communication Path: Breakout5......Page 422 Improving the Control of the Ball Sprite: Breakout5......Page 423 More Extensions of the Game Breakout5......Page 424 Summary......Page 425 Exercises......Page 426 Constructing the Class Worm.java as a Composite Class......Page 427 Painting a Worm and a Treat Statically on the GUI: The Project Worm1......Page 428 Animating the Worm Along the X-Axis: The Project Worm2......Page 432 The Player Controls the Game Through Keys: The Project Worm3......Page 435 Adding Another Worm for Extending the Game: The Project Worm4......Page 440 Some Extensions of the Game Worm......Page 444 Exercises......Page 445 Revisiting the Abstract Model of Games......Page 446 The Story and Its UML State Machine of the Game Othello......Page 447 Initializing the Game with a Board and Four Pieces: The Project Othello1......Page 448 Building up a Mouse Control Mechanism for Players: The Project Othello2......Page 454 Implementing the Playing Rules: The Project Othello3......Page 459 Linking the Rules with the Sprites on the GUI: The Project Othello3......Page 464 Exercises......Page 469 Making Background Color of Images Transparent: The Project TestFlip1......Page 471 Animating Image Pieces: The Project TestFlip2......Page 474 Inserting the Image Pieces: The Project Othello4......Page 476 The “First” Algorithm: The Project Othello5First......Page 478 The “Random” Algorithm: The Project Othello6Ran......Page 481 The “Best” Algorithm: The Project Othello7Best......Page 483 The “Edge” Algorithm: The Project Othello8Edge......Page 486 Summary......Page 490 Exercises......Page 491 --- Serious Games......Page 492 A Teaching Tool for Showing Linear Data Structure......Page 493 Preparing the GUI: The Project BubbleSort1......Page 494 Animating Bubble Sort Algorithm: The Project BubbleSort2......Page 503 Switching the Sorting Algorithm to Be Quick Sort: The Project QuickSort......Page 509 Supporting Multiple Sorting Algorithms: The Project MultiSort......Page 513 Exercises......Page 516 Converting an Integer in Any Base to Decimal: The Project AnyToDecimal......Page 517 Building Up the Control Panel: The Class ControlPanel.java......Page 518 Rendering the Computation Process: The Class RenderSprite.java......Page 524 Converting an Integer in Decimal to Any Base: The Project DecimalToAny......Page 528 Converting a Float in Decimal to Any Base: The Project DeciToAnyFloat......Page 529 Exercises......Page 539 Summation of Binary Integers in Signed-Magnitude: The Project SumSigned......Page 541 Summation of Binary Integers in 1’s Complement: The Project SumOnesComp......Page 552 Summation of Binary Integers in 2’s Complement: The Project SumTwos......Page 559 Reusable Logics and Unshared Diferences for the Six Projects......Page 566 Exercises......Page 567 Source Codes of 3-Layer Structure for Games - GameStruTemplate......Page 568
Similar books
Learning Java With Games
2018 · PDF
Learning Java with Games
2018 · EPUB
Learning Java with Games
2018 · PDF
Software Architecture and Design Illuminated (Jones and Bartlett Illuminated)
2009 · MOBI
Software Architecture and Design Illuminated (Jones and Bartlett Illuminated)
2009 · PDF
Software Architecture and Design Illuminated
2009 · EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF