cs349 - Developing User Interfaces - Winter 2005

Assignment 1 - Game interfaces. 2D graphics - Resources.

Game programming

When programming a game it is normal to use programming techniques that allow the tightest possible control over what happens on the screen, and when it happens. The architecture appropriate for such programming is the event loop: a single-threaded flow of control checks for an event, responds appropriately to it, then returns to check for the following event, and so on. There are two types of event loop.

  1. Blocking. The function that gets an event blocks until an event is available.
  2. Non-blocking. The blocking function that gets an event is protected by a test to see if any event is available, allowing the program to change state in response to no event.

Blocking event loops are paced by user actions; non-blocking event loops must be paced by some other method, usually calls to a real-time clock.

Game programming is usually done assuming that program performance will not be degraded by other users of the computer on which the program runs, which will, unfortunately, not be true for you, at least when you program in the undergraduate environment. (Please remember that we will run your submission in the undergraduate environment, so allow yourself time to port your sbumission, and to tune it, in the undergraduate environment.)

In addition to the event loop you will need a graphics model so that you can draw things to predictable places on the screen and get input from the mouse.

Thus, the purpose of this assignment is to give you some implementation experience with three important concepts:

  1. the event loop,
  2. two dimensional graphics, and
  3. managing the sequence of things that occur in a user interface.

In doing this assignment you start with a program that does simple mouse/keyboard interaction, which you will find in the course directory, /u/cs349/assignments/a1/hello.c. This program is written in C, using the Xlib library, which implements a 2D graphics model similar to the one described in class. You are assumed to be familiar with C programming and I expect you to acquire information about Xlib functions you wish to use from documentation like the following examples.

This process is quite simple: you know roughly what you want to do on the screen, and look at functions with suggestive names until you find the right one.


Return to: