void TransitionStrips::PrepareStrips( Uint16 FadeFrames, Uint16 NumberOfStrips ) { numStrips = NumberOfStrips; frameMax = FadeFrames; stripWidth = Framework::System->GetDisplayWidth() / NumberOfStrips; if( stripWidth * NumberOfStrips < Framework::System->GetDisplayWidth() ) // Correct any rounding issues { stripWidth++; } frameIndex = 0; slowestSpeed = Framework::System->GetDisplayHeight() / FadeFrames; SourceScreen = spUniqueCopySurface( spGetWindowSurface() ); spSelectRenderTarget( SourceScreen ); Source->Render(); TargetScreen = spUniqueCopySurface( spGetWindowSurface() ); spSelectRenderTarget( TargetScreen ); Target->Render(); spSelectRenderTarget( spGetWindowSurface() ); speedList = (int*)malloc( sizeof(int) * NumberOfStrips ); for( int i = 0; i < NumberOfStrips; i++ ) { speedList[i] = slowestSpeed + (rand() % slowestSpeed); if( speedList[i] == 0 ) { speedList[i] = 1; } } }
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 StateMenu::render(SDL_Surface* target) { spClearTarget( spGetRGB(128,0,0) ); if ( textMode == -1 ) { SDL_SetAlpha( text, SDL_SRCALPHA, (1.0f - (float)textTimer.getTime() / (float)textTimer.getDuration()) * 255.0f ); if ( textTimer.isStopped() ) { textTimer.start( MENU_TEXT_SHOW_TIME ); textMode = 0; SDL_SetAlpha( text, SDL_SRCALPHA, SDL_ALPHA_OPAQUE ); } } else if ( textMode == 0 ) { if ( textTimer.isStopped() ) { textTimer.start( MENU_TEXT_FADE_TIME ); textMode = 1; } } else if ( textMode == 1 ) { SDL_SetAlpha( text, SDL_SRCALPHA, (float)textTimer.getTime() / (float)textTimer.getDuration() * 255.0f ); if ( textTimer.isStopped() ) { ++textIndex; if ( textIndex >= lines.size() ) textIndex = 0; textTimer.start( MENU_TEXT_FADE_TIME ); textMode = -1; SDL_FillRect( text, NULL, spGetRGB( 255, 0, 255 ) ); SDL_SetColorKey( text, SDL_SRCCOLORKEY, spGetRGB( 255, 0, 255 ) ); spSelectRenderTarget( text ); spFontDraw( 20, 10, -1, (unsigned char*) lines[textIndex].first.c_str(), fontDark ); spFontDraw( 20, 10 + MENU_FONT_SIZE, -1, (unsigned char*) lines[textIndex].second.c_str(), fontDark ); spSelectRenderTarget( spGetWindowSurface() ); SDL_SetAlpha( text, SDL_SRCALPHA, SDL_ALPHA_TRANSPARENT ); } } SDL_Rect rect = { 0,0,APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT / 2 }; spUnlockRenderTarget(); SDL_BlitSurface( text, NULL, spGetWindowSurface(), &rect ); spLockRenderTarget(); for ( int I = entries.size()-1; I >= 0; --I ) { if ( choice == I ) { spFontDrawRight( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT - MENU_FONT_SIZE * (I+1), -1, (unsigned char*) entries[I].name.c_str(), fontBright ); } else { spFontDrawRight( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT - MENU_FONT_SIZE * (I+1), -1, (unsigned char*) entries[I].name.c_str(), fontDark ); } } }
void resizeWindow( Uint16 w, Uint16 h ) { spDeleteSurface(display); display = spCreateWindow( w, h, gameSettings->FullScreen, 0 ); //Setup of the new/resized window spSelectRenderTarget(spGetWindowSurface()); spSetPerspective(50.0f,(float)spGetWindowSurface()->w/(float)spGetWindowSurface()->h,0.1f,100.0f); }
void draw_function( void ) { spClearTarget( 0 ); char buffer[256]; sprintf(buffer,"FPS: %i",spGetFPS()); spFontDrawRight( spGetWindowSurface()->w-1, spGetWindowSurface()->h-font->maxheight, -1, buffer, font ); spFlip(); }
void draw_c4a() { if (c4aState == 0) return; if (spNetC4AGetTimeOut() <= 0 && c4aErrorTimeOut <= 0) return; spFontPointer small_font = settings_get_small_font(); int engineWindowX=spGetWindowSurface()->w; int engineWindowY=spGetWindowSurface()->h; spFontDraw(1,engineWindowY-(small_font->maxheight),-1,c4aStatus,small_font); }
void TransitionFade::PrepareFade( Uint16 FadeFrames ) { Alpha = 0; FadePerUpdate = SP_ONE / FadeFrames; SourceScreen = spUniqueCopySurface( spGetWindowSurface() ); spSelectRenderTarget( SourceScreen ); Source->Render(); TargetScreen = spUniqueCopySurface( spGetWindowSurface() ); spSelectRenderTarget( TargetScreen ); Target->Render(); spSelectRenderTarget( spGetWindowSurface() ); }
void ShmupStage::Render() { if( stageFlag < 2 ) return; curGame->Render(); char buffer[256]; sprintf( buffer, "FPS: %i", spGetFPS() ); spFontDrawRight( spGetWindowSurface()->w-1, spGetWindowSurface()->h-font->maxheight, -1, buffer, font ); /* sprintf( buffer, "Pos: %i", curGame->Scenery->ScrollLevelPosition ); spFontDraw( 3, spGetWindowSurface()->h-font->maxheight, -1, buffer, font ); */ }
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 ); }
void StateScore::render( SDL_Surface *target ) { spUnlockRenderTarget(); SDL_BlitSurface( killFrame, NULL, spGetWindowSurface(), NULL ); spLockRenderTarget(); if ( scoreText ) { spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 - SCORE_FONT_SIZE * 2, -1, playerDead ? (unsigned char*) "You died!" : (unsigned char*) "You survived, somehow...", scoreText ); spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 - SCORE_FONT_SIZE, -1, (unsigned char*) ("Score: " + Utility::numToStr( score )).c_str(), scoreText ); if ( run && run->playing ) spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 , -1, (unsigned char*) "Name of this player:", scoreText ); else spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 , -1, (unsigned char*) "Enter your name:", scoreText ); char temp[strlen(name) + caret]; strcpy( temp, name ); if ( caret ) strcat( temp, "_\0" ); spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 + SCORE_FONT_SIZE, -1, (unsigned char*) temp, scoreText); if ( state == 0 ) spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 + SCORE_FONT_SIZE * 3, -1, (unsigned char*) "Press \""SP_BUTTON_START_NAME"\" to confirm name...", scoreText ); else spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2 + SCORE_FONT_SIZE * 3, -1, (unsigned char*) "Press \""SP_BUTTON_START_NAME"\" to return to menu...", scoreText ); } }
void help_draw(void) { spClearTarget(LL_BG); const int B1 = spMax(spGetSizeFactor()>>16,1); const int B2 = spMax(spGetSizeFactor()>>15,1); spFontDrawMiddle( spGetWindowSurface()->w/2, 2, 0, "How to Play", help_font ); int h = spGetWindowSurface()->h - 4 - 4*help_font->maxheight; spFontDrawTextBlock(left,2+spGetWindowSurface()->w/6,2*help_font->maxheight+2, 0,help_block,h,help_scroll,help_font); if (help_scroll != SP_ONE) { const char button_text[] = "[v]"; help_button[2].w = spFontWidth( button_text, help_font ); help_button[2].h = help_font->maxheight; help_button[2].x = 2+spGetWindowSurface()->w*5/6; help_button[2].y = spGetWindowSurface()->h-2-2*help_font->maxheight; int width = help_button[2].w; int height = help_font->maxheight; draw_edgy_rectangle(help_button[2].x,help_button[2].y,&width,&height,B1,B2); spFontDraw( help_button[2].x, help_button[2].y, 0, button_text, help_font ); } else { help_button[2].x = -1; help_button[2].y = -1; help_button[2].w = -1; help_button[2].h = -1; } if (help_scroll != 0) { const char button_text[] = "[^]"; help_button[1].w = spFontWidth( button_text, help_font ); help_button[1].h = help_font->maxheight; help_button[1].x = 2+spGetWindowSurface()->w*5/6; help_button[1].y = 2+ help_font->maxheight; int width = help_button[1].w; int height = help_font->maxheight; draw_edgy_rectangle(help_button[1].x,help_button[1].y,&width,&height,B1,B2); spFontDraw( help_button[1].x, help_button[1].y, 0, button_text, help_font ); } else { help_button[1].x = -1; help_button[1].y = -1; help_button[1].w = -1; help_button[1].h = -1; } const char button_text[] = "{jump}Okay"; help_button[0].w = spFontWidth( button_text, help_font ); help_button[0].h = help_font->maxheight; help_button[0].x = spGetWindowSurface()->w/2 - help_button[0].w/2; help_button[0].y = spGetWindowSurface()->h-B2*2-help_font->maxheight; int width = help_button[0].w; int height = help_font->maxheight; draw_edgy_rectangle(help_button[0].x,help_button[0].y,&width,&height,B1,B2); spFontDraw( help_button[0].x, help_button[0].y, 0, button_text, help_font ); spFlip(); }
void UnitLaser::generateIdleImage() { idle = spCreateSurface( LASER_RADIUS * 2, LASER_RADIUS * 2 ); SDL_FillRect( idle, NULL, SP_ALPHA_COLOR ); spSelectRenderTarget( idle ); spEllipse( LASER_RADIUS, LASER_RADIUS, -1, LASER_RADIUS, LASER_RADIUS, 0 ); spSelectRenderTarget( spGetWindowSurface() ); }
void UnitBomb::generateFlashingImage() { flashing = spCreateSurface( BOMB_RADIUS * 2, BOMB_RADIUS * 2 ); SDL_FillRect( flashing, NULL, SP_ALPHA_COLOR ); spSelectRenderTarget( flashing ); spEllipse( BOMB_RADIUS ,BOMB_RADIUS, -1, BOMB_RADIUS, BOMB_RADIUS, spGetFastRGB( 255, 255, 255 ) ); spSelectRenderTarget( spGetWindowSurface() ); }
void draw_music() { if (show_music > 0) { SDL_Surface *screen = spGetWindowSurface(); char buffer[256]; sprintf(buffer,"Vol: %i%%",volume); spFontDrawMiddle(screen->w/2,screen->h/2,-1,buffer,getFont(0)); } }
StateScore::StateScore( StateLevel *level ) : StateBase(), file( FOLDER_DATA "/" FILE_HIGHSCORE_NORMAL ) { SDL_Surface *temp = spCreateSurface( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT ); killFrame = spCreateSurface( APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT ); spSelectRenderTarget( temp ); level->render( temp ); spUnlockRenderTarget(); SDL_SetAlpha( temp, SDL_SRCALPHA, 128 ); SDL_BlitSurface( temp, NULL, killFrame, NULL ); spLockRenderTarget(); spSelectRenderTarget( spGetWindowSurface() ); spDeleteSurface( temp ); if ( level->player->toBeRemoved ) playerDead = true; else playerDead = false; score = level->scoreKeeper->getScore(); scoreText = spFontLoad( FONT_GENERAL, SCORE_FONT_SIZE ); if ( scoreText ) { spFontAdd( scoreText, SP_FONT_GROUP_ALPHABET SP_FONT_GROUP_GERMAN ".:!\"_", -1 ); spFontAdd( scoreText, SP_FONT_GROUP_NUMBERS, spGetRGB( 255, 128, 0 ) ); } nameBkup[0] = 0; if ( level->run->playing ) { state = 1; caret = false; strcpy( nameBkup, name ); strcpy( name, level->run->info.name.c_str() ); run = level->run; level->run = NULL; } else { caret = true; state = 0; spPollKeyboardInput( name, SCORE_MAX_NAME_LENGTH, NULL ); run = level->run; level->run = NULL; } caretTimer.start( SCORE_CARET_BLINK_TIME ); timers.push_back( &caretTimer ); type = stScore; }
void ItemSlowmo::generateIdleImage() { idle = spCreateSurface( ITEM_SLOWMO_RADIUS * 2, ITEM_SLOWMO_RADIUS * 2 ); SDL_FillRect( idle, NULL, SP_ALPHA_COLOR ); spSelectRenderTarget( idle ); Uint16 col = spGetRGB( 0, 192, 0 ); spEllipse( ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS, -1, ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS, -1); spEllipse( ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS, -1, ITEM_SLOWMO_RADIUS * 0.9, ITEM_SLOWMO_RADIUS * 0.9, col ); spEllipse( ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS, -1, ITEM_SLOWMO_RADIUS * 0.65, ITEM_SLOWMO_RADIUS * 0.65, -1); spEllipse( ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS, -1, ITEM_SLOWMO_RADIUS * 0.55, ITEM_SLOWMO_RADIUS * 0.55, col ); spRectangle( ITEM_SLOWMO_RADIUS, ITEM_SLOWMO_RADIUS * 0.8, -1, ITEM_SLOWMO_RADIUS * 0.1, ITEM_SLOWMO_RADIUS * 0.4, -1 ); spRectangle( ITEM_SLOWMO_RADIUS * 1.2, ITEM_SLOWMO_RADIUS, -1, ITEM_SLOWMO_RADIUS * 0.4, ITEM_SLOWMO_RADIUS * 0.1, -1 ); spSelectRenderTarget( spGetWindowSurface() ); }
void resize( Uint16 w, Uint16 h ) { screen = spGetWindowSurface(); spSelectRenderTarget(screen); spFontSetShadeColor(0); //Font Loading if ( font ) { if (spGetSizeFactor() > SP_ONE) { spFontReload( font , "./data/DejaVuSans-Bold.ttf", 8 * spGetSizeFactor() >> SP_ACCURACY); spFontReload( font_dark, "./data/DejaVuSans-Bold.ttf", 8 * spGetSizeFactor() >> SP_ACCURACY); } else {
void ItemVortex::generateIdleImage() { idle = spCreateSurface( ITEM_VORTEX_RADIUS * 2, ITEM_VORTEX_RADIUS * 2 ); SDL_FillRect( idle, NULL, SP_ALPHA_COLOR ); spSelectRenderTarget( idle ); Uint16 col = spGetRGB( 0, 192, 0 ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1 ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.9, ITEM_VORTEX_RADIUS * 0.9, col ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.65, ITEM_VORTEX_RADIUS * 0.65, -1 ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.55, ITEM_VORTEX_RADIUS * 0.55, col ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.45, ITEM_VORTEX_RADIUS * 0.45, -1 ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.35, ITEM_VORTEX_RADIUS * 0.35, col ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.25, ITEM_VORTEX_RADIUS * 0.25, -1 ); spEllipse( ITEM_VORTEX_RADIUS, ITEM_VORTEX_RADIUS, -1, ITEM_VORTEX_RADIUS * 0.15, ITEM_VORTEX_RADIUS * 0.15, col ); spSelectRenderTarget( spGetWindowSurface() ); }
void start_help(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h )) { int i = 3; while (i --> 0 ) { help_button[i].x = -1; help_button[i].y = -1; help_button[i].w = -1; help_button[i].h = -1; } help_was_pressed = 0; help_block = spCreateTextBlock(help_text,spGetWindowSurface()->w*2/3-4,font); help_scroll = 0; help_font = font; spLoop(help_draw,help_calc,10,resize,NULL); spDeleteTextBlock(help_block); }
void draw_filled_border(int x1,int y1,int x2,int y2,Uint16 color) { SDL_LockSurface(spGetWindowSurface()); Uint16* pixel = (Uint16*)spGetWindowSurface()->pixels; int x,y; int r = 6 * spGetSizeFactor() >> SP_ACCURACY; for (x = x1; x<=x2; x++) for (y = y1; y<=y2; y++) if (x >= 0 && y >= 0 && x<spGetWindowSurface()->w && y<spGetWindowSurface()->h) { /*//left, top edge if (x-x1 < r && y-y1 < r) { int value = (r-x+x1)*(r-x+x1)+(r-y+y1)*(r-y+y1); if (value < r*r && ((x+(y&3))&3)) pixel[x+y*spGetWindowSurface()->w] = color; } else //right, top edge if (x2-x < r && y-y1 < r) { int value = (r-x2+x)*(r-x2+x)+(r-y+y1)*(r-y+y1); if (value < r*r && ((x+(y&3))&3)) pixel[x+y*spGetWindowSurface()->w] = color; } else //left, bottom edge if (x-x1 < r && y2-y < r) { int value = (r-x+x1)*(r-x+x1)+(r-y2+y)*(r-y2+y); if (value < r*r && ((x+(y&3))&3)) pixel[x+y*spGetWindowSurface()->w] = color; } else //right, bottom edge if (x2-x < r && y2-y < r) { int value = (r-x2+x)*(r-x2+x)+(r-y2+y)*(r-y2+y); if (value < r*r && ((x+(y&3))&3)) pixel[x+y*spGetWindowSurface()->w] = color; } else*/ if ((x+(y&3))&3) pixel[x+y*spGetWindowSurface()->w] = color; } SDL_UnlockSurface(spGetWindowSurface()); }
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 TransitionFadeIn::Render() { SDL_Surface* b = spGetWindowSurface(); SDL_Surface* t = spUniqueCopySurface( b ); // Fade from colour spClearTarget( SourceColour ); // Buffer the next stages screen spSelectRenderTarget( t ); Target->Render(); spSelectRenderTarget( b ); // Alpha it to the actual screen spSetHorizontalOrigin( SP_LEFT ); spSetVerticalOrigin( SP_TOP ); spSetBlending( Alpha ); spBlitSurface( 0, 0, -1, t ); spSetBlending( SP_ONE ); spDeleteSurface( t ); }
void resize(Uint16 w,Uint16 h) { //Setup of the new/resized window spSelectRenderTarget(spGetWindowSurface()); spSetPerspective(50.0,(float)spGetWindowSurface()->w/(float)spGetWindowSurface()->h,1.0,100); spBundlePointer translation = settings_get_translation(); spFontShadeButtons(1); //Font Loading spFontSetShadeColor(FONT_BORDER_1); if (font) spFontDelete(font); font = spFontLoad(FONT_LOCATION,FONT_SIZE*spGetSizeFactor()>>SP_ACCURACY); spFontAdd(font,SP_FONT_GROUP_ASCII,FONT_COLOR_1);//whole ASCII spFontAddEveryLetterOfTextBundle(font,translation,FONT_COLOR_1); spFontAddBorder(font,FONT_BORDER_1); spFontMulWidth(font,15<<SP_ACCURACY-4); spFontAddButton( font, 'A', SP_BUTTON_LEFT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'B', SP_BUTTON_RIGHT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'X', SP_BUTTON_DOWN_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'Y', SP_BUTTON_UP_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'L', SP_BUTTON_L_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'R', SP_BUTTON_R_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'S', SP_BUTTON_START_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( font, 'E', SP_BUTTON_SELECT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); settings_set_font(font); spFontSetShadeColor(FONT_BORDER_2); if (small_font) spFontDelete(small_font); small_font = spFontLoad(FONT_LOCATION,FONT_SMALL_SIZE*spGetSizeFactor()>>SP_ACCURACY); spFontAdd(small_font,SP_FONT_GROUP_ASCII,FONT_COLOR_2);//whole ASCII //spFontAdd(small_font,SP_FONT_GROUP_GERMAN,0);//some German letters spFontAddEveryLetterOfTextBundle(small_font,translation,FONT_COLOR_2); spFontAddBorder(small_font,FONT_BORDER_2); spFontMulWidth(small_font,15<<SP_ACCURACY-4); spFontAddButton( small_font, 'A', SP_BUTTON_LEFT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'B', SP_BUTTON_RIGHT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'X', SP_BUTTON_DOWN_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'Y', SP_BUTTON_UP_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'L', SP_BUTTON_L_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'R', SP_BUTTON_R_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'S', SP_BUTTON_START_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( small_font, 'E', SP_BUTTON_SELECT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); settings_set_small_font(small_font); spFontSetShadeColor(FONT_BORDER_1); if (middle_font) spFontDelete(middle_font); middle_font = spFontLoad(FONT_LOCATION,FONT_MIDDLE_SIZE*spGetSizeFactor()>>SP_ACCURACY); spFontAdd(middle_font,SP_FONT_GROUP_ASCII,FONT_COLOR_1);//whole ASCII //spFontAdd(middle_font,SP_FONT_GROUP_GERMAN,0);//some German letters spFontAddEveryLetterOfTextBundle(middle_font,translation,FONT_COLOR_1); spFontAddBorder(middle_font,FONT_BORDER_1); spFontMulWidth(middle_font,15<<SP_ACCURACY-4); spFontAddButton( middle_font, 'A', SP_BUTTON_LEFT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'B', SP_BUTTON_RIGHT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'X', SP_BUTTON_DOWN_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'Y', SP_BUTTON_UP_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'L', SP_BUTTON_L_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'R', SP_BUTTON_R_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'S', SP_BUTTON_START_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); spFontAddButton( middle_font, 'E', SP_BUTTON_SELECT_NAME, spGetRGB(230,230,230), spGetRGB(64,64,64)); settings_set_middle_font(middle_font); spFontSetShadeColor(FONT_BORDER_1); if (countdown_font) spFontDelete(countdown_font); countdown_font = spFontLoad(FONT_LOCATION,FONT_COUNTDOWN_SIZE*spGetSizeFactor()>>SP_ACCURACY); spFontAdd(countdown_font,"0123",FONT_COLOR_1); spFontAddBorder(countdown_font,FONT_BORDER_1); settings_set_countdown_font(countdown_font); spFontSetShadeColor(FONT_BORDER_1); if (highscore_font) spFontDelete(highscore_font); highscore_font = spFontLoad(FONT_LOCATION,FONT_HIGHSCORE_SIZE*spGetSizeFactor()>>SP_ACCURACY); spFontAdd(highscore_font,"ABCDEFGHIJKLMNOPQRSTUVWXYZ",FONT_COLOR_1); spFontAddBorder(highscore_font,FONT_BORDER_1); settings_set_highscore_font(highscore_font); //Particles resize_particle(w,h); init_stars(); }
void draw_account(spFontPointer font,spFontPointer font_small,spFontPointer font_very_small) { SDL_Surface* screen = spGetWindowSurface(); spFontDrawRight( screen->w-2, 2, 0, "[X] Back", font_very_small ); if (spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS) spFontDrawMiddle( screen->w*2/3, 2, 0, "[B] Enter letter", font_very_small ); if (spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS) spFontDraw( 2, 2, 0, "[L] & [R]: Select Row", font_very_small ); else spFontDraw( 2, 2, 0, SP_PAD_NAME": Select Row", font_very_small ); switch (mode) { case 0: spFontDrawMiddle( 2*screen->w/3, 1*screen->h/9, 0, ">>> Account Creating <<<", font); spFontDrawMiddle( 2*screen->w/3, 2*screen->h/11, 0, "Press [S] to create the account", font_small); break; case 1: spFontDrawMiddle( 2*screen->w/3, 1*screen->h/9, 0, ">>> Account Editing <<<", font); spFontDrawMiddle( 2*screen->w/3, 2*screen->h/11, 0, "Press [S] to save the changes", font_small); spFontDrawMiddle( 2*screen->w/3, 2*screen->h/8, 0, "Press [E] to delete the account", font_small); break; } char* mom_line = NULL; switch (line) { case 0: mom_line = shortName; break; case 1: mom_line = longName; break; case 2: mom_line = password; break; case 3: mom_line = mail; break; } spLine( 2*screen->w/3 + spFontWidth(mom_line,font)/2+1, (line*2+6)*screen->h/18, 0, 2*screen->w/3 + spFontWidth(mom_line,font)/2+1, (line*2+7)*screen->h/18, 0, ((blink/512)&1)?0:65535); spFontDrawRight( screen->w/3, 3*screen->h/9, 0, "3 Letter Nick:", font); spFontDrawMiddle( 2*screen->w/3, 3*screen->h/9, 0, shortName, font); spLine( screen->w/3+10, 7*screen->h/18, 0, screen->w-10, 7*screen->h/18,0,65535); spFontDrawMiddle( 2*screen->w/3, 7*screen->h/18, 0, "(e.g. JHN)", font_very_small); spFontDrawRight( screen->w/3, 4*screen->h/9, 0, "Display Nick:", font); spFontDrawMiddle( 2*screen->w/3, 4*screen->h/9, 0, longName, font); spLine( screen->w/3+10, 9*screen->h/18, 0, screen->w-10, 9*screen->h/18,0,65535); spFontDrawMiddle( 2*screen->w/3, 9*screen->h/18, 0, "(e.g. JohnSmith)", font_very_small); spFontDrawRight( screen->w/3, 5*screen->h/9, 0, "Password:"******"(alphanumeric, e.g. aBc123)", font_very_small); spFontDrawRight( screen->w/3, 6*screen->h/9, 0, "E-Mail address:", font); spFontDrawMiddle( 2*screen->w/3, 6*screen->h/9, 0, mail, font); spLine( screen->w/3+10, 13*screen->h/18, 0, screen->w-10, 13*screen->h/18,0,65535); spFontDrawMiddle( 2*screen->w/3, 13*screen->h/18, 0, "(for score being beaten notification)", font_very_small); if (spIsKeyboardPolled() && spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS) spBlitSurface(screen->w/2,screen->h-spGetVirtualKeyboard()->h/2,0,spGetVirtualKeyboard()); switch (askMode) { case 1: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Are you sure to delete your profile forever?", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[S] Yes... [X] Hell No!", font); break; case 2: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Your 3 Letter Nick needs 3 alphanumeric letters.", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font); break; case 3: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Only numbers and characters are allowed for your Nick!", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Uuups...", font); break; case 4: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Only numbers and characters are allowed for passwords!", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font); break; case 5: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "IF you enter a e-mail, make sure it contains an @.", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font); break; case 6: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Couldn't connect to Server! Check your connection.", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font); break; case 7: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account created successfully", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font); break; case 8: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account edited successfully", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font); break; case 9: spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account deleted successfully", font); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font); break; } if (spNetC4AGetStatus() > 0) { spInterpolateTargetToColor(0,3*SP_ONE/4); spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Connecting to server...", font); char buffer[256]; sprintf(buffer,"Timeout in %i.%i",spNetC4AGetTimeOut()/1000,(spNetC4AGetTimeOut()/100)%10); spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, buffer, font); } }
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 draw_border(int x1,int y1,int x2,int y2,Uint16 color) { SDL_LockSurface(spGetWindowSurface()); Uint16* pixel = (Uint16*)spGetWindowSurface()->pixels; int x,y; int r = 6 * spGetSizeFactor() >> SP_ACCURACY; spHorizentalLine(pixel,x1+r,y1,x2-x1-2*r,color,1,spGetWindowSurface()->w,spGetWindowSurface()->h); spHorizentalLine(pixel,x1+r,y2,x2-x1-2*r,color,1,spGetWindowSurface()->w,spGetWindowSurface()->h); for (x = x1; x<=x2; x++) { //Jumping over emptiness: if (x-x1 == r) x = (x2-r); for (y = y1; y<=y2; y++) if (x >= 0 && y >= 0 && x<spGetWindowSurface()->w && y<spGetWindowSurface()->h) { //left, top edge if (x-x1 < r && y-y1 < r) { int value = (r-x+x1)*(r-x+x1)+(r-y+y1)*(r-y+y1); if ( value > (r-1)*(r-1) && value < r*r) pixel[x+y*spGetWindowSurface()->w] = color; } else //right, top edge if (x2-x < r && y-y1 < r) { int value = (r-x2+x)*(r-x2+x)+(r-y+y1)*(r-y+y1); if ( value > (r-1)*(r-1) && value < r*r) pixel[x+y*spGetWindowSurface()->w] = color; } else //left, bottom edge if (x-x1 < r && y2-y < r) { int value = (r-x+x1)*(r-x+x1)+(r-y2+y)*(r-y2+y); if ( value > (r-1)*(r-1) && value < r*r) pixel[x+y*spGetWindowSurface()->w] = color; } else //right, bottom edge if (x2-x < r && y2-y < r) { int value = (r-x2+x)*(r-x2+x)+(r-y2+y)*(r-y2+y); if ( value > (r-1)*(r-1) && value < r*r) pixel[x+y*spGetWindowSurface()->w] = color; } else if (x == x1 | y == y1 | x == x2 | y == y2) pixel[x+y*spGetWindowSurface()->w] = color; } } SDL_UnlockSurface(spGetWindowSurface()); }
void resize(Uint16 w,Uint16 h) { //Setup of the new/resized window spSetPerspective(50.0,(float)spGetWindowSurface()->w/(float)spGetWindowSurface()->h,0.1,100); }