changelog shortlog tags files raw

changeset: Keyboard support, code movement, and TestManager

changeset 5: bcf3d6f89c62
parent 4:6366beccd211
tag:tip
author: Mohammed Khoory
date: Wed Jul 07 19:11:38 2010 -0400 (19 months ago)
files: 9Game.cpp 9Game.h Makefile gmanager.h graphics.cpp keyboard.c keyboard.h main.cpp sprload.cpp sprload.h testman.cpp testman.h
description: Keyboard support, code movement, and TestManager

Major Changes
=============
- Added "testman.h" and "testman.cpp" to be used exclusively to test stuff (from a
GameManager perspective)
- Moved all the testing stuff to testman.cpp. 9game is just an empty class now to
manage other GameManagers
- Moved all the initializing stuff from 9Game to main. 9Game is like any other
GameManager now (just that it manages other GameManagers)
- Added keyboard.h and keyboard.c to handle keyboard interrupts (by replacing the
keyboard ISR)
- Keyboard is working :D can read more than one key at a time. (tested in
TestManager with WASD)

Minor Changes
=============
- Removed the exception throwing in SpriteLoader::unloadFile() (because it just
makes things unnecessarily complicated)
- added finished() to GameManager to indicate whether a GameManager is finished or
not
- Animation test + key control test. Sprite moves around depending on wasd key
input. (program ends when off screen to right)
- Set 0x00 as transparency color with drawSprite (TODO: change to make this
customizeable on runtime)
- Edited Makefile to reflect new changes

Notes
=====
- Animation seems to work nice and smooth in dosbox, slow in dosemu, so maybe I
should start testing in both dosemu and dosbox
- TODO: fix bug with drawSprite. When a sprite is drawn on the right of the screen
it "wraps around" to the other side by one pixel in width
       1--- a/9Game.cpp	Mon Jun 21 15:08:59 2010 -0400
       2+++ b/9Game.cpp	Wed Jul 07 19:11:38 2010 -0400
       3@@ -10,98 +10,35 @@
       4 Game9::Game9()
       5 {
       6 //	graphics = GraphicsDevice();
       7+	testman = new TestManager();
       8+	currentManager = testman;
       9+
      10 }
      11 
      12 Game9::~Game9()
      13 {
      14-	if(testSprite != NULL)
      15+	if(testman != NULL)
      16 	{
      17-		delete[] testSprite->bitmap;
      18-		delete testSprite;
      19-		testSprite = NULL;
      20+		delete testman;
      21+		testman = NULL;
      22 	}
      23 }
      24 
      25 int Game9::processKeys()
      26 {
      27+	currentManager->processKeys();
      28 	return 0;
      29 }
      30 
      31 int Game9::updateState()
      32 {
      33+	currentManager->updateState();
      34 	return 0;
      35 }
      36 
      37 int Game9::render(GraphicsDevice& graphics)
      38 {
      39-	// clear screen
      40-	graphics.clearScreen();
      41-	
      42-	// make all objects render themselves in order
      43-	
      44-	graphics.drawPixel(100, 100, 0x0F);
      45-	graphics.drawHorizontalLine(100, 110, 50, 0x0F);
      46-	graphics.drawVerticalLine(100, 120, 50, 0x0F);
      47-	if(testSprite != NULL && testSprite->bitmap != NULL)
      48-		graphics.drawSprite(10,10, testSprite);
      49-	else
      50-		graphics.drawHorizontalLine(5,10,25,0x0F);
      51-	
      52-	//update buffer
      53-	graphics.updateBuffer();
      54-
      55-	return 0;
      56-}
      57-
      58-int Game9::run()
      59-{
      60-	// load sprite from bmp file
      61-	SpriteLoader spriteloader;
      62-	try
      63-	{
      64-		spriteloader.loadFile("C:\\9game\\DJGPP\\sprites\\sprites");
      65-		
      66-		
      67-		printf("debugging info:\n");
      68-		printf("Width: %ld Height: %ld \n", spriteloader.getWidth(), spriteloader.getHeight());
      69-		printf("Size: %lu\n" , spriteloader.getSize());
      70-		
      71-		testSprite = spriteloader.getSprite(0,0,110,110);
      72-		
      73-
      74-		GraphicsDevice::enter_mode13h();
      75-		spriteloader.setPalette(graphics);
      76-		spriteloader.unloadFile();	
      77-
      78-		
      79-		for(int i = 0; i < 120; i++){
      80-			processKeys();
      81-			updateState();
      82-			render(graphics);
      83-		}
      84-		
      85-		GraphicsDevice::leave_mode13h();
      86-	}
      87-	catch(int e)
      88-	{
      89-		printf("an exception has occurred\n");
      90-		switch(e){
      91-		case SpriteLoader::FileNotLoadedException:
      92-			printf("Tried to run a function when no file loaded\n");
      93-			break;
      94-		case SpriteLoader::BadFileNameException:
      95-			printf("File name is not valid\n");
      96-			break;
      97-		case SpriteLoader::BadFileException:
      98-			printf("This file is bad. makes no sense\n");
      99-			break;
     100-		case SpriteLoader::CannotReadException:
     101-			printf("This file is not supported\n");
     102-			break;
     103-		}
     104-		
     105-		
     106-	}
     107+	currentManager->render(graphics);
     108 	return 0;
     109 }
     110 
     111@@ -109,3 +46,7 @@
     112 {
     113 	return 0;
     114 }
     115+int Game9::finished()
     116+{
     117+	return currentManager->finished();
     118+}
     1.1--- a/9Game.h	Mon Jun 21 15:08:59 2010 -0400
     1.2+++ b/9Game.h	Wed Jul 07 19:11:38 2010 -0400
     1.3@@ -21,7 +21,7 @@
     1.4 #include "gobject.h"
     1.5 //#include "bmpload.h"
     1.6 #include "sprload.h"
     1.7- 
     1.8+#include "testman.h" 
     1.9 
    1.10 class Game9 : public GameManager
    1.11 {
    1.12@@ -31,21 +31,23 @@
    1.13 protected:
    1.14 	GraphicsDevice graphics;
    1.15 	
    1.16-	struct sprite * testSprite;
    1.17+	GameManager * currentManager;
    1.18+	
    1.19+	TestManager * testman;
    1.20+	
    1.21+//	struct sprite * testSprite;
    1.22 
    1.23 
    1.24 public:
    1.25 	Game9(void);
    1.26 	~Game9(void);
    1.27-
    1.28-
    1.29-	int run(); // enters loops, starts the game
    1.30 
    1.31 	// inherited methods from GameManager
    1.32 	virtual int processKeys(); // reads user input
    1.33 	virtual int updateState(); // updates the object states
    1.34 	virtual int render(GraphicsDevice& device); // renders ethe stuff on screen
    1.35 	virtual int registerGameObject(GameObject * aGameObject);
    1.36+	virtual int finished();
    1.37 
    1.38 };
    1.39  
     2.1--- a/Makefile	Mon Jun 21 15:08:59 2010 -0400
     2.2+++ b/Makefile	Wed Jul 07 19:11:38 2010 -0400
     2.3@@ -3,14 +3,15 @@
     2.4 #
     2.5 
     2.6 # Compiler command
     2.7-CC=gxx
     2.8+CXX=gxx
     2.9+CC=gcc
    2.10 
    2.11 #
    2.12 # Flags 
    2.13 #       -g  -- Enable debugging
    2.14 #       -wall  -- Turn on all warnings
    2.15 #
    2.16-CFLAGS=-g
    2.17+CFLAGS=
    2.18 
    2.19 #Redirection app for logging
    2.20 REDIR=redir -o build.txt -eo 
    2.21@@ -21,27 +22,33 @@
    2.22 	del *.o
    2.23 	del *.exe
    2.24 
    2.25-game.exe : 9game.o graphics.o main.o gobject.o movblobj.o sprload.o
    2.26-	$(CC) $(CFLAGS) -o game.exe 9game.o graphics.o gobject.o movblobj.o sprload.o main.o 
    2.27+game.exe : 9game.o graphics.o main.o gobject.o movblobj.o sprload.o testman.o keyboard.o
    2.28+	$(REDIR) $(CXX) $(CFLAGS) -o game.exe 9game.o graphics.o keyboard.o gobject.o movblobj.o sprload.o testman.o main.o 
    2.29 #C:\DJGPP\LIB\LIBSTD~1.A
    2.30 
    2.31 graphics.o: graphics.cpp
    2.32-	$(REDIR) $(CC) $(CFLAGS) -c graphics.cpp
    2.33+	$(REDIR) $(CXX) $(CFLAGS) -c graphics.cpp
    2.34 
    2.35 9game.o : 9game.cpp
    2.36-	$(REDIR) $(CC) $(CFLAGS) -c 9game.cpp
    2.37+	$(REDIR) $(CXX) $(CFLAGS) -c 9game.cpp
    2.38 
    2.39 main.o : main.cpp
    2.40-	$(REDIR) $(CC) $(CFLAGS) -c main.cpp
    2.41+	$(REDIR) $(CXX) $(CFLAGS) -c main.cpp
    2.42 
    2.43 gobject.o : gobject.cpp
    2.44-	$(REDIR) $(CC) $(CFLAGS) -c gobject.cpp
    2.45+	$(REDIR) $(CXX) $(CFLAGS) -c gobject.cpp
    2.46 
    2.47 movblobj.o : movblobj.cpp
    2.48-	$(REDIR) $(CC) $(CFLAGS) -c movblobj.cpp
    2.49+	$(REDIR) $(CXX) $(CFLAGS) -c movblobj.cpp
    2.50 
    2.51 bmpload.o : bmpload.cpp
    2.52-	$(REDIR) $(CC) $(CFLAGS) -c bmpload.cpp
    2.53+	$(REDIR) $(CXX) $(CFLAGS) -c bmpload.cpp
    2.54 
    2.55 sprload.o : sprload.cpp
    2.56-	$(REDIR) $(CC) $(CFLAGS) -c sprload.cpp
    2.57\ No newline at end of file
    2.58+	$(REDIR) $(CXX) $(CFLAGS) -c sprload.cpp
    2.59+
    2.60+testman.o : testman.cpp
    2.61+	$(REDIR) $(CXX) $(CFLAGS) -c testman.cpp
    2.62+
    2.63+keyboard.o : keyboard.c
    2.64+	$(REDIR) $(CC) $(CFLAGS) -c keyboard.c
     3.1--- a/gmanager.h	Mon Jun 21 15:08:59 2010 -0400
     3.2+++ b/gmanager.h	Wed Jul 07 19:11:38 2010 -0400
     3.3@@ -19,6 +19,9 @@
     3.4 	
     3.5 public:
     3.6 	virtual int registerGameObject(GameObject * aGameObject) = 0; // adds an object to the game
     3.7+	virtual int finished() = 0; // returns GameManager::NOT_FINISHED if not done, anything else otherwise
     3.8+	
     3.9+	static const int NOT_FINISHED = 0;
    3.10 };
    3.11 
    3.12 #endif
     4.1--- a/graphics.cpp	Mon Jun 21 15:08:59 2010 -0400
     4.2+++ b/graphics.cpp	Wed Jul 07 19:11:38 2010 -0400
     4.3@@ -76,6 +76,7 @@
     4.4 	*(buffer + (y*screen_width) + x) = color;
     4.5 }
     4.6 
     4.7+//TODO fix bug when sprite is drawn on the right side of the screen
     4.8 void GraphicsDevice::drawSprite(int x, int y, struct sprite * aSprite)
     4.9 {
    4.10 	for(int i = 0; i< aSprite->height; i++)
    4.11@@ -83,7 +84,8 @@
    4.12 		for(int j = 0; j < aSprite->width; j++)
    4.13 		{
    4.14 			// if off-screen dont draw
    4.15-			if(!(x + j > screen_width || x + j < 0 || y + i > screen_height || y + i < 0))
    4.16+			if(!(x + j > screen_width || x + j < 0 || y + i > screen_height || y + i < 0)
    4.17+				&& !(*(aSprite->bitmap + (i*aSprite->width) + j) == 0))
    4.18 				*(buffer + ( (y+i) * screen_width) + (x+j)) = *(aSprite->bitmap + (i*aSprite->width) + j);
    4.19 		}
    4.20 	}
     5.1--- a/main.cpp	Mon Jun 21 15:08:59 2010 -0400
     5.2+++ b/main.cpp	Wed Jul 07 19:11:38 2010 -0400
     5.3@@ -2,17 +2,78 @@
     5.4  --- main function is here ---
     5.5  */
     5.6  
     5.7- #include <stdio.h>
     5.8- #include "9Game.h"
     5.9+#include <stdio.h>
    5.10+#include "9Game.h"
    5.11+#include "sprload.h"
    5.12+extern "C" {
    5.13+	#include "keyboard.h"
    5.14+}
    5.15  
    5.16  int main(int argc, char ** argv)
    5.17  {
    5.18 	int rc = 0;
    5.19 	Game9 nineGame = Game9();
    5.20 	
    5.21-	rc  = nineGame.run();
    5.22+//	rc  = nineGame.run();
    5.23+	GraphicsDevice graphics;
    5.24+	SpriteLoader spriteloader;
    5.25+	
    5.26+	GraphicsDevice::enter_mode13h();
    5.27+	try{
    5.28+		spriteloader.loadFile("C:\\9game\\DJGPP\\sprites\\sprites");
    5.29+		
    5.30+		
    5.31+		printf("debugging info:\n");
    5.32+		printf("Width: %ld Height: %ld \n", spriteloader.getWidth(), spriteloader.getHeight());
    5.33+		printf("Size: %lu\n" , spriteloader.getSize());
    5.34+		
    5.35+//		testSprite = spriteloader.getSprite(0,0,110,110);
    5.36+		spriteloader.setPalette(graphics);
    5.37+		spriteloader.unloadFile();	
    5.38+
    5.39+	}
    5.40+	catch(int e)
    5.41+	{
    5.42+		printf("an exception has occurred\n");
    5.43+		switch(e){
    5.44+		case SpriteLoader::FileNotLoadedException:
    5.45+			printf("Tried to run a function when no file loaded\n");
    5.46+			break;
    5.47+		case SpriteLoader::BadFileNameException:
    5.48+			printf("File name is not valid\n");
    5.49+			break;
    5.50+		case SpriteLoader::BadFileException:
    5.51+			printf("This file is bad. makes no sense\n");
    5.52+			break;
    5.53+		case SpriteLoader::CannotReadException:
    5.54+			printf("This file is not supported\n");
    5.55+			break;
    5.56+		}
    5.57+		rc = 1;
    5.58+	}
    5.59+	
    5.60+	if(rc != 0)
    5.61+		return rc;
    5.62+	
    5.63+	// attach keyboard ISR
    5.64+	rc = attach_keyboard_handler();
    5.65+	if(rc !=0)
    5.66+	{
    5.67+		detach_keyboard_handler();
    5.68+		return rc;
    5.69+	}
    5.70+
    5.71+	while(nineGame.finished() == GameManager::NOT_FINISHED)
    5.72+	{
    5.73+		nineGame.processKeys();
    5.74+		nineGame.updateState();
    5.75+		nineGame.render(graphics);
    5.76+	}
    5.77+	
    5.78+	// detach keyboard ISR
    5.79+	detach_keyboard_handler();
    5.80 	
    5.81 //	nineGame.~Game9();
    5.82-	
    5.83+	GraphicsDevice::leave_mode13h();
    5.84 	return rc;
    5.85  }
    5.86\ No newline at end of file
     6.1--- a/sprload.cpp	Mon Jun 21 15:08:59 2010 -0400
     6.2+++ b/sprload.cpp	Wed Jul 07 19:11:38 2010 -0400
     6.3@@ -79,11 +79,8 @@
     6.4 	
     6.5 }
     6.6 
     6.7-void SpriteLoader::unloadFile() throw(int)
     6.8+void SpriteLoader::unloadFile()
     6.9 {
    6.10-	if(!paletteFile.is_open() && !rawBitmapFile.is_open())
    6.11-		throw FileNotLoadedException;
    6.12-	
    6.13 	if(paletteFile.is_open())
    6.14 		paletteFile.close();
    6.15 	
     7.1--- a/sprload.h	Mon Jun 21 15:08:59 2010 -0400
     7.2+++ b/sprload.h	Wed Jul 07 19:11:38 2010 -0400
     7.3@@ -38,7 +38,7 @@
     7.4 	
     7.5 	// opens all bitmap and palette and reads the header (filenames are passed in without extension)
     7.6 	void loadFile(const string& filename) throw(int, ios_base::failure);
     7.7-	void unloadFile() throw (int);
     7.8+	void unloadFile();
     7.9 	
    7.10 	// get methods (allocates memory!)
    7.11 	// returns the entire bitmap as a char array
     8.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2+++ b/keyboard.c	Wed Jul 07 19:11:38 2010 -0400
     8.3@@ -0,0 +1,65 @@
     8.4+#include "keyboard.h"
     8.5+#include <stdio.h>
     8.6+
     8.7+/* static methods and variables for handling the keyboard */
     8.8+
     8.9+void handler()
    8.10+{
    8.11+	unsigned char key;	// the key
    8.12+
    8.13+	int i;
    8.14+	
    8.15+	// get the key from the keyboard port
    8.16+	key = inportb(0x60);
    8.17+
    8.18+	if( (key & 0x80) == 0) // check if key is pressed
    8.19+		keys[key & 0x7f] = 1; // set the keys array to pressed
    8.20+	else
    8.21+		keys[ key & 0x7f ] = 0; // not pressed
    8.22+		
    8.23+	outportb(0x20, 0x20);
    8.24+		
    8.25+}
    8.26+// this dummy function simply indicates the end of the handler function
    8.27+void handler_end(){}
    8.28+
    8.29+int attach_keyboard_handler()
    8.30+{
    8.31+	if( enabled == 0)
    8.32+	{
    8.33+		_go32_dpmi_lock_data( (char *) &keys, sizeof(keys) ); // locks storage reigon
    8.34+		
    8.35+		// lock code reigon x
    8.36+		_go32_dpmi_lock_code( (void *) handler, (unsigned long) handler_end - (unsigned long) handler);
    8.37+		
    8.38+		// store the old keyboard handling interrupt service routine
    8.39+		_go32_dpmi_get_protected_mode_interrupt_vector(9, &oldKeyboardHandlerSeginfo);
    8.40+		
    8.41+		// set the offset of the function that will be called
    8.42+		newKeyboardHandlerSeginfo.pm_offset = (int)handler;
    8.43+		
    8.44+		// register the function
    8.45+		if ( _go32_dpmi_allocate_iret_wrapper( &newKeyboardHandlerSeginfo ) != 0)
    8.46+			return 1;
    8.47+		if ( _go32_dpmi_set_protected_mode_interrupt_vector(9, &newKeyboardHandlerSeginfo) != 0)
    8.48+			return 1;
    8.49+		
    8.50+		enabled = 1;
    8.51+	}
    8.52+	return 0;
    8.53+}
    8.54+
    8.55+void detach_keyboard_handler()
    8.56+{
    8.57+	if(enabled == 1)
    8.58+	{
    8.59+		_go32_dpmi_set_protected_mode_interrupt_vector(9, &oldKeyboardHandlerSeginfo);
    8.60+		_go32_dpmi_free_iret_wrapper(&newKeyboardHandlerSeginfo);
    8.61+		enabled = 0;
    8.62+	}
    8.63+}
    8.64+
    8.65+inline char keyPressed(unsigned char key)
    8.66+{
    8.67+	return keys[key];
    8.68+}
    8.69\ No newline at end of file
     9.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2+++ b/keyboard.h	Wed Jul 07 19:11:38 2010 -0400
     9.3@@ -0,0 +1,40 @@
     9.4+#ifndef KEYBOARD
     9.5+#define KEYBOARD
     9.6+
     9.7+/*#ifdef __cplusplus
     9.8+extern "C" {
     9.9+#endif*/
    9.10+/* functions and a custom ISR used to handle the keyboard 
    9.11+	- DOS by itself can only handle one key at a time, so we need to 
    9.12+	replace the interrupt service routine (ISR) to make it handle more 
    9.13+	than one key at a time
    9.14+*/
    9.15+#include <dpmi.h>
    9.16+#include <io.h>
    9.17+#include <conio.h>
    9.18+#include <dos.h>
    9.19+
    9.20+// insert some keyboard codes here as DEFINES (or static chars)
    9.21+
    9.22+
    9.23+char enabled;
    9.24+volatile char keys[256]; // stores keyboard state
    9.25+
    9.26+// keyboard ISRs
    9.27+_go32_dpmi_seginfo oldKeyboardHandlerSeginfo;
    9.28+_go32_dpmi_seginfo newKeyboardHandlerSeginfo;
    9.29+
    9.30+void handler();
    9.31+void handler_end();
    9.32+
    9.33+int attach_keyboard_handler();
    9.34+void detach_keyboard_handler();
    9.35+
    9.36+char keyPressed(unsigned char key);
    9.37+
    9.38+/*
    9.39+#ifdef __cplusplus
    9.40+}
    9.41+#endif
    9.42+*/
    9.43+#endif
    10.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2+++ b/testman.cpp	Wed Jul 07 19:11:38 2010 -0400
    10.3@@ -0,0 +1,123 @@
    10.4+
    10.5+#include "testman.h"
    10.6+
    10.7+TestManager::TestManager()
    10.8+{
    10.9+	// load sprite
   10.10+	SpriteLoader spriteloader;
   10.11+	try{
   10.12+		spriteloader.loadFile("C:\\9game\\DJGPP\\sprites\\sprites");
   10.13+		
   10.14+		printf("debugging info from TestManager:\n");
   10.15+		printf("Width: %ld Height: %ld \n", spriteloader.getWidth(), spriteloader.getHeight());
   10.16+		printf("Size: %lu\n" , spriteloader.getSize());
   10.17+		
   10.18+		testSprite = spriteloader.getSprite(0,0,110,110);
   10.19+	}
   10.20+	catch(int e)
   10.21+	{
   10.22+		printf("an exception has occurred\n");
   10.23+		switch(e){
   10.24+		case SpriteLoader::FileNotLoadedException:
   10.25+			printf("Tried to run a function when no file loaded\n");
   10.26+			break;
   10.27+		case SpriteLoader::BadFileNameException:
   10.28+			printf("File name is not valid\n");
   10.29+			break;
   10.30+		case SpriteLoader::BadFileException:
   10.31+			printf("This file is bad. makes no sense\n");
   10.32+			break;
   10.33+		case SpriteLoader::CannotReadException:
   10.34+			printf("This file is not supported\n");
   10.35+			break;
   10.36+		}
   10.37+		if(spriteloader.isLoaded())
   10.38+			spriteloader.unloadFile();
   10.39+	}
   10.40+	
   10.41+	spriteX = 20;
   10.42+	spriteY = 20;
   10.43+	
   10.44+	wKey = false;
   10.45+	aKey = false;
   10.46+	sKey = false;
   10.47+	dKey = false;
   10.48+}
   10.49+
   10.50+TestManager::~TestManager()
   10.51+{
   10.52+	// free up memory from sprite
   10.53+	if(testSprite != NULL)
   10.54+	{
   10.55+		delete[] testSprite->bitmap;
   10.56+		delete testSprite;
   10.57+		testSprite = NULL;
   10.58+	}
   10.59+}
   10.60+
   10.61+int TestManager::processKeys()
   10.62+{
   10.63+	wKey = keyPressed(0x11) > 0;
   10.64+	aKey = keyPressed(0x1E) > 0;
   10.65+	sKey = keyPressed(0x1F) > 0;
   10.66+	dKey = keyPressed(0x20) > 0;
   10.67+	return 0;
   10.68+}
   10.69+
   10.70+int TestManager::updateState()
   10.71+{
   10.72+	if(wKey)
   10.73+		spriteY -= 1;
   10.74+	if(sKey)
   10.75+		spriteY += 1;
   10.76+	if(aKey)
   10.77+		spriteX -= 1;
   10.78+	if(dKey)
   10.79+		spriteX += 1;
   10.80+	return 0;
   10.81+}
   10.82+
   10.83+int TestManager::render(GraphicsDevice& graphics)
   10.84+{
   10.85+	// clear screen
   10.86+	graphics.clearScreen();
   10.87+	
   10.88+	// make all objects render themselves in order
   10.89+	
   10.90+	graphics.drawPixel(100, 100, 0x0F);
   10.91+	graphics.drawHorizontalLine(100, 110, 50, 0x0F);
   10.92+	graphics.drawVerticalLine(100, 120, 50, 0x0F);
   10.93+	if(testSprite != NULL && testSprite->bitmap != NULL)
   10.94+		graphics.drawSprite(spriteX,spriteY, testSprite);
   10.95+	else
   10.96+		graphics.drawHorizontalLine(5,10,25,0x0F);
   10.97+	
   10.98+	// display keyboard button presses
   10.99+	if(wKey)
  10.100+		graphics.drawPixel(50, 140, 0x0F);
  10.101+	if(aKey)
  10.102+		graphics.drawPixel(50, 150, 0x0F);
  10.103+	if(sKey)
  10.104+		graphics.drawPixel(50, 160, 0x0F);
  10.105+	if(dKey)
  10.106+		graphics.drawPixel(50, 170, 0x0F);
  10.107+	
  10.108+	
  10.109+	//update buffer
  10.110+	graphics.updateBuffer();
  10.111+
  10.112+	return 0;
  10.113+}
  10.114+
  10.115+int TestManager::registerGameObject(GameObject * aGameObject)
  10.116+{
  10.117+	return 0;
  10.118+}
  10.119+
  10.120+int TestManager::finished()
  10.121+{
  10.122+	if( spriteX > 320 )
  10.123+		return FINISHED;
  10.124+	
  10.125+	return NOT_FINISHED;
  10.126+}
  10.127\ No newline at end of file
    11.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2+++ b/testman.h	Wed Jul 07 19:11:38 2010 -0400
    11.3@@ -0,0 +1,40 @@
    11.4+/*
    11.5+	This gamemanager is used for testing
    11.6+*/
    11.7+
    11.8+#ifndef TESTMANAGER
    11.9+#define TESTMANAGER
   11.10+
   11.11+#include "graphics.h"
   11.12+#include "gmanager.h"
   11.13+#include "gobject.h"
   11.14+#include "sprload.h"
   11.15+/*extern "C" {
   11.16+	#include "keyboard.h"
   11.17+}*/
   11.18+extern "C" char keyPressed(unsigned char key);
   11.19+
   11.20+class TestManager : public GameManager
   11.21+{
   11.22+private:	
   11.23+	
   11.24+protected:
   11.25+	struct sprite * testSprite;
   11.26+	int spriteX, spriteY;
   11.27+	bool wKey, aKey, sKey, dKey;
   11.28+	
   11.29+public:
   11.30+	TestManager();
   11.31+	~TestManager();
   11.32+	
   11.33+	// inherited methods
   11.34+	virtual int processKeys();
   11.35+	virtual int updateState();
   11.36+	virtual int render(GraphicsDevice& graphics);
   11.37+	virtual int registerGameObject(GameObject * aGameObject);
   11.38+	virtual int finished();
   11.39+	
   11.40+	static const int FINISHED = 1;
   11.41+};
   11.42+
   11.43+#endif
   11.44\ No newline at end of file