// Ive written must of this while I was half a sleep, probably explains // any wierdness within the code. Saying that Im always half asleep ??? #include #include #include "pad.h" #include "addrs.h" //#include "3dgraph.h" #include "height.h" // DEFINES //--------- #define TITLE (0) #define GAME (1) #define QUIT (9) //world constants #define GRAVITY (0) #define FRICTION (0) // STRUCTS / UNION //----------------- // PROTOTYPES //------------ void UpdateWorldTitle(); void RenderWorldTitle(); u_long ProcessUserInputTitle(); void UpdateWorldGame(); void RenderWorldGame(); u_long ProcessUserInputGame(); // GLOBALS //--------- // We need a viewing system for 3D graphics GsRVIEW2 ViewPoint; u_long PADstatus=0; u_long VerticalSync=0; ////////////////////////////////////////////////////////////////////// // FUNCTIONS //----------- // ** TITLE SCREEN FUNCTIONS ** // void RenderWorldTitle() { RenderPrepare(); FntPrint(" Title Screen\n\n "); FntPrint(" X = starts\n "); FntPrint(" select and start = Quits "); FntFlush(-1); RenderFinish(); } // void UpdateWorldTitle() { }; // u_long ProcessUserInputTitle() { // create PAD variable to hold states of both joypads u_long PAD = PadRead(); // standard check. Quit if pad1 has start + select pressed if ((PAD& PADstart) && (PAD& PADselect)) return(QUIT); if (PAD& PADcross) return (GAME); //if (PAD& PADLup) ; //if (PAD& PADLdown); return(TITLE); } /////////////////////////////////////////////////////////////////////// // ** GAME FUNCTIONS ** // This function deals with double buffering and drawing of 3D objects void RenderWorldGame() { RenderPrepare(); DrawMap(); VerticalSync = VSync(0); //print your message FntPrint("Game\n"); FntPrint(" \n%d/320\n ",VerticalSync); FntPrint("X =%d\n", ViewPoint.vpx); FntPrint("Y =%d\n", ViewPoint.vpy); // force text output to the PSX screen FntFlush(-1); RenderFinish(); } // void UpdateWorldGame() { // UpdateMap(); //RotateModelMatrix(&test.Object_Coord,10,10,10); //Update scores and titles etc }; // u_long ProcessUserInputGame() { // create PAD variable to hold states of both joypads u_long PAD = PadRead(); // standard check. Quit if pad1 has start pressed if (PAD& PADstart) return(TITLE); if (PAD& PADLleft) MoveModel(&tileModel[0].Object_Coord,0,0,100); if (PAD& PADLright)MoveModel(&tileModel[0].Object_Coord,0,0,-100); if (PAD& PADLdown) MoveModel(&tileModel[0].Object_Coord,0,100,0); if (PAD& PADLup) MoveModel(&tileModel[0].Object_Coord,0,-100,0); if (PAD& PADcross) RotateMap(0,0,30); if (PAD& PADtriangle) RotateMap(0,0,-30); if (PAD& PADsquare) RotateMap(0,30,0); if(PAD& PADcircle) RotateMap(0,-30,0); if(PAD& PADselect) { tileModel[0].Object_Coord.coord = GsIDMATRIX; } return(GAME); } //////////////////////////////////////////////////////////////////////// int main() { u_long GameRunning = TRUE; // FLAG Has game been exited u_long GameState = TITLE;// FLAG Which part of game are we in. (e.g title) // set up print-to-screen font, the parameters are where the font is // loaded into the frame buffer FntLoad(960, 256); //specify where to write on the PSX screen FntOpen(-150, -110, 300, 220, 0, 512); // initialise the joypad PadInit(); // initialise graphics Initialise3DGraphics(); // Setup view to view the car from the side InitialiseView(&ViewPoint,250, 0, 0, -1000, 0, 0, 0, 0 ); InitialiseLights(); SetupMap(); while(GameRunning == TRUE) { while(GameState == TITLE) { GameState = ProcessUserInputTitle(); UpdateWorldTitle(); RenderWorldTitle(); } while(GameState == GAME) { GameState = ProcessUserInputGame(); UpdateWorldGame(); RenderWorldGame(); } if(GameState == QUIT) { GameRunning = FALSE; } } // clean up ResetGraph(3); return 0; }