Esempio n. 1
0
void GameTable::Tick(SDL_Renderer* renderer)
{

    // Background Rendering
    BackgroundRenderer(renderer);

    // Only render the table's content when not paused
    switch (state)
    {
    case GameTableState::Running:
        RenderRunning();
        break;
    case GameTableState::Paused:
        RenderPause();
        break;
    case GameTableState::Ended:
        break;
    case GameTableState::InputDisabled:
        RenderRunning();
        break;
    default:
        break;
    }

    Update();

    // UI Drawing
    RenderUserInterface(renderer);
}
Esempio n. 2
0
// ============================================================================================
// ================================= Renderering ==============================================
// ============================================================================================
void Renderer::Render( )
{
	SDL_RenderClear( renderer );

	switch ( gameState )
	{
		case GameState::MainMenu:
		case GameState::Options:
		case GameState::Lobby:
			RenderMenu();
			break;

		case GameState::InGame:
			RenderGameObjects();
		FALLTHROUGH
		case GameState::InGameWait:
			RenderText();
			break;

		case GameState::Paused:
			RenderPause();
		FALLTHROUGH
		case GameState::GameOver:
			RenderText();
			break;
		default:
			break;
	}

	SDL_RenderPresent( renderer );
}
Esempio n. 3
0
void GameApp::Render(){
	glClear(GL_COLOR_BUFFER_BIT);
	switch (state){
		case MAIN_MENU:
			RenderMainMenu();
			break;
		case GAMEPLAY:
			RenderGamePlay();
			break;
		case GAME_OVER:
			RenderGameOver();
			break;
		case PAUSE:
			RenderPause();
			break;
	}
	SDL_GL_SwapWindow(displayWindow);	
}
Esempio n. 4
0
    void BacteroidsState::Render()
    {
        Renderer &renderer = GetRenderer();
        renderer.SetTime(m_time.GetTimeMicros());

        renderer.SetView(m_playView);

        renderer.BindColorShader();
        renderer.SetColor(Color(0.05f, 0.13f, 0.15f));
        renderer.DrawFilledRectangle(PLAY_AREA_LEFT, PLAY_AREA_BOTTOM, PLAY_AREA_RIGHT, PLAY_AREA_TOP);

        for (size_t_32 i = 0; i < m_objects.Size(); i++)
        {
            GameObject *obj = m_objects[i];

            vec2f p = obj->GetPosition();
            float r = obj->GetRadius() * 1.1f;

            if ((p.x > PLAY_AREA_LEFT - r && p.x < PLAY_AREA_RIGHT + r &&
                 p.y > PLAY_AREA_BOTTOM - r && p.y < PLAY_AREA_TOP + r) == false)
            {
                continue;
            }

            renderer.BindShader(obj->GetShader());

            const vec2f vel2 = obj->GetVelocity();
            const vec4f velocity(vel2.x, vel2.y, 0.0f, 0.0f);
            renderer.GetGraphics()->SetUniform(m_uniforms.m_velocity, velocity);
            obj->Render(&renderer, m_uniforms);
        }

        renderer.BindColorShader();
        m_damageFade.Render(&renderer);
        m_pauseFade.Render(&renderer);


        renderer.SetView(GetDefaultView());

        if (m_time.IsPaused())
        {
            RenderPause();
        }
        else if (m_player.IsDead())
        {
            RenderGameOver();
        }

        {
            TextLayout layout(renderer, 0.0f, 0.0f);

            renderer.BindFontShader();
            renderer.SetColor(Color(1.0f, 1.0f, 1.0f));
            renderer.SetFontScale(1.0f);

            char buf[64];
            StringPrintF(buf, "Score: %i", m_score);
            layout.AddText(buf, 0.0f);
            layout.AddLine();

            StringPrintF(buf, "Kills: %i", m_kills);
            layout.AddText(buf, 0.0f);
            layout.AddLine();

            const float ptPerKill = (m_kills) ? (m_score / float(m_kills)) : 0;
            StringPrintF(buf, "pt per kill: %.1f", ptPerKill);
            layout.AddText(buf, 0.0f);
            layout.AddLine();

            const float hx = 10.0f;
            const float hy = layout.m_cursor.y + 10.0f;

            renderer.BindColorShader();
            renderer.SetColor(Color(0.5f, 0.5f, 0.5f));
            renderer.DrawFilledRectangle(hx, hy, hx + 100.0f, hy + 10.0f);
            renderer.SetColor(Color(0.85f, 0.05f, 0.05f));
            renderer.DrawFilledRectangle(hx, hy, hx + m_player.GetHealth(), hy + 10.0f);
        }

        {
            const Viewport vp = renderer.GetView().m_viewport;

            TextLayout layout(renderer, 0.0f, vp.h);

            renderer.BindFontShader();
            renderer.SetColor(Color(1.0f, 1.0f, 1.0f));
            renderer.SetFontScale(1.0f);

            char buf[64];
            StringPrintF(buf, "[M] - Muted: %s", GetAudio().IsMuted() ? "yes" : "no");
            layout.AddLines(-1);
            layout.AddText(buf, 0.0f);
        }
    }