当前位置: 首页>>代码示例>>C++>>正文


C++ LTexture::getHeight方法代码示例

本文整理汇总了C++中LTexture::getHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ LTexture::getHeight方法的具体用法?C++ LTexture::getHeight怎么用?C++ LTexture::getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LTexture的用法示例。


在下文中一共展示了LTexture::getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addProj

void addProj(Player pl)
{
	int x = pl.getPosX();
	Projectile * tmp = new Projectile(x, SCREEN_HEIGHT - gProjTexture.getHeight()*2);
    tmp->setTex(&gProjTexture);
	Projects.push_back(tmp);
    gameObjects.push_back(tmp);
}
开发者ID:nbudinov,项目名称:Game-Dev-Summer-2014,代码行数:8,代码来源:Main.cpp

示例2: ifShipHit

bool ifShipHit(int projX, int projY, int shipX, int shipY)
{
	if ( projX >= shipX  && 
		(projX < (shipX + (gShipTexture.getWidth()) ) )  && 
		(projY > shipY  ) && 
		(projY < (shipY + (gShipTexture.getHeight()) ) ) )
	{
	return true;
	}
	else 
		return false;
}
开发者ID:nbudinov,项目名称:Game-Dev-Summer-2014,代码行数:12,代码来源:Main.cpp

示例3: ifHitPlayer

bool ifHitPlayer(int playerX, int playerY, int shipProjX, int shipProjY)
{
	//cout << "px " << playerX << "py " << playerY << "sX" << shipProjX << "sY " << shipProjY << endl;
	if( shipProjX > playerX  &&
		shipProjX < playerX + gPlayerTexture.getWidth()  &&
		shipProjY > playerY - gPlayerTexture.getHeight()  )
	{
		cout << "curna TRUE";
		return true;
	}
	else {
		return false;
	}
}
开发者ID:nbudinov,项目名称:Game-Dev-Summer-2014,代码行数:14,代码来源:Main.cpp

示例4:

Dot::Dot()
{
    //Initialize the offsets
    mPosX = 0;
    mPosY = 0;

	//Set collision box dimension
	mCollider.w = gDotTexture.getWidth();
	mCollider.h = gDotTexture.getHeight();

    //Initialize the velocity
    mVelX = 0;
    mVelY = 0;
}
开发者ID:JerelynCo,项目名称:CS179.14,代码行数:14,代码来源:27_collision_detection.cpp

示例5: main

int main() {
  if(!init()) {
    printf("Failed to initialize!\n");
    return -1;
  }

  if(!loadMedia()) {
    printf("Failed to load media!\n");
    return -1;
  }

  bool quit = false;
  SDL_Event e;

  //While application is running
  while(!quit) {
    //Handle events on queue
    while(SDL_PollEvent(&e) != 0) {
      //User request quit
      if(e.type == SDL_QUIT) {
	quit = true;
      } 
      //Handle window events
      g_window.handleEvent(e);
    }
    //Only draw when not minimized
    if(!g_window.isMinimized()) {
      //Clear screen
      SDL_SetRenderDrawColor(g_renderer, 0xFF, 0xFF, 0xFF, 0xFF);
      SDL_RenderClear(g_renderer);

      //Render text textures
      g_sceneTexture.render((g_window.getWidth() - g_sceneTexture.getWidth()) / 2,
				 (g_window.getHeight() - g_sceneTexture.getHeight()) / 2 );

      //Update screen
      SDL_RenderPresent(g_renderer);
    }
  }
  close();
  return 0;
}
开发者ID:wedemalm,项目名称:lazyfoo,代码行数:42,代码来源:WindowEvents.cpp

示例6: loadMedia

bool loadMedia() {
  //Loading success flag
  bool success = true;

  //Load foo' texture
  if( !gFooTexture.loadFromFile( "40_texture_manipulation/foo.png" ) ) {
    printf( "Failed to load corner texture!\n" );
    success = false;
  } else {
    //Lock texture
    if( !gFooTexture.lockTexture() ) {
      printf( "Unable to lock Foo' texture!\n" );
    }
    //Manual color key
    else {
      //Get pixel data
      Uint32* pixels = (Uint32*)gFooTexture.getPixels();
      int pixelCount = ( gFooTexture.getPitch() / 4 ) * gFooTexture.getHeight();

      //Map colors
      Uint32 colorKey = SDL_MapRGB( SDL_GetWindowSurface( gWindow )->format, 0, 0xFF, 0xFF );
      Uint32 transparent = SDL_MapRGBA( SDL_GetWindowSurface( gWindow )->format, 0xFF, 0xFF, 0xFF, 0x00 );

      //Color key pixels
      for( int i = 0; i < pixelCount; ++i ) {
        if( pixels[ i ] == colorKey ) {
          pixels[ i ] = transparent;
        }
      }

      //Unlock texture
      gFooTexture.unlockTexture();
    }
  }

  return success;
}
开发者ID:kaprikawn,项目名称:sdl-starter,代码行数:37,代码来源:40.cpp

示例7: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//Angle of rotation
			double degrees = 0;

			//Flip type
			SDL_RendererFlip flipType = SDL_FLIP_NONE;

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
					else if( e.type == SDL_KEYDOWN )
					{
						switch( e.key.keysym.sym )
						{
							case SDLK_a:
							degrees -= 60;
							break;
							
							case SDLK_d:
							degrees += 60;
							break;

							case SDLK_q:
							flipType = SDL_FLIP_HORIZONTAL;
							break;

							case SDLK_w:
							flipType = SDL_FLIP_NONE;
							break;

							case SDLK_e:
							flipType = SDL_FLIP_VERTICAL;
							break;
						}
					}
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render arrow
				gArrowTexture.render( ( SCREEN_WIDTH - gArrowTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gArrowTexture.getHeight() ) / 2, NULL, degrees, NULL, flipType );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
开发者ID:Stephen-Lamb,项目名称:Work,代码行数:84,代码来源:15_rotation_and_flipping.cpp

示例8: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//Set text color as black
			SDL_Color textColor = { 0, 0, 0, 255 };

			//The application timer
			LTimer timer;

			//In memory text stream
			std::stringstream timeText;

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
					//Reset start time on return keypress
					else if( e.type == SDL_KEYDOWN )
					{
						//Start/stop
						if( e.key.keysym.sym == SDLK_s )
						{
							if( timer.isStarted() )
							{
								timer.stop();
							}
							else
							{
								timer.start();
							}
						}
						//Pause/unpause
						else if( e.key.keysym.sym == SDLK_p )
						{
							if( timer.isPaused() )
							{
								timer.unpause();
							}
							else
							{
								timer.pause();
							}
						}
					}
				}

				//Set text to be rendered
				timeText.str( "" );
				timeText << "Seconds since start time " << ( timer.getTicks() / 1000.f ) ; 

				//Render text
				if( !gTimeTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) )
				{
					printf( "Unable to render time texture!\n" );
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render textures
				gStartPromptTexture.render( ( SCREEN_WIDTH - gStartPromptTexture.getWidth() ) / 2, 0 );
				gPausePromptTexture.render( ( SCREEN_WIDTH - gPausePromptTexture.getWidth() ) / 2, gStartPromptTexture.getHeight() );
				gTimeTextTexture.render( ( SCREEN_WIDTH - gTimeTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gTimeTextTexture.getHeight() ) / 2 );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}
		}
	}

	//Free resources and close SDL
	close();

//.........这里部分代码省略.........
开发者ID:JerelynCo,项目名称:CS179.14,代码行数:101,代码来源:23_advanced_timers.cpp

示例9: main

int main( int argc, char* args[] )
{
    //Start up SDL and create window
    if( !init() )
    {
        printf( "Failed to initialize!\n" );
    }
    else
    {
        //Load media
        if( !loadMedia() )
        {
            printf( "Failed to load media!\n" );
        }
        else
        {
            //Main loop flag
            bool quit = false;

            //Event handler
            SDL_Event e;

            //While application is running
            while( !quit )
            {
                //Handle events on queue
                while( SDL_PollEvent( &e ) != 0 )
                {
                    //User requests quit
                    if( e.type == SDL_QUIT )
                    {
                        quit = true;
                    }

                    //Handle window events
                    gWindow.handleEvent( e );
                }

                //Only draw when not minimized
                if( !gWindow.isMinimized() )
                {
                    //Clear screen
                    SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
                    SDL_RenderClear( gRenderer );

                    //Render text textures
                    gSceneTexture.render( ( gWindow.getWidth() - gSceneTexture.getWidth() ) / 2, ( gWindow.getHeight() - gSceneTexture.getHeight() ) / 2 );

                    //Update screen
                    SDL_RenderPresent( gRenderer );
                }
            }
        }
    }

    //Free resources and close SDL
    close();

    return 0;
}
开发者ID:pmrobotix,项目名称:DemoFusion,代码行数:60,代码来源:35_window_events.cpp

示例10:

void LTexture::renderRelToScrnRel2Object(double x, double y, LTexture& obj2, double angle) {
	render(	MidPositionRelative(SCREEN_WIDTH,	obj2.getWidth(),	getWidth(),	x),
		MidPositionRelative(SCREEN_HEIGHT,	obj2.getHeight(),	getHeight(),	y),
		angle);
}
开发者ID:alex152,项目名称:HUD_proj,代码行数:5,代码来源:LTexture.c

示例11: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render current frame
				gTextTexture.render( ( SCREEN_WIDTH - gTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gTextTexture.getHeight() ) / 2 );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
开发者ID:JerelynCo,项目名称:CS179.14,代码行数:53,代码来源:16_true_type_fonts.cpp

示例12: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//Set text color as black
			SDL_Color textColor = { 0, 0, 0, 255 };

			//The frames per second timer
			LTimer fpsTimer;

			//In memory text stream
			std::stringstream timeText;

			//Start counting frames per second
			int countedFrames = 0;
			fpsTimer.start();

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
				}

				//Calculate and correct fps
				float avgFPS = countedFrames / ( fpsTimer.getTicks() / 1000.f );
				if( avgFPS > 2000000 )
				{
					avgFPS = 0;
				}
				
				//Set text to be rendered
				timeText.str( "" );
				timeText << "Average Frames Per Second " << avgFPS; 

				//Render text
				if( !gFPSTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) )
				{
					printf( "Unable to render FPS texture!\n" );
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render textures
				gFPSTextTexture.render( ( SCREEN_WIDTH - gFPSTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gFPSTextTexture.getHeight() ) / 2 );

				//Update screen
				SDL_RenderPresent( gRenderer );
				++countedFrames;
			}
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
开发者ID:cvg256,项目名称:SDLTestGame,代码行数:84,代码来源:24_calculating_frame_rate.cpp

示例13: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//Text rendering color
			SDL_Color textColor = { 0, 0, 0, 0xFF };
			SDL_Color highlightColor = { 0xFF, 0, 0, 0xFF };

			//Current input point
			int currentData = 0;

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
					else if( e.type == SDL_KEYDOWN )
					{
						switch( e.key.keysym.sym )
						{
							//Previous data entry
							case SDLK_UP:
							//Rerender previous entry input point
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), textColor );
							--currentData;
							if( currentData < 0 )
							{
								currentData = TOTAL_DATA - 1;
							}
							
							//Rerender current entry input point
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor );
							break;
							
							//Next data entry
							case SDLK_DOWN:
							//Rerender previous entry input point
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), textColor );
							++currentData;
							if( currentData == TOTAL_DATA )
							{
								currentData = 0;
							}
							
							//Rerender current entry input point
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor );
							break;

							//Decrement input point
							case SDLK_LEFT:
							--gData[ currentData ];
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor );
							break;
							
							//Increment input point
							case SDLK_RIGHT:
							++gData[ currentData ];
							gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor );
							break;
						}
					}
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render text textures
				gPromptTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, 0 );
				for( int i = 0; i < TOTAL_DATA; ++i )
				{
					gDataTextures[ i ].render( ( SCREEN_WIDTH - gDataTextures[ i ].getWidth() ) / 2, gPromptTextTexture.getHeight() + gDataTextures[ 0 ].getHeight() * i );
				}

				//Update screen
				SDL_RenderPresent( gRenderer );
//.........这里部分代码省略.........
开发者ID:aatwo,项目名称:TestProjects,代码行数:101,代码来源:33_file_reading_and_writing.cpp

示例14: loop

void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}
		//Reset start time on return keypress
		else if( e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_RETURN )
		{
			startTime = SDL_GetTicks();
		}
	}

	//Set text to be rendered
	timeText.str( "" );
	timeText << "Milliseconds since start time " << SDL_GetTicks() - startTime; 

	//Render text
	if( !gTimeTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) )
	{
		printf( "Unable to render time texture!\n" );
	}

	//Clear screen
	SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
	SDL_RenderClear( gRenderer );

	//Render textures
	gPromptTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, 0 );
	gTimeTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gPromptTextTexture.getHeight() ) / 2 );

	//Update screen
	SDL_RenderPresent( gRenderer );
}
开发者ID:peterhenryfirst,项目名称:thecyclops,代码行数:37,代码来源:22_timing.cpp

示例15: loop

void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}
	}
	
	//Calculate and correct fps
	float avgFPS = countedFrames / ( fpsTimer.getTicks() / 1000.f );
	if( avgFPS > 2000000 )
	{
		avgFPS = 0;
	}
	
	//Set text to be rendered
	timeText.str( "" );
	timeText << "Average Frames Per Second " << avgFPS; 

	//Render text
	if( !gFPSTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) )
	{
		printf( "Unable to render FPS texture!\n" );
	}

	//Clear screen
	SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
	SDL_RenderClear( gRenderer );

	//Render textures
	gFPSTextTexture.render( ( SCREEN_WIDTH - gFPSTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gFPSTextTexture.getHeight() ) / 2 );

	//Update screen
	SDL_RenderPresent( gRenderer );
	++countedFrames;
}
开发者ID:peterhenryfirst,项目名称:thecyclops,代码行数:39,代码来源:24_calculating_frame_rate.cpp


注:本文中的LTexture::getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。