Пример #1
0
/* Draw the changes to the screen.
Remove the changing objects, redraw the strings and draw the changing objects again.
 */
void BaseEngine::DrawChanges()
{
	// Remove objects from their old positions
	UndrawChangingObjects();
	// Draw the text for the user
	DrawStrings();
	// Draw objects at their new positions
	DrawChangingObjects();
}
Пример #2
0
/* Draw the screen - copy the background buffer, then draw the text and objects. */
void BaseEngine::DrawScreen()
{
	// First draw the background
	//this->CopyBackgroundPixels( 100, 100, 100, 100 );
	CopyAllBackgroundBuffer();
	// And finally, draw the text
	DrawStrings();
	// Then draw the changing objects
	DrawChangingObjects();
}
Пример #3
0
/* Draw the changes to the screen.
Remove the changing objects, redraw the strings and draw the changing objects again.
 */
void Demo4Main::DrawChanges()
{
	// NEW IF
	if ( m_state == stateInit )
		return; // Do not draw objects if initialising

	// Remove objects from their old positions
	UndrawChangingObjects();
	// Draw the text for the user
	DrawStrings();
	// Draw objects at their new positions
	DrawChangingObjects();
}
Пример #4
0
	//後更新
	void Player::OnUpdate2() {
		auto PtrPs = GetComponent<PsSphereBody>();
		auto Ptr = GetComponent<Transform>();
		Ptr->SetPosition(PtrPs->GetPosition());
		//回転の計算
		Vec3 Angle = GetMoveVector();
		if (Angle.length() > 0.0f) {
			auto UtilPtr = GetBehavior<UtilBehavior>();
			//補間処理を行わない回転。補間処理するには以下1.0を0.1などにする
			UtilPtr->RotToHead(Angle, 1.0f);
		}
		//文字列の表示
		DrawStrings();
	}
Пример #5
0
/* Draw the screen - copy the background buffer, then draw the text and objects. */
void Demo4Main::DrawScreen()
{
	// First draw the background
	//this->CopyBackgroundPixels( 100, 100, 100, 100 );
	CopyAllBackgroundBuffer();
	// And finally, draw the text
	DrawStrings();

	// NEW IF
	if ( m_state == stateInit )
		return; // Do not draw objects if initialising

	// Then draw the changing objects
	DrawChangingObjects();
}
Пример #6
0
	void Ball::OnUpdate2() {
		DrawStrings();
	}
Пример #7
0
	//後更新
	void Player::OnUpdate2() {
		//文字列の表示
		DrawStrings();
	}
Пример #8
0
/*
Overridable function, if necessary, for doing all of the drawing.
Base class version checks whether a redraw is needed and does nothing if not. See Redraw() function.
If a redraw is needed then there is an option to either redraw the whole screen or just redraw the moving objects.
If redrawing the whole screen then:
1a) SetupBackgroundBuffer is called to draw the background to the background buffer.
1b) DrawScreen is called to copy the background buffer onto the screen, then draw the moving objects.
1c) SDL_UpdateRect() is called to actually redraw the whole screen.
If only redrawing the moving objects then:
2a) DrawChangingObjects() is called to remove the objects from their old positions, and redraw them in their new positions.
2b) GetUpdateRectanglesForChangingObjects() is called to calculate where on the screen needs redrawing.
2c) SDL_UpdateRects() is called to redraw the parts of the screen which changed.
*/
void BaseEngine::GameRender(void)
{
	if ( !m_bNeedsRedraw )
		return;

	// Just drawn so no more redraw needed
	m_bNeedsRedraw = false;
	// Note: the redraw flags must only be set early in this method, not at the end, since the drawing/moving of the moving objects may
	// potentially flag a win/lose condition and a state change, which will set the redraw flag again to force a full draw after the 
	// state changes.

	if ( m_bWholeScreenUpdate )
	{
		// Drawn whole screen now, so no need to draw it again. See note above about the importance of not resetting this after DrawChangingObjects()
		m_bWholeScreenUpdate = false;

		// Lock surface if needed
		if (SDL_MUSTLOCK(m_pActualScreen))
		{
			m_bInsideDraw = true;
			if (SDL_LockSurface(m_pActualScreen) < 0) 
				return;
		}

		// Draw the screen as it should appear now.
		// First draw the background
		//this->CopyBackgroundPixels( 100, 100, 100, 100 );
		CopyAllBackgroundBuffer();
		// Draw the text for the user
		DrawStrings(); // Single function in case people want to use that instead
		DrawStringsUnderneath();	// Draw the string underneath the other objects here
		// Then draw the changing objects
		DrawObjects();
		// Another option for where to put the draw strings code - if you want it on top of the moving objects
		DrawStringsOnTop();

		// Unlock if needed
		if (SDL_MUSTLOCK(m_pActualScreen)) 
			SDL_UnlockSurface(m_pActualScreen);
		m_bInsideDraw = false;

		SDL_UpdateTexture( m_pSDL2Texture,NULL,m_pActualScreen->pixels,m_pActualScreen->pitch );
		//SDL_RenderClear( m_pSDL2Renderer );
		SDL_RenderCopy( m_pSDL2Renderer,m_pSDL2Texture,NULL,NULL );
		SDL_RenderPresent( m_pSDL2Renderer );

		//SDL_UpdateRect(m_pActualScreen, 0, 0, m_iScreenWidth, m_iScreenHeight);    
	}
	else
	{
		// Here we assume that the background buffer has already been set up

		// Lock surface if needed
		if (SDL_MUSTLOCK(m_pActualScreen))
		{
			m_bInsideDraw = true;
			if (SDL_LockSurface(m_pActualScreen) < 0) 
				return;
		}

		// Remove objects from their old positions
		UndrawObjects();
		// Remove the old strings be re-drawing the background
		UnDrawStrings(); 
		// Draw the text for the user
		DrawStrings(); // Single function in case people want to use that instead
		DrawStringsUnderneath();	// Draw the string underneath the other objects here
		// Draw objects at their new positions
		DrawObjects();
		// Another option for where to put the draw strings code - if you want it on top of the moving objects
		DrawStringsOnTop(); 

		// Unlock if needed
		if (SDL_MUSTLOCK(m_pActualScreen)) 
			SDL_UnlockSurface(m_pActualScreen);
		m_bInsideDraw = false;

		// Copy the screen display into the window and display it
		SDL_UpdateTexture( m_pSDL2Texture,NULL,m_pActualScreen->pixels,m_pActualScreen->pitch );
		//SDL_RenderClear( m_pSDL2Renderer );
		SDL_RenderCopy( m_pSDL2Renderer,m_pSDL2Texture,NULL,NULL );
		SDL_RenderPresent( m_pSDL2Renderer );
	}
}