I210 - Spring 2011
Information Infrastructure (Intro to Programming)
Course: 14947/8862, labs: 8863-65, 14948-50,28589-90
 
 

Graphical Programming


Since some of the game design for the Final Exam Game Project must take place before you learn the specific techniques for doing graphical programming in Python (using LiveWires), here are some notes on what you need to know (and will learn) about graphical programming.  Most of these techniques are common to all forms of graphical programming in all languages, though Python and LiveWires make some of these methods particularly convenient and easy.

 
Graphical programming
“just remember that your standing on a planet thats evolving / revolving at nine-hundred miles an hour”

You will be able to:


•Open a graphics window


You can open (create) a window of a specifiable width and height in which to render your graphics.


•Use a picture of your choosing for the background of the graphics window


You can obtain a .bmp picture from any source and use it as the background for your game.


•Use pictures of your choice as "sprites" that you can position and move around


You can obtain small .bmp pictures from any source and use them as animated game pieces. The locations of sprite objects are specified using (x,y) coordinates, with (0,0) at the top left of the window and (width-1,height-1) at the bottom right of the window.


•Get your sprite objects to change position incrementally via an “update” method


The LiveWires game module you will be using will automatically call your objects’ “update” method for each time step (each frame), so you can incrementally move objects around inside the window.


•Find out when objects collide (overlap)


You will be able to tell when any of your objects collide by asking for a list of all objects with which it overlaps.


•Put text in your window


You can display a game score, instructions, or whatever text you want in your window. The locations of text are specified using (x,y) coordinates, with (0,0) at the top left of the window and (width-1,height-1) at the bottom right of the window.


•Show temporary text in your window


You can ask the game module to display text in your window temporarily, and have it automatically removed after a specified amount of time has passed.


•Read the mouse position, so you can use it to control objects in your window


You can tell where the mouse is and use it to move things around on screen.


•Read keys pressed on the keyboard, so you can control game actions (this will require you to read ahead to Chapter 12, which we will not be covering in class, though we will cover keyboard input if there is time)


You can tell if any keys are pressed on the keyboard, allowing you to move objects around, change game options, or do whatever you want using the keyboard.


•You can play sounds, including playing multiple sounds at the same time.


The Livewires package provided with the book will let you load and play sounds once, a specific number of times, or looping continuously.  You can stop these sounds on demand.  And you can play multiple sounds at the same time.