
Main Page / Code Examples
Code Examples
In addition to the explanations in textual form, the book contains multiple (mostly short) code snippets. Code examples from the book are available here for download, sorted by chapter.
Chapter 2: Hello Game World!























Chapter 3: Console Output and Comments

Chapter 4: Variables and Data Types





Chapter 5: Iteration with the while Loop














Chapter 6: Conditionals (if, if/else, if/else if)















Chapter 7: Relational Expressions (e.g. <, >) and Logical Operators (e.g. &&, ||)












Chapter 8: Math and Arithmetic











Chapter 9: Short Cuts





Chapter 10: Type Conversions (Casting and Rounding)

Chapter 11: Formatting Code



Chapter 12: Iteration with the for Loop



















Chapter 13: Arrays













Chapter 14: Functions















Chapter 15: Movement













Chapter 16: Basic Collision Detection






Chapter 17: Drawing Modes and Drawing Lines


Chapter 18: Polygons and Vertex Functions









Chapter 19: Colour and Transparency





Chapter 20: Text and Fonts, and Loading and Saving Data








Chapter 21: Real Time

Chapter 22: Images




Chapter 23: The Processing IDE, Technical Documentation, Debugging and Common Errors

Chapter 25: Classes and Objects














Chapter 26: Event-Driven Programming and Game Controls















Chapter 27: Hardware Speed Independence for Movement









Chapter 28: Sprites, Frame-Based Animation and Timed Events







Chapter 29: Tiling






Chapter 30: Scrolling and Split-Screen Displays


Chapter 31: Movement in Curves










Chapter 32: Pixel-Perfect Collision Detection

Chapter 33: Vectors













Chapter 34: ArrayLists


Chapter 35: Recursion






Chapter 36: Basic Game AI and Enemy Behaviour



Chapter 37: Programming Libraries, and Using an Audio Library














![Freya Holmér. Vectors & Dot Product • Math for Game Devs [Part 1]. Online video (3:16'27 h). YouTube, Nov 9, 2020. A three hour lecture on vectors; Freya Holmér speaks about vectors and uses them in math and Unity specifically, but the math is applicable anywhere. The whole series 'Math for Game Devs' is on YouTube, and can get quite advanced Vectors & Dot Product • Math for Game Devs [Part 1] on YouTube website screenshot](../links/youtube_com_freya_vectors.png)

|