Beispiel #1
0
void LButton::render()
{
	//Show current button sprite
	gButtonSpriteSheetTexture.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
	gButtonSpriteSheetTexture1.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
	gButtonSpriteSheetTexture2.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
}
Beispiel #2
0
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 background texture to screen
				gBackgroundTexture.render( 0, 0 );

				//Render Foo' to the screen
				gFooTexture.render( 240, 190 );

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

	//Free resources and close SDL
	close();

	return 0;
}
void Particle::render() {
  //Show image
  mTexture->render( mPosX, mPosY );

  //Show shimmer
  if( mFrame % 2 == 0 ) {
    gShimmerTexture.render( mPosX, mPosY );
  }

  //Animate
  mFrame++;
}
Beispiel #4
0
int main(int argc, const char * argv[]) {
    init();
    loadMedia();
    
    bool quit = false;
    
    SDL_Event e;
    
    int frame = 0;
    
    int scrollingOffset = gameState.scrollingOffset;
    
    while (!quit) {
        while (SDL_PollEvent(&e) != 0) {
            if (e.type == SDL_QUIT) {
                quit = true;
            }
            batman->handleEvent(e);
        }
        
        SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
        SDL_RenderClear(gRenderer);
        
        // load background first with offset
        if (batman->isMovingFwd()) {
            -- scrollingOffset;
            if (scrollingOffset < -gBackGroundTexture.getWidth()) {
                scrollingOffset = 0;
            }
        }
        
        gBackGroundTexture.render(scrollingOffset, 0, gRenderer);
        gBackGroundTexture.render(scrollingOffset + gBackGroundTexture.getWidth(), 0, gRenderer);
        
        batman->render(50, SCREEN_HEIGHT - 60);
        
        SDL_RenderPresent(gRenderer);
    }
    
    // save game state
    gameState.scrollingOffset = scrollingOffset;
    printf("saving game state: scrolling offset %d\n", gameState.scrollingOffset);
    
    // close
    close();
    
    
    return 0;
}
void Dot::render() {
  //Show the dot
  gDotTexture.render( mPosX, mPosY );

  //Show particles on top of dot
  renderParticles();
}
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;

			//Run the thread
			int data = 101;
			SDL_Thread* threadID = SDL_CreateThread( threadFunction, "LazyThread", (void*)data );

			//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 prompt
				gSplashTexture.render( 0, 0 );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}

			//Remove timer in case the call back was not called
			SDL_WaitThread( threadID, NULL );
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
Beispiel #7
0
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;

      //Current rendered texture
      LTexture* currentTexture = NULL;

      //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;
          }
        }

        //Set texture based on current keystate
        const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL );
        if( currentKeyStates[ SDL_SCANCODE_UP ] ) {
          currentTexture = &gUpTexture;
        } else if( currentKeyStates[ SDL_SCANCODE_DOWN ] ) {
          currentTexture = &gDownTexture;
        } else if( currentKeyStates[ SDL_SCANCODE_LEFT ] ) {
          currentTexture = &gLeftTexture;
        } else if( currentKeyStates[ SDL_SCANCODE_RIGHT ] ) {
          currentTexture = &gRightTexture;
        } else {
          currentTexture = &gPressTexture;
        }

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

        //Render current texture
        currentTexture->render( 0, 0 );

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

  //Free resources and close SDL
  close();

  return 0;
}
Beispiel #8
0
void render()
{
    GLfloat half_width  = SCREEN_WIDTH  / 2.f;
    GLfloat half_height = SCREEN_HEIGHT / 2.f;

    //Clear color buffer
    glClear( GL_COLOR_BUFFER_BIT );

    //Reset transformations
    glLoadIdentity();

    //Screen quad fills render surface
    glTranslatef( half_width, half_height, 0.0 );
    glBegin( GL_QUADS );
        glColor3f( 1.f, 1.f, 1.f );
        glVertex2f( -half_width, -half_height );
        glVertex2f(  half_width, -half_height );
        glVertex2f(  half_width,  half_height );
        glVertex2f( -half_width,  half_height );
    glEnd();

    //Render the texture
    gOpenGLTexture.render( 0.0, 0.0 );

    //Update screen
    glutSwapBuffers();
}
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;
}
Beispiel #10
0
void Tile::render( SDL_Rect& camera )
{
    //If the tile is on screen
    if( checkCollision( camera, mBox ) )
    {
        //Show the tile
        gTileTexture.render( mBox.x - camera.x, mBox.y - camera.y, &gTileClips[ mType ] );
    }
}
void Scoreboard::render( SDL_Renderer* gRenderer, TTF_Font* gFont, LTexture gTextTexture ) {
	string s = std::to_string( static_cast<long long>( score ) );
	s = string( 10 - s.size(), ' ' ) + s;
	string text = "Score: " + s;
	gTextTexture.loadFromRenderedText( text, textColor );
	gTextTexture.setBlendMode( SDL_BLENDMODE_BLEND );
	gTextTexture.setAlpha( 150 );
	gTextTexture.render( xPos, yPos, gRenderer );
}
Beispiel #12
0
bool IntroRender (int x, int y)
{
    //Event handler
    SDL_Event e;
    LTexture texture;
    std::string counter="";

    for (int i=0; i<1502; i+=2)
    {
        //Handle events on queue
        while( SDL_PollEvent( &e ) != 0 )
        {
            //Clear screen
            SDL_SetRenderDrawColor( gRenderer, 0, 0, 0, 0 );
            SDL_RenderClear( gRenderer );
            //User requests quit
            if( e.type == SDL_QUIT )
            {
                return false;
            }
        }
        bool quit=false;
        counter+="IntroPics/Intro";
        counter+=IntToString(i+1);
        counter+=".jpg";
        Intro [i]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
        gSplashTexture.render(x, y,Intro[i],IntroW, IntroH);
        //Update screen
        SDL_RenderPresent( gRenderer );
        if (Intro [i]!=NULL)

        {
            SDL_DestroyTexture( Intro [i] );
            Intro [i] = NULL;
        };

        printf(counter.c_str());
        counter="";
        SDL_Delay(10);

    }

//    //Render splash
//    for (int i=0 ; i<1410; i++)
//
//    {
//    if (Intro [i]!=NULL)
//
//        {
//            SDL_DestroyTexture( Intro [i] );
//           Intro [i] = NULL;
//        };
//    if (i<910)
//    Intro [i+500]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
//    }
    return true;
}
Beispiel #13
0
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;

      //Current animation frame
      int frame = 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;
          }
        }

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

        //Render current frame
        SDL_Rect* currentClip = &gSpriteClips[ frame / 4 ];
        gSpriteSheetTexture.render( ( SCREEN_WIDTH - currentClip->w ) / 2, ( SCREEN_HEIGHT - currentClip->h ) / 2, currentClip );

        //Update screen
        SDL_RenderPresent( gRenderer );

        //Go to next frame
        ++frame;

        //Cycle animation
        if( frame / 4 >= WALKING_ANIMATION_FRAMES ) {
          frame = 0;
        }
      }
    }
  }

  //Free resources and close SDL
  close();

  return 0;
}
void render()
{
    //Clear color buffer
    glClear( GL_COLOR_BUFFER_BIT );

    //Initialize modelview matrix
    glLoadIdentity();

    //Render textured quad using VBOs
    gVBOTexture.render( ( SCREEN_WIDTH - gVBOTexture.imageWidth() ) / 2.f, ( SCREEN_HEIGHT - gVBOTexture.imageHeight() ) / 2.f );
}
void render()
{
    //Clear color buffer
    glClear( GL_COLOR_BUFFER_BIT );

    //Render texture stretched
    gStretchedTexture.render( 0.f, 0.f, NULL, &gStretchRect );

    //Update screen
    glutSwapBuffers();
}
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;
}
Beispiel #17
0
void render()
{
    // clear color buffer
    glClear(GL_COLOR_BUFFER_BIT);

    // render OpenGL texture
    gCircleTexture.render((SCREEN_WIDTH - gCircleTexture.imageWidth()) / 2.f,
            (SCREEN_HEIGHT - gCircleTexture.imageHeight()) / 2.f);

    // update screen
    glutSwapBuffers();
}
Beispiel #18
0
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 callback
			SDL_TimerID timerID = SDL_AddTimer(3 * 1000, callback, "3 seconds waited	!");

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

				//clear the screen
				SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
				SDL_RenderClear(gRenderer);

				//render splash 
				gSplashTexture.render(0, 0);

				//Update screen
				SDL_RenderPresent(gRenderer);

			}
			SDL_RemoveTimer(timerID);
		}
		close();
	}
}
void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}

		//Handle input for the dot
		dot.handleEvent( e );
	}
	
	//Move the dot
	dot.move();

	//Scroll background
	--scrollingOffset;
	if( scrollingOffset < -gBGTexture.getWidth() )
	{
		scrollingOffset = 0;
	}

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

	//Render background
	gBGTexture.render( scrollingOffset, 0 );
	gBGTexture.render( scrollingOffset + gBGTexture.getWidth(), 0 );

	//Render objects
	dot.render();

	//Update screen
	SDL_RenderPresent( gRenderer );
}
Beispiel #20
0
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;
          }
          //Joystick button press
          else if( e.type == SDL_JOYBUTTONDOWN ) {
            //Play rumble at 75% strenght for 500 milliseconds
            if( SDL_HapticRumblePlay( gControllerHaptic, 0.75, 500 ) != 0 ) {
              printf( "Warning: Unable to play rumble! %s\n", SDL_GetError() );
            }
          }
        }

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

        //Render splash image
        gSplashTexture.render( 0, 0 );

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

  //Free resources and close SDL
  close();

  return 0;
}
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 );
}
Beispiel #22
0
void render()
{
    // clear color buffer
    glClear(GL_COLOR_BUFFER_BIT);

    // calculate centered offsets
    GLfloat x = (SCREEN_WIDTH - gCheckerBoardTexture.textureWidth()) / 2.f;
    GLfloat y = (SCREEN_HEIGHT - gCheckerBoardTexture.textureHeight()) / 2.f;

    // render checkerboard texture
    gCheckerBoardTexture.render(x, y);

    // update screen
    glutSwapBuffers();
}
void render()
{
    //Clear color and stencil buffer
    glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
    glLoadIdentity();

    //Disable rendering to the color buffer
    glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );

    //Start using the stencil
    glEnable( GL_STENCIL_TEST );

    //Place a 1 where rendered
    glStencilFunc( GL_ALWAYS, 1, 1 );

    //Replace where rendered
    glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE );

    //Render stencil triangle
    glTranslatef( gPolygonX, gPolygonY, 0.f );
    glRotatef( gPolygonAngle, 0.f, 0.f, 1.f );
    glBegin( GL_TRIANGLES );
        glVertex2f(           -0.f / 4.f, -SCREEN_HEIGHT / 4.f );
        glVertex2f(   SCREEN_WIDTH / 4.f,  SCREEN_HEIGHT / 4.f );
        glVertex2f(  -SCREEN_WIDTH / 4.f,  SCREEN_HEIGHT / 4.f );
    glEnd();

    //Reenable color
    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );

    //Where a 1 was not rendered
    glStencilFunc( gStencilRenderOp, 1, 1 );

    //Keep the pixel
    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );

    //Render stenciled texture
    glLoadIdentity();
    gTexture.render( ( SCREEN_WIDTH - gTexture.imageWidth() ) / 2.f, ( SCREEN_HEIGHT - gTexture.imageHeight() ) / 2.f );

    //Finished using stencil
    glDisable( GL_STENCIL_TEST );

    //Update screen
    glutSwapBuffers();
}
Beispiel #24
0
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;
}
Beispiel #25
0
void LBitmapFont::renderText( int x, int y, std::string text )
{
    //If the font has been built
    if( mBitmap != NULL )
    {
		//Temp offsets
		int curX = x, curY = y;

        //Go through the text
        for( int i = 0; i < text.length(); ++i )
        {
            //If the current character is a space
            if( text[ i ] == ' ' )
            {
                //Move over
                curX += mSpace;
            }
            //If the current character is a newline
            else if( text[ i ] == '\n' )
            {
                //Move down
                curY += mNewLine;

                //Move back
                curX = x;
            }
            else
            {
                //Get the ASCII value of the character
                int ascii = (unsigned char)text[ i ];

                //Show the character
				mBitmap->render( curX, curY, &mChars[ ascii ] );

                //Move over the width of the character with one pixel of padding
                curX += mChars[ ascii ].w + 1;
            }
        }
    }
}
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;
}
Beispiel #27
0
	virtual void render()
	{
		if (!mMinimized)
		{
			//Initialize renderer color
			SDL_SetRenderDrawColor(mRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
			SDL_RenderClear(mRenderer);
			SDL_Rect stretchRect;
			stretchRect =
			{	0, 0, mWidth, mHeight};
			gBackgroundTexture.render(mRenderer, 0, 0, &stretchRect);

			for (std::list<Panel*>::iterator iter = pList_->begin(); iter != pList_->end(); iter++)
			{
				Panel *p = (*iter);
				p->render(mRenderer);
			}
		}

		//Update screen
		SDL_RenderPresent(mRenderer);
	}
Beispiel #28
0
void PlayerDisplayingHitsAndMiss (char AImap [10][10])
{
    int xchange = gScreenRect.w/23.9473684211;
    int ychange = ceil(gScreenRect.h/11.9512195122);
    int rows=0;

    for (int ys=gScreenRect.h/5.76470588235; ys<gScreenRect.h/1.00926879506; ys+=ychange)
    {
        int cols=0;
        for (int xs=ceil(gScreenRect.w/2.82608695652)+10; xs<gScreenRect.w/1.2962962963; xs+=xchange)
        {

            if (AImap[cols][rows]=='X')
            {
                gSplashTexture.render(xs,ys,Miss,xchange, ychange);
            }
            cols++;
        }
        rows++;

    }


}
Beispiel #29
0
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;

			//Run the threads
			srand( SDL_GetTicks() );
			SDL_Thread* threadA = SDL_CreateThread( worker, "Thread A", (void*)"Thread A" );
			SDL_Delay( 16 + rand() % 32 );
			SDL_Thread* threadB = SDL_CreateThread( worker, "Thread B", (void*)"Thread B" );
			
			//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 splash
				gSplashTexture.render( 0, 0 );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}

			//Wait for threads to finish
			SDL_WaitThread( threadA, NULL );
			SDL_WaitThread( threadB, NULL );
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
Beispiel #30
0
void Dot::render() {
  //Show the dot
  gDotTexture.render( mPosX, mPosY );
}