예제 #1
0
void Application::Render() {

	glClear(GL_COLOR_BUFFER_BIT);

	program->setProjectionMatrix(projectionMatrix);
	program->setViewMatrix(viewMatrix);
	program->setModelMatrix(modelMatrix);

	modelMatrix.identity();
	modelMatrix.Translate(player->xPos, player->yPos, 0.0f);
	modelMatrix.Scale(0.5f, 0.5f, 1.0f);

	player->Draw(player->CurrentAnimationIndex, 8, 4, program);

	program->setModelMatrix(tileMatrix);

	tileMatrix.identity();

	DrawChunk(TileTextureSheet, map->CurrentChunk, 0.5f, 0);
	// DrawChunk(TileTextureSheet, map->FirstChunk, 0.5f, -1);
	// DrawChunk(TileTextureSheet, map->LastChunk, 0.5f, 1);

	viewMatrix.identity();
	viewMatrix.Translate(-player->xPos, -player->yPos, 0.0f);

	printf("Position : %d \n", player->Position);

	SDL_GL_SwapWindow(displayWindow);

}
예제 #2
0
파일: Space.cpp 프로젝트: treeman/Sat-E
void Space::DrawChunk( int x, int y, Vec2i offset ) { DrawChunk( Vec2i( x, y), offset ); }
예제 #3
0
파일: Space.cpp 프로젝트: treeman/Sat-E
void Space::Draw()
{
    Vec2i offset = -cam;
    Tree::ClearWindow( Tree::Color( 0xFF000000 ) );

    Vec2i chunk = CurrentChunkIndex();

    DrawChunk( chunk, offset );

    // Draw surrounding chunks
    DrawChunk( chunk.x - 1, chunk.y, offset );
    DrawChunk( chunk.x + 1, chunk.y, offset );
    DrawChunk( chunk.x, chunk.y - 1, offset );
    DrawChunk( chunk.x, chunk.y + 1, offset );

    DrawChunk( chunk.x - 1, chunk.y - 1, offset );
    DrawChunk( chunk.x - 1, chunk.y + 1, offset );
    DrawChunk( chunk.x + 1, chunk.y - 1, offset );
    DrawChunk( chunk.x + 1, chunk.y + 1, offset );

    box.Draw( offset );

    // Draw satellite
    satellite.Draw( offset );

    if( satellite.SeesWayHome() ) {
        arrow_home_spr.Move( offset );
        Tree::Draw( arrow_home_spr );
    }

    if( SETTINGS->GetValue<bool>( "bounding_box_show" ) ) {
        draw_outline( satellite.BoundingBox(), -cam );
    }

    // Draw GUI elements
    DrawCollected();
    DrawLife();
    DrawFuel();

    if( victory ) {
        Vec2i pos = satellite.GetPos() + offset;

        friend_spr.SetPosition( pos.x + 15, pos.y - 10 );
        Tree::Draw( friend_spr );

        talk_str.SetPosition( pos.x + 5, pos.y - 35 );
        talk_str.SetColor( Tree::Color( 0xffeeeeee ) );
        Tree::Draw( talk_str );

        sf::Shape black = sf::Shape::Rectangle( 0, 0, Tree::GetWindowWidth(), Tree::GetWindowHeight(),
            sf::Color( 0, 0, 0, fade ) );
        Tree::Draw( black );
    }
    else if( game_over ) {
        sf::Shape black = sf::Shape::Rectangle( 0, 0, Tree::GetWindowWidth(), Tree::GetWindowHeight(),
            sf::Color( 0, 0, 0, fade ) );
        Tree::Draw( black );
    }

    // Draw docking on top, if we can ofc
    if( dock.IsActive() ) { dock.Draw(); }
}