home games for coders about contact

by Antonio Maiorano

 

For Coders

This section contains tutorials, source code, and anything else that can help you get into programming, and more specifically, game programming.  I know that when I was a kid, every time I finished playing a game, I would read every name in the credits (even those Japanese ones I could barely pronounce!) and dream that someday my name would be there. When I turned 17, I finally started getting into game coding, and since then, I've come a long way! Knowing I'm surely not the only person with similar aspirations, I've put together this section to help out some of my fellow dreamers! Enjoy.

Quick Links to Sections Below:

Source Code & Libraries
          The Tetris Master GL - Source Code
          Guardian Soft DirectX Library (gsdxlib)

Tutorial & Seminars
          C++ Tutorials
          Mode 13h Tutorial
          Operating System Tutorials

Great Books & References

Useful Links

 
 
 
 
 

Source Code & Libraries

The Tetris Master GL - Source Code

As you can see from the Games section, The Tetris Master (TTM) is the piece of code that I have ported the most often. By porting over the code, I was able to extract the core logic from the system-specific logic, making it a very nice piece of code for beginners to learn from.

DOWNLOAD: Click here to download the Tetris Master GL source code.

Here's a quick overview of the classes in TTM to get you started:

Class Description
TMBlock Represents a Tetris block, or piece. In classic Tetris, there are 7 of these blocks, each made up of four squares.
TMBlockFactory Class that can return one of the 7 pre-defined classic Tetris blocks, either by index, or randomly.
TMMap The map is the area in which the blocks are manipulated by the player. The class contains a 2D matrix of size 20x10 to represent the map area, and has most of the functions that are called in response to user input.
TMScreen The screen represents the entire screen, including the TMMap instance, and potentially anything else that should be displayed. In the original version, this class contained instances of the "next window" class, the "score widow" class, and others. In this simplified version, only the map instance is held. This class also contains the DoIteration() function, which should be called once for every iteration of the main game loop.
TMHighScore This fully functional class is not used in this version, but is available anyway for future expansion.

Actually, with the experience I have gained since I coded TTM, I have often thought of improving the code by transforming it into a Tetris framework. The framework would basically interface with a single class containing pure virtual functions, called say TMClient, which would have to be implemented for system-specific details. This way, porting the code would be as simple as implementing different TMClients, one for each platform. However, this flexibility would also introduce complexity in the code, making it harder for beginner, or even experienced game programmers to learn from it.

 

Guardian Soft DirectX Library (gsdxlib)

Back in 2000, I had just finished learning DirectX and I decided to wrap it up into my own game library that I called simply "Guardian Soft DirectX Library", or gsdxlib for short. As a wrapper for DirectX, the primary purpose of the library was to hide the complexity of using DirectX in a Windows environment. As many game programmers at the time, I was used to the (relatively) easy life of coding games in DOS. When I decided to make the move to Windows programming and use DirectX, I was hit with quite a learning curve! So I decided to mask the complexity behind a well-designed, consistent, and easy to use interface using C++. My goal was to make it so easy to use that a DOS game coder could easily use the library without knowing anything about DirectX and Windows programming.

Although the library is not completely finished, it is still very much in a usable state. I don't intend to continue working on it much since I have moved on to other projects; however, I may take special requests to fix certain problems here or there.

DOWNLOAD: Click here to download the Guardian Soft DirectX Library (includes sample)

HTML DOCS: Click here to view the unfinished HTML documentation for the library

GFX UML DESIGN: Click here to view the UML class diagram for the Graphics component of the library

 

 
 
 
 
 

Tutorials & Seminars

C++ Tutorials

While working at GSI as the main C++ programmer, I could see that many of my coworkers were interested in learning C++ but did not know how to go about accomplishing this somewhat daunting task. So I decided to teach C++ once a week on my own time, and was very happy with the way it turned out. My tutorials consisted mainly of PowerPoint slides and source code, which I have made available for everyone. Keep in mind that the target audience are programmers who don't know C++, but are familiar with common programming concepts, so the tutorials move pretty quickly at the beginning.

bulletLesson 1: The Basics - history of C/C++, basic data types, arrays, strings, naming identifiers.
bulletLesson 2: Program Flow & Pointers - code blocks, conditionals, loops, functions, parameters by value and by reference, pointers, pointers and arrays.
bulletLesson 3: More Pointers! - type casting, dynamic allocation (new/delete), memory leaks, dangling pointers, pointer vs. reference parameters.
bulletLesson 4: Building Programs & Intro to OOP - file organization (cpp, h), compiler vs. linker, common linker errors, old C structures and related problems.
bulletLesson 5: Object-Oriented Programming - classes, constructors & destructors, solving old C struct problems.
bulletLesson 6: Static Data & Cloning Objects - local static variables, global static variables, static data members, cloning class objects, shallow vs. deep copying.
bulletLesson 7: Static Member Functions & Function Overloading - static member functions, function overloading, default parameters.
bulletLesson 8: Operator Overloading - how to overload operators, abusing operator overloading, rules & limitations, guidelines.
bulletLesson 9: Inheritance & Polymorphism - lingo, inheritance, overriding functions, polymorphism, virtual functions, virtual destructors, an actual example.
bulletLesson 10: Q&A on Inheritance & Polymorphism - not useful on its own.
bulletLesson 11: Abstract Classes & Templates - pure virtual functions, templates.

Click here to download a zip containing all the PowerPoint slides and source code.

 

Visual Studio Seminar

In our last year at Concordia University, my good friend, Paul Di Marco, and I were talking about how although we had learned a lot of Computer Science theory in our program, we had barely learned anything practical, like how to use Visual Studio properly. Luckily, we were both so hard-core that we picked it up on our own, but we knew that a lot of our fellow students were going to graduate without even knowing how to use the amazing Visual Studio debugger! So we decided to teach them. In our last year, we presented our Visual Studio Seminar twice, thanks to the help of Concordia Computer Science Society, who were able to reserve a large computer room and the equipment that we needed. Click below to read the PowerPoint presentation for our seminar.

Visual Studio Seminar

 

Mode 13h Tutorial

This tutorial was written back in April 1999, when I was still programming Zelda PC. Although Mode 13h is no longer used to program games nowadays, graphic cards still fully support this mode, and it is a great mode to learn 2D graphics programming. Unfortunately, I never got the chance to finish the tutorial; however, even though it may be outdated, I have every intention of finishing it because I believe it can still be useful. Click below to read this tutorial.

Game Programming in DOS using the C Language

 

Operating System Tutorials

In the Winter semester of 2002, my friend, Paul Di Marco, and I decided to apply for Teacher's Assistant (TA) positions at Concordia University, where we had both graduated as Computer Scientists. We were both assigned to the same teacher who taught the Operating Systems (OS) course, each of us with separate sections to tutor. It turned out that both our tutorials were back to back, so we decided to tag-team and join the tutorials into one to make it more useful for the students. It turned out to be quite a success, and soon we had students from other sections coming to our tutorials!

Although this may not seem game-programming related, I believe strongly that to be a good game programmer, you must know as much as possible about the low-level functionality of the platform you are coding for. Having knowledge about threading, thread synchronization methods, CPU scheduling, and more can greatly improve your design decisions when coding a game.

Note that the language of choice for this course was Java because it is simpler than C++, so students could concentrate more on learning OS techniques rather than battle with the subtleties of C++. Furthermore, Java has some useful built-in features for multithreading.

bulletTutorial 1: Introduction - some good Java links.
bulletTutorial 2: Adventures in Threading - thread scheduling, priorities, time-slices, programming threads in Java, difference in Java implementations.
bulletTutorial 3: Sync or Sink! - thread synchronization, semaphores.
bulletTutorial 4: Scheduling - context switching, scheduling policies (first-come-first-server, shortest job first, etc).
bulletTutorial 5: Even More Synchronization! - alternatives to semaphores: and synchronization, events, monitors, condition variables, reader-writer problem.
bulletTutorial 6: Monitor Review and Deadlock - more on monitors, how to avoid deadlock.
bulletTutorial 7: Memory Management - primary vs. secondary memory, memory manager, stack vs. heap memory, process memory layout, memory allocation strategies (fixed vs. variable partition), memory manager strategies (swapping vs. virtual memory).
bulletTutorial 8: Virtual Memory: PAGING - static paging policies (fetch, replacement, placement) , demand paging algorithms (random, optimal, LRU, LFU, FIFO).
bulletTutorial 9: PA3 - tutorial geared towards helping students with programming assignment 3.
bulletTutorial 10: Protection & Security - policy and mechanism, authentication (external, user, internal).
bulletTutorial 11: PA4 - tutorial geared towards helping students with programming assignment 4.

Click here to download a zip containing all the PowerPoint slides and source code.

 

 
 
 
 
 

Great Books & References

One of the things I love the most is reading programming-related books. I will rarely go anywhere without some good reading material on me! This section lists some of the books I own that I have found to be useful in my programming career.

Now before you go off and spend all your Christmas money on these books, I recommend you take the time to learn C++ properly by either taking a course, or reading a good book on the topic. My basic C++ books are not that great, so I don't mention them here, but I know Bjarne Stroustrup's book The C++ Programming Language is a popular one. Also, you should definitely read or take a course on data structures and algorithms so that you become very comfortable with structures such as lists, trees, hash tables, etc., all of which are used extensively in the programming world.

Title


The C Programming Language, Second Edition

Author(s)

Brian W. Kernighan & Dennis M. Ritchie

Comments

This is the classic book on C programming written by the creators of the language itself. Although C++ is certainly the language of choice nowadays, I believe that having solid knowledge of its predecessor is extremely important towards understanding both the unfortunate backwards-compatibility issues that were carried into C++ from C, and also to appreciate the improvements to the language. The book explains and contains classic examples of every basic construct of the language; however, be warned that it can be quite technical and somewhat daunting to beginners. Definitely a great reference to have, though.
 

Title


Design Patterns - Elements of Reusable Object-Oriented Software

Author(s)

Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (The Gang of Four)

Comments

This is easily one of my favourite books. It's purpose is to teach you how to solve specific problems that seem to come up over and over in programming. In particular, it shows you how to solve these common problems, or patterns, using Object-Oriented techniques such as inheritance and polymorphism. Definitely not a book for the faint of heart, though - I've had to read it over many times to actually understand everything! - but it is certainly worth the effort.
 

Title


C++ for Game Programmers

Author(s)

Noel Llopis

Comments

I started reading this book at a local bookstore and got hooked almost immediately! After ravenously devouring three chapters, I bought it and finished reading it within two weeks! This is an excellent book for beginner to intermediate game programmers who are very comfortable with C++, but have questions about which features of the language should be used, and what design strategies to follow when coding a game. When I bought it, I was in the middle of designing my latest game library, and had many questions floating around in my head, such as how efficient are C++ exceptions, the standard template library (STL), and using dynamic memory allocation. The book answered all my questions and gave me a lot more! A definite must-buy!
 

Title


OpenGL SuperBible, Second Edition

Author(s)

Richard S. Wright, Jr. and Michael Sweet

Comments

I bought this book to learn OpenGL, one of the most popular graphics libraries out there, and it was quite good. It starts off with some basic 3D terminology and theory, but assures you that there is no need for a deep understanding of linear algebra or advanced calculus in order to use OpenGL (at least at a beginner to intermediate level). It goes on to explain the most useful features of OpenGL, such as rendering geometry, texturing, lighting, etc. My only complaint is that I found the chapters written by Sweet were not as explanatory as those written by Wright. However, I have used this book as a reference many times, and do recommend it.
 

Title


Inside DirectX

Author(s)

Bradley Bargen and Peter Donnelly

Comments

Although rather dated, covering DirectX 5, this is an excellent reference for DirectX. It does not cover Direct3D, though, since that is a topic that easily requires its own book, but it covers every other component, including DirectDraw, DirectSound, DirectInput, DirectPlay, and DirectSetup. It is not exactly a book that you can just read through; it is more of a reference, and the best way to use it is to read it and play with the examples from the CD.
 

Title


Windows 98 Programming from the Ground Up

Author(s)

Herbert Schildt

Comments

This is the perfect book for those who don't know any Windows programming and would love to get started. Schildt, in my opinion, has one of the smoothest writing styles, and is not afraid to include complete source code into the book, rather than give you small snippets and force you to load up the CD for complete examples. This makes it a great book to read on the bus every day! It covers all the basics of Win32 programming, and after I finished reading it, it literally took me one week to learn most of MFC, since it is basically just a C++ wrapper to Win32. This book is not really a reference, though, so if you are pretty comfortable with Win32, don't bother buying it.
 

Title


Teach Yourself Game Programming in 21 Days

Author(s)

André LaMothe

Comments

This book holds a very special place in my heart because it is the very first game-programming book I ever bought. I have fond memories of lugging it around school everywhere, and reading it every chance I got. Although it is quite old, covering game programming in DOS graphics Mode 13h, it is still a great book to learn basics from. LaMothe is a well-known game programmer, and in this book, he covers both the high-level design strategies to create your own game, which is still useful even today, as well as the low-level programming techniques used to achieve this goal. One of the most interesting sections explains how ID Software was able to make games like Doom and Wolfenstein run so smoothly on 386 machines. Remember, ID Software was born through its first game, Commander Keen, which was programmed entirely in Mode 13h, and look how far they've come!
 

Title


Physics for Game Programmers

Author(s)

David M. Bourg

Comments

This is the book I am currently carrying with me all over the place! I will be writing up my blurb as soon as I'm done!
 
 
 
 
 
 

Useful Links

This section contains some links to websites I have found to be useful in my programming career.

bulletFiReBeLL - Website of my original game programming mentor, Nathan Yam.
bulletNeon Helium Productions (NeHe) - Excellent resource for OpenGL tutorials.
bulletCode Guru - Contains lots of great programming articles.
bulletThe Code Project - Great site, similar to Code Guru, and Canadian too!
bulletGameDev.net - Huge game development website.
bulletGamasutra - Another large game development resource.

 

 
 


This page is best viewed in at least 1024x768. If you have any comments
regarding the website, please contact the
webmaster.
©1999-2003 Guardian Soft. All rights reserved.