Exemplo n.º 1
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 );
		}
	}
}
Exemplo n.º 2
0
void StateHighscores::render(SDL_Surface* target)
{
	spClearTarget( COLOUR_BACKGROUND );

	int posOffset = spFontWidth( (unsigned char*) Utility::numToStr( file.scores.size() ).c_str(), fontB );
	int numEntries = std::min( HIGHS_ENTRIES_ON_SCREEN, (int)file.scores.size() );
	int vertOffset = ( APP_SCREEN_HEIGHT + 40 - numEntries * HIGHS_FONT_SIZE ) / 2;

	int I = drawOffset;
	for ( HighscoreFile::scoreIter iter = offsetIter; I < drawOffset + numEntries && iter != file.scores.end(); ++iter )
	{
		spFontPointer temp = fontB;
		if ( I == selOffset )
			temp = fontW;
		int yPos = APP_SCREEN_HEIGHT - vertOffset - ( I - drawOffset + 1 ) * HIGHS_FONT_SIZE;
		spFontDrawRight( posOffset + 16, yPos, -1,
						 (unsigned char*) (Utility::numToStr( I + 1 ) + "." ).c_str(), temp );
		spFontDraw( posOffset + 28, yPos, -1,
					(unsigned char*) iter->name.c_str(), temp );
		spFontDrawRight( APP_SCREEN_WIDTH - 16, yPos, -1,
						(unsigned char*) Utility::numToStr( iter->score ).c_str(), temp );
		++I;
	}

	if ( file.scores.empty() )
	{
		spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT / 2, -1,
						(unsigned char*) "No highscores set yet, go play the game!", fontB );
	}
	else
	{
		spFontDrawMiddle( APP_SCREEN_WIDTH / 2, APP_SCREEN_HEIGHT - HIGHS_FONT_SIZE, -1,
						(unsigned char*) "Press \""SP_BUTTON_B_NAME"\" to load the replay for a score. Press \""SP_BUTTON_START_NAME"\" to exit.", fontHint );
	}
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
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 );
	*/
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
0
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);
	}
}