void draw_primitives(int rotation) { spSetZTest( primitives_z ); spSetZSet( primitives_z ); spSetBlending( primitives_blending?spFloatToFixed(0.5):SP_ONE ); SDL_Surface* screen = spGetWindowSurface(); srand( 0 ); int i; for ( i = 0; i < 8; i++ ) spEllipseBorder( rand() % screen->w, rand() % screen->h, 0, rand() % screen->w / 4, rand() % screen->h / 4, 10, 20, rand() % 65536 ); for ( i = 0; i < 8; i++ ) spEllipse( rand() % screen->w, rand() % screen->h, 0, rand() % screen->w / 4, rand() % screen->h / 4, rand() % 65536 ); for ( i = 0; i < 8; i++ ) spRectangleBorder( rand() % screen->w, rand() % screen->h, 0, rand() % screen->w / 2, rand() % screen->h / 2, 12, 6, rand() % 65536 ); for ( i = 0; i < 8; i++ ) spRectangle( rand() % screen->w, rand() % screen->h, 0, rand() % screen->w / 2, rand() % screen->h / 2, rand() % 65536 ); for ( i = 0; i < 64; i++ ) { spSetLineWidth(rand()%8+1); spLine( rand() % screen->w, rand() % screen->h, 0, rand() % screen->w, rand() % screen->h, 0, rand() % 65536 ); } /*spSetLineWidth(5); spLine(292,113,0,29,192,0,12345);*/ spSetLineWidth(1); spSetZTest( 1 ); spSetZSet( 1 ); spSetBlending( SP_ONE ); }
int main(int argc, char **argv) { spInitCore(); SDL_EnableUNICODE( 1 ); gameSettings = new Settings(); display = spCreateWindow( gameSettings->ScreenWidth, gameSettings->ScreenHeight, gameSettings->FullScreen, 0 ); //Setup of the new/resized window spSelectRenderTarget(spGetWindowSurface()); spSetPerspective(50.0f,(float)spGetWindowSurface()->w/(float)spGetWindowSurface()->h,0.1f,100.0f); spSetZTest( 0 ); spSetZSet( 0 ); spSetAlphaTest( 1 ); gameStack = new StageStack(); gameStack->Push( (Stage*)(new BootStage()) ); deltaTime = 0; spLoop( engineDraw, engineUpdate, 10, resizeWindow, engineSDLEvent); spQuitCore(); return 0; }
void draw_splash(void) { spClearTarget(0); spResetZBuffer(); spIdentity(); spTranslate(0,0,-3<<SP_ACCURACY); spSetZTest(0); spSetZSet(0); spMesh3D( sparrow_mesh, 1 ); spMesh3D( logo_mesh, 1 ); spFlip(); }
void draw_sprites(int rotation) { spSetZTest( sprites_z ); spSetZSet( sprites_z ); SDL_Surface* screen = spGetWindowSurface(); spRotozoomSurface( screen->w / 4, screen->h / 4, 0, sprites_garfield, spSin( rotation * 4 ) + ( spFloatToFixed( 1.5f ) ) >> 2, spCos( rotation * 8 ) + ( spFloatToFixed( 1.5f ) ) >> 2, rotation ); spRotozoomSurfacePart( 3 * screen->w / 4, screen->h / 4, 0, sprites_garfield, sprites_garfield->w / 4, sprites_garfield->h / 4, sprites_garfield->w / 2, sprites_garfield->w / 2, spSin( rotation * 4 ) + ( spFloatToFixed( 1.5f ) ) >> 1, spCos( rotation * 8 ) + ( spFloatToFixed( 1.5f ) ) >> 1, rotation ); sprite->rotation = 0; spDrawSprite( screen->w / 5, 5 * screen->h / 8, 0, sprite ); sprite->zoomX = spSin( rotation * 8 ) + ( spFloatToFixed( 1.5f ) ); sprite->zoomY = spCos( rotation * 6 ) + ( spFloatToFixed( 1.5f ) ); spDrawSprite( 2 * screen->w / 5, 5 * screen->h / 8, 0, sprite ); sprite->zoomX *= -1; sprite->rotation = rotation * 4; spDrawSprite( 3 * screen->w / 5, 5 * screen->h / 8, 0, sprite ); sprite->zoomX = SP_ONE; sprite->zoomY = SP_ONE; spDrawSprite( 4 * screen->w / 5, 5 * screen->h / 8, 0, sprite ); spSetZTest( 0 ); spSetZSet( 0 ); }
void draw_schizo( void ) { RESET_ZBUFFER CLEAN_TARGET((*levelPointer)->backgroundColor) spSetZSet( Z_SORTING ); spSetZTest( Z_SORTING ); spSetAlphaTest( 1 ); drawLevel((*levelPointer)); //HUD (for debug reasons) spSetZSet( 0 ); spSetZTest( 0 ); spSetAlphaTest( 1 ); char buffer[256]; sprintf( buffer, "camera X: %i\ncamera Y: %i\ncollisiontests: %i\nfps: %i\nspeed:%.5i,%.5i", (*levelPointer)->currentCamera.x >> SP_ACCURACY-5,(*levelPointer)->currentCamera.y >> SP_ACCURACY-5, getCollisionCount(),spGetFPS(), (*levelPointer)->choosenPlayer->physicsElement->speed.x, (*levelPointer)->choosenPlayer->physicsElement->speed.y); spFontDrawRight( screen->w-1, screen->h-font->maxheight*5, -1, buffer, font ); #if defined ZOOMUP && defined ZOOMDOWN #ifdef FIRSTUP spScale2XSmooth(screen,dummy_screen); spScaleDownSmooth(dummy_screen,screen); #else spScaleDownSmooth(screen,dummy_screen); spScale2XSmooth(dummy_screen,screen); #endif #elif defined ZOOMUP spScale2XSmooth(screen,real_screen); #elif defined ZOOMDOWN spScaleDownSmooth(screen,real_screen); #endif if (levelFade > 0) // Fade in spInterpolateTargetToColor(0,(levelFade*SP_ONE)/FADE_TIME); if (levelFade < 0) // Fade out spInterpolateTargetToColor(0,SP_ONE+(levelFade*SP_ONE)/FADE_TIME); spFlip(); }
int main( int argc, char **argv ) { //sparrow3D Init spSetDefaultWindowSize( 640, 480 ); //Creates a 640x480 window at PC instead of 320x240 spInitCore(); //Setup screen = spCreateDefaultWindow(); spSelectRenderTarget(screen); resize(screen->w,screen->h); spSetZSet(0); spSetZTest(0); spLoop( draw_function, calc_function, 10, resize, NULL ); //Winter Wrap up, Winter Wrap up spFontDelete( font ); spQuitCore(); return 0; }
int main( int argc, char **argv ) { //sparrow3D Init spSetDefaultWindowSize( 640, 480 ); //Creates a 640x480 window at PC instead of 320x240 spInitCore(); //Setup screen = spCreateDefaultWindow(); spSelectRenderTarget(screen); //Tile map loading tile_map = spLoadSurface( "./data/science_guy_frames01.png" ); //Creating an empty sprite sprite = spNewSprite(); //Filling it with it subsprites. int i; for ( i = 0; i < 9; i++ ) spNewSubSpriteWithTiling( sprite, tile_map, i * 24 + 1, 1, 22, 46, 100 ); //We don't want to use the zBuffer in any way spSetZSet(0); spSetZTest(0); //All glory the main loop //every frame the draw_function is called //every frame the calc_function is called with the past time as argument //at least 10 ms have to be between to frames (max 100 fps) //if the window is resized, the resize feedback-function is called (again) spLoop( draw_function, calc_function, 10, NULL, NULL ); //Winter Wrap up, Winter Wrap up spDeleteSprite( sprite ); spDeleteSurface( tile_map ); spQuitCore(); return 0; }
void draw_target(int rotation) { SDL_Surface* screen = spGetWindowSurface(); //drawing on the target_texture spSelectRenderTarget(target_texture); spClearTarget(65535); spSetZSet(0); spSetZTest(0); target_sprite->rotation = 0; spDrawSprite( target_texture->w / 4, target_texture->h / 4, 0, target_sprite ); target_sprite->zoomX = spSin( rotation * 8 ) + spFloatToFixed( 1.5f ); target_sprite->zoomY = spCos( rotation * 6 ) + spFloatToFixed( 1.5f ); spDrawSprite( 3 * target_texture->w / 4, target_texture->h / 4, 0, target_sprite ); target_sprite->rotation = rotation * 4; spDrawSprite( target_texture->w / 4, 3 * target_texture->h / 4, 0, target_sprite ); target_sprite->zoomX = SP_ONE; target_sprite->zoomY = SP_ONE; spDrawSprite( 3 * target_texture->w / 4, 3 * target_texture->h / 4, 0, target_sprite ); //drawing on the target_graph spSelectRenderTarget(target_graph); spClearTarget(01234); spSetZSet(0); spSetZTest(0); Uint16* pixeldata = spGetTargetPixel(); int x; for (x = 0;x < GRAPH_SIZE; x++) { Sint32 sx = spIntToFixed(x-GRAPH_SIZE/2)/16; Sint32 sy = spSin(sx+rotation*16); int y = spFixedToInt(sy*16)+GRAPH_SIZE/2; if (y>=0 && y<GRAPH_SIZE) pixeldata[y*GRAPH_SIZE+x] = 56789; sy = spCos(sx+rotation*32); y = spFixedToInt(sy*16)+GRAPH_SIZE/2; if (y>=0 && y<GRAPH_SIZE) pixeldata[y*GRAPH_SIZE+x] = 45678; } spUnlockRenderTarget(); for (x = 0;x < GRAPH_SIZE-1; x++) { Sint32 sx1 = spIntToFixed(x-GRAPH_SIZE/2)/16; Sint32 sy1 = spTan(sx1+rotation*8); int y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2; Sint32 sx2 = spIntToFixed(x+1-GRAPH_SIZE/2)/16; Sint32 sy2 = spTan(sx2+rotation*8); int y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2; spLine(x,y1,0,x+1,y2,0,34567); sy1 = spAcos(sx1/2+spSin(rotation*24)); y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2; sy2 = spAcos(sx2/2+spSin(rotation*24)); y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2; spLine(x,y1,0,x+1,y2,0,23456); sy1 = spAsin(sx1/2+spCos(rotation*24)); y1 = spFixedToInt(sy1*16)+GRAPH_SIZE/2; sy2 = spAsin(sx2/2+spCos(rotation*24)); y2 = spFixedToInt(sy2*16)+GRAPH_SIZE/2; spLine(x,y1,0,x+1,y2,0,12345); } //drawing on the screen spSelectRenderTarget(screen); spClearTarget(0); spSetZSet(1); spSetZTest(1); spResetZBuffer(); spIdentity(); spTranslate( 0,0, spFloatToFixed( -7.0f ) ); spRotateX( rotation ); spRotateY( rotation ); spRotateZ( rotation ); //Front / Back spBindTexture(target_texture); spQuadTex3D( -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_texture->h - 1, -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, 0, spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_texture->w - 1, 0, spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_texture->w - 1, target_texture->h - 1, 65535); spQuadTex3D( spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, target_texture->h - 1, spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0, -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_texture->w - 1, 0, -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_texture->w - 1, target_texture->h - 1, 65535 ); //Left / Right spBindTexture(target_graph); spQuadTex3D( -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_graph->h - 1, -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0, -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_graph->w - 1, 0, -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_graph->w - 1, target_graph->h - 1, 65535 ); spQuadTex3D( spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_graph->h - 1, spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0, spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_graph->w - 1, 0, spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_graph->w - 1, target_graph->h - 1, 65535 ); //Up / Down spBindTexture(target_garfield); spQuadTex3D( spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_garfield->h - 1, spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0, -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_garfield->w - 1, 0, -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_garfield->w - 1, target_garfield->h - 1, 65535 ); spQuadTex3D( -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), 0, target_garfield->h - 1, -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), 0, 0, spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), target_garfield->w - 1, 0, spFloatToFixed( 1.5f ), -spFloatToFixed( 1.5f ), spFloatToFixed( 1.5f ), target_garfield->w - 1, target_garfield->h - 1, 65535 ); }
void DebugStage::Render() { int elevation = 24; spResetZBuffer(); spIdentity(); spClearTarget(SDL_MapRGB( display->format, 190, 190, 220 )); spSetLight(1); spSetCulling(1); spSetZSet(1); spSetZTest(1); spSetAlphaTest(1); Sint32 brightness = 65535; // (spCos(rotation+a*SP_PI/8)>>SP_HALF_ACCURACY)*abs(spCos(rotation+a*SP_PI/8)>>SP_HALF_ACCURACY)/2+(3<<SP_ACCURACY-1); Uint16 color = 0x8410; // 0xFFFF; // ((brightness>>SP_ACCURACY-4)<<11)+((brightness>>SP_ACCURACY-5)<<5)+(brightness>>SP_ACCURACY-4); spTranslate(0,-6<<SP_ACCURACY,-24<<SP_ACCURACY); spRotateX(rotation); for( int a = 0; a < 64; a++ ) { spRotateX(SP_PI/32); if( ((rotation / (SP_PI/32)) + a) % 64 > 32 ) { int yA, yB; ////////////////////////////////////////// Left OffRoad yA = -15; // + LeftWall[a+1]; yB = -15 + LeftWall[a]; if( yA > yB ) { int yT = yB; yB = yA; yA = yT; } elevation = 25; spBindTexture(roadsideTexture); if( ((rotation / (SP_PI/32)) + a) % 64 > 56 ) { spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } yA = -15 + LeftWall[(a+1) % 64] + 1; if( LeftWall[a+1] != LeftWall[a] ) { spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } spQuadTex3D(((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); yA = -15; // + LeftWall[a+1]; spBindTexture(offroadTexture); spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); ////////////////////////////////////////// Right OffRoad yA = 15 - RightWall[a]; yB = 15; if( yA > yB ) { int yT = yB; yB = yA; yA = yT; } elevation = 25; spBindTexture(roadsideTexture); if( ((rotation / (SP_PI/32)) + a) % 64 > 56 ) { spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } yB = 15 - RightWall[(a+1) % 64] - 1; if( RightWall[a+1] != RightWall[a] ) { spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,roadsideTexture->h-SP_FONT_EXTRASPACE-1, ((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadsideTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); yB = 15; // + LeftWall[a+1]; spBindTexture(offroadTexture); spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); // Draw Road yA = -14 + LeftWall[a]; yB = 14 - RightWall[a]; spBindTexture(roadTexture); elevation = 24; spQuadTex3D(((4*yA)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*yA)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,roadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadTexture->w-SP_FONT_EXTRASPACE-1,roadTexture->h-SP_FONT_EXTRASPACE-1, ((4*yB)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,roadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); /* for( int y = -15; y <= 15; y++ ) { if( y <= -15 + LeftWall[a] || y >= 15 - RightWall[a] ) { elevation = 25; //if( ((rotation / (SP_PI/32)) + a) % 64 == 60 && y == carPos ) // spBindTexture(carTexture); //else spBindTexture(roadsideTexture); if( ((rotation / (SP_PI/32)) + a) % 64 > 56 ) { spQuadTex3D(((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } if( y == -15 + LeftWall[a] || y == 15 - RightWall[a] ) { if( (y == -15 + LeftWall[a] && LeftWall[a] > LeftWall[a+1]) || (y == 15 - RightWall[a] && RightWall[a] > RightWall[a+1]) ) { spQuadTex3D(((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } spQuadTex3D(((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); spQuadTex3D(((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, (elevation-1)<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } spBindTexture(offroadTexture); spQuadTex3D(((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } else { //if( ((rotation / (SP_PI/32)) + a) % 64 == 60 && y == carPos ) // spBindTexture(carTexture); //else spBindTexture(roadTexture); elevation = 24; spQuadTex3D(((4*y)-2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,SP_FONT_EXTRASPACE,SP_FONT_EXTRASPACE, ((4*y)-2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,-3<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,offroadTexture->h-SP_FONT_EXTRASPACE-1, ((4*y)+2)<<SP_ACCURACY-2,+2<<SP_ACCURACY-2, elevation<<SP_ACCURACY-1,offroadTexture->w-SP_FONT_EXTRASPACE-1,SP_FONT_EXTRASPACE,color); } } */ } } spIdentity(); spBindTexture(carTexture); spTranslate( carGfxAt, -3<<SP_ACCURACY, -12<<SP_ACCURACY ); spRotateY( (SP_PI/8)*12 ); spRotateZ( (SP_PI/16)*26 ); if( crashed != 0 ) { spRotateX( (SP_PI/16)*(crashTick < 6 ? crashTick : 6) ); spRotateY( (SP_PI/16)*crashTick ); spRotateZ( (SP_PI/16)*crashTick ); char crashText[80]; int crashYAdj; if( crashHiScore >= 0 ) { sprintf((char*)&crashText, "Well Done\nNew High Score\nRank %d", (crashHiScore+1) ); crashYAdj = (int)((double)fontHiSHnd->maxheight * 1.5); } else { sprintf((char*)&crashText, "Game Over" ); crashYAdj = (int)(fontHiSHnd->maxheight / 2); } spSetZSet( 0 ); spSetZTest( 0 ); spFontDrawMiddle( (gameSettings->ScreenWidth / 2) + 4, (gameSettings->ScreenHeight / 2) + 4 - crashYAdj, -1, (char*)&crashText, fontHiSHnd ); spFontDrawMiddle( (gameSettings->ScreenWidth / 2), (gameSettings->ScreenHeight / 2) - crashYAdj, -1, (char*)&crashText, fontHiHnd ); spSetZSet( 1 ); spSetZTest( 1 ); } else if( carGfxTo > carGfxAt ) { spRotateY( -(SP_PI/16) ); } else if( carGfxTo < carGfxAt ) { spRotateY( (SP_PI/16) ); } spMesh3D( carMesh, 0 ); char scoreText[15]; sprintf((char*)&scoreText, "Score: %d", (int)(score > 9999999 ? 9999999 : score) ); spFontDraw( 10, 10, -1, (char*)&scoreText, fontHnd ); }