You are previewing Visual Basic® Game Programming for Teens, Third Edition.
O'Reilly logo
Visual Basic® Game Programming for Teens, Third Edition

Book Description

Visual Basic Game Programming for Teens, Third Edition teaches teens and other beginners how to create their own 2D role-playing game (RPG) using the free to download and easy to use Visual Basic 2008 Express. The game is built step-by-step throughout the book as readers learn new skills and build upon them. This new edition features almost entirely new content from the previous edition and readers will also learn game tool creation, animation skills, and graphics programming.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. Pacing and Experience
      1. Prerequisites
      2. Visual Basic 2008 and the .NET Framework
      3. Managed DirectX Goes Away?
    2. Contacting the Author
    3. Book Contents
    4. Conventions Used in This Book
    5. Companion Website Downloads
  5. I. Building Blocks
    1. 1. Getting Started
      1. What Is Game Programming Really All About?
        1. Get Your Feet Wet First, Ask Questions Later
        2. On Programming Languages
        3. Let Your Creativity Fly
      2. On Creativity, Talent, and Hard Work
        1. The Sky’s the Limit
        2. Learn the Tricks of the Trade
      3. Taking a Look at Celtic Crusader
        1. Building a Role-Playing Game
        2. The Story
        3. Describing the Player’s Character
        4. Adventure Game or Dungeon Crawler?
      4. Level Up!
    2. 2. Visual Basic Primer
      1. What Is Visual Basic?
        1. The .NET Framework
        2. Windows Messages
      2. Writing Your First Visual Basic Program
        1. Say Hello
        2. Code Editor Window
      3. Variables of All Types
        1. Using Variables
        2. What’s So Special about Strings?
        3. Telling Time
          1. Label Control
          2. Timer Events
      4. Branching/Conditional Statements
        1. The If... Then Statement
          1. Single-Line If... Then Statements
          2. Using If ... Then
        2. The Select ... Case Statement
        3. Guessing Game
      5. Subroutines and Functions
        1. Using Subs and Functions
        2. Returning a Value
      6. Mathematical Operators
        1. Converting Data
        2. Addition and Subtraction
        3. Multiplication and Division
          1. Modulus
        4. Math Quiz
      7. Relational Operators
      8. Looping Statements
        1. For Loop
        2. Do Loops
      9. Arrays
      10. Structures
      11. Object-Oriented Programming
        1. Encapsulation
        2. Inheritance
        3. Polymorphism
        4. Properties
        5. Classes
          1. The Format of a Class
          2. Class Variables
          3. Class Constructor
          4. Class Properties and Methods
      12. Level Up!
    3. 3. Forms and Controls
      1. Dice War
        1. Form Layout
        2. Source
      2. Block Buster
        1. Form Layout
        2. Source
      3. Tic-Tac-Toe
        1. Button Events
        2. Source
      4. Level Up!
    4. 4. Drawing with GDI+
      1. Drawing Lines
        1. PictureBox Is Our Friend
        2. Surfaces and Devices
        3. 4D Programming with a Timer
      2. Drawing Rectangles
      3. Drawing Text
      4. Level Up!
    5. 5. Bitmaps: Our First Building Block
      1. Dissecting Bitmaps
        1. Loading a Bitmap File
        2. Drawing a Bitmap
        3. Rotating and Flipping a Bitmap
        4. Accessing Bitmap Pixels
      2. Creating a Game Class
        1. Game Class Constructor
        2. Game Class Destructor
        3. Game Updates
        4. Framework Demo
      3. Level Up!
    6. 6. Sprites and Real-Time Animation
      1. What Is a Sprite?
      2. Animating a Sprite
        1. Sprite Animation Theory
        2. Creating a Sprite Class
      3. Sprite Drawing Demo
        1. Improving the Game Class
        2. Separating Form and Module Code
        3. Adding a Real-Time Game Loop
        4. Gameplay Functions
      4. Level Up!
    7. 7. Collision Detection
      1. Reacting to Solid Objects
        1. Rectangle Intersection
      2. Collision Demo Program
        1. Sprite Class
        2. Game Class
        3. Form1 Class
      3. Level Up!
    8. 8. Playing Sound Effects and Music
      1. Programming Audio
        1. Playing Wave Files
        2. Playing Wave Resources
        3. The Audio Demo Program
      2. Using the Media Player Control
        1. Referencing the Media Player
        2. Playing MP3 and MIDI Files
      3. Level Up!
  6. II. Game World
    1. 9. Designing the Game of Celtic Crusader
      1. The Quest-Based Storyline
      2. Designing the RPG World
        1. Map of the World
        2. Regions
          1. Leinster Region
          2. Munster Region
          3. Ulster Region
          4. Connaught Region
      3. The Player’s Character
        1. Character Attributes (Stats)
          1. Strength
          2. Dexterity
          3. Stamina
          4. Intellect
          5. Charisma
        2. Character Status
        3. Character Classes
          1. Warrior Class
          2. Paladin Class
          3. Hunter Class
          4. Priest Class
      4. Non-Player Characters
      5. Weapons and Armor
      6. Magic
      7. Communication
      8. Combat
      9. Level Up!
    2. 10. Creating the Level Editor
      1. Designing Our Own Level Editor
        1. Building the Editor
        2. Creating a New Tilemap Level
        3. Loading and Saving Level Files
          1. Saving the Editor Palette
          2. Saving the Tile Palette as a Texture
          3. Saving the Whole Level as a Bitmap
          4. Loading and Saving the Level
      2. Level Up!
    3. 11. Rendering a Game Level
      1. Mapping the Game World
        1. Tile-Based Ireland
        2. Loading and Drawing Level Files
      2. Introduction to Tiled Scrolling
        1. Constructing the Tiled Image
        2. Tile Buffer
        3. Stepping Stones of the World
        4. Tile Rendering Theory
      3. Per-Tile Scrolling
        1. Full Tile Scrolling
        2. Full-Tile Smooth Scrolling
      4. Per-Pixel Scrolling
        1. Sub-Tile Scrolling
        2. Drawing the Scroll Buffer
        3. Aligning Tiles to the Scroll Buffer
        4. Sub-Tile Scroll Buffering
        5. Sub-Tile Smooth Scrolling
      5. Level Up!
    4. 12. Adding Objects to the World
      1. Adding Scenery to the Game World
        1. A New Game Loop
          1. Modifying Game.vb
          2. A New Game Loop
        2. New Level Class
        3. Adding Trees
          1. Modifying Sprite.vb
          2. Adding the Trees
      2. Adding an Animated Character
      3. Level Up!
    5. 13. Using Portals to Expand the World
      1. Updating the Level Editor
        1. Perusing New Editor Features
        2. Creating a Portal
      2. It’s a Data-Driven Game World
        1. Level Class Modifications
        2. Teleporting to Another Dimension
        3. Looking for Tile Collisions
        4. Portal Demo Program
      3. Adding Lua Scripting Support to the Game
        1. Installing LuaInterface
        2. Testing LuaInterface
        3. Sharing Tile Data with Lua
      4. Level Up!
  7. III. Gameplay
    1. 14. Creating the Character Editor
      1. Character Classes and Attributes
        1. Attributes
          1. Strength (STR)
          2. Dexterity (DEX)
          3. Stamina (STA)
          4. Intellect (INT)
          5. Charisma (CHA)
          6. Hit Points
        2. Gaining Experience and Leveling Up
        3. The Base Character Classes
          1. Warrior Class
          2. Paladin Class
          3. Hunter Class
          4. Priest Class
        4. Peasants as Quest-Giving NPCs
        5. The Enemy/Monster Classes
          1. Skeleton Warrior
          2. Skeleton Archer
          3. Viking Guard
          4. Zombie
      2. The Character Editor
      3. Loading Character Files
        1. The Character Class
        2. The Animated Character Artwork
        3. Character Demo
      4. Level Up!
    2. 15. Dialogue: Talking with NPCs
      1. Talking with NPCs
        1. Creating the “Vendor” NPC
        2. Starting a Conversation
        3. Dialogue Choices
      2. Creating the Dialogue System
        1. Making Eye Contact
        2. Dialogue GUI
          1. Positioning the Dialogue Window
          2. Drawing the Dialogue Window
          3. Drawing the Title
          4. Drawing the Message with Word Wrapping
          5. Drawing the Buttons
        3. Final Example
      3. Level Up!
    3. 16. Fighting, Getting XP, and Leveling Up
      1. Preparing for Combat
        1. Starting an Attack
        2. Combat Demo 1
      2. Character Templates
        1. Animations: Player Characters (PCs)
          1. Hero (Axe)
          2. Hero (Sword)
          3. Hero (Axe & Shield)
          4. Hero (Sword & Shield)
          5. Hero (Bow)
          6. Hero (Staff)
          7. Hero (Unarmed)
          8. Female Hero (Axe & Shield)
        2. Animations: Hostile NPCs
          1. Undead Skeleton (Bow)
          2. Undead Skeleton (Sword & Shield)
          3. Undead Skeleton (Unarmed)
          4. Undead Zombie (Unarmed)
          5. Viking (Axe)
          6. Viking (Sword & Shield)
        3. Animations: Friendly NPCs
          1. Anna the Peasant
          2. Joe the Farmer
      3. Creating the Combat System
        1. Making Up Our Own Rules
          1. Spawning Enemy NPCs
        2. Attack Rolls
          1. Armor Class (AC)
          2. Melee “Chance To-Hit” Rolls
          3. Ranged “Chance To-Hit” Rolls
        3. Rolling for Damage
          1. Melee “Damage” Rolls
          2. Ranged “Damage” Rolls
          3. Critical Hits (“Crit”)
        4. Attack Roll Example
          1. Armor Class
          2. Attack Roll
          3. Damage Roll
          4. Hit Points
        5. Dealing with the Player’s Death
        6. Combat Demo 2
          1. Turn-based Combat
          2. More Dialogue
          3. Attack!
      4. Facing Your Enemies
        1. Which Way Did He Go?
        2. A Change of Character
      5. State-Based Combat
        1. Dialogue Improvements
        2. Plugging in Attack State
      6. Dealing Permanent Damage
        1. Gaining Experience
      7. Level Up!
    4. 17. Creating the Item Editor
      1. Item Editor Design
        1. Item Images
        2. Looking Up Items
        3. Item Class
        4. Item Editor Source Code
      2. Level Up!
    5. 18. Looting Treasure and Managing Inventory
      1. Looting Treasure
        1. Preparing to Loot
        2. Stumbling Upon Loot
        3. Items Class
        4. Character Class
        5. Dropping Loot
      2. Managing Inventory
        1. Inventory Class
        2. Player Class
      3. Level Up!
    6. 19. Creating the Quest Editor
      1. Quests as Data
        1. Pushing or Pulling?
        2. Quest Condition Types
        3. Quest Rewards
        4. Quest Class
        5. Quest Editor
      2. Quests as Story Driver
        1. Quests Class
          1. Starting a Quest
        2. Quest Window
        3. Completing a Quest
      3. Level Up!
    7. 20. So You Want to Be a Hero?
      1. Rolling Your Player Character
      2. Scripting
        1. Binding Basic Functions
        2. Binding Lua Functions
      3. Loading and Saving the Game
        1. Saving
        2. Loading
      4. Level Up!