Esempio n. 1
0
void World::AddBall( vec2 const& pos )
{
    Entity entity;

    f32 grad = 32.f;
    f32 prad = GraphicsToPhysicsRadius( grad );
    vec2 gpos{ pos.x - grad, pos.y - grad };
    vec2 ppos = GraphicsToPhysicsPos( gpos ) + vec2{ prad, -prad };
    
    entity.graphics = graphics->AddSphere( gpos, grad );
    entity.physics = physics->AddSphere( ppos, prad );

    entities.push_back( entity );
}
Esempio n. 2
0
void World::AddBox( vec2 const& pos )
{
    Entity entity;

    vec2 gdim = { 32.f, 32.f };
    vec2 gpos = pos - gdim * 0.5f;
    vec2 pdim = GraphicsToPhysicsDim( gdim );
    vec2 ppos = GraphicsToPhysicsPos( gpos ) + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };
    
    entity.graphics = graphics->AddBox( gpos, gdim );
    entity.physics = physics->AddBox( ppos, pdim );

    entities.push_back( entity );
}
Esempio n. 3
0
void World::AddPoly( vec2 const& pos )
{
    Entity entity;

    vec2 gdim = { 32.f, 32.f };
    vec2 gpos = pos - gdim * 0.5f;
    vec2 pdim = GraphicsToPhysicsDim( gdim );
    vec2 ppos = GraphicsToPhysicsPos( gpos ) + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };

    entity.graphics = graphics->AddPolygon( gpos, gdim );
    entity.physics = physics->AddPolygon( ppos, pdim );
    //std::cout << "ok pas de prob\n";
    entities.push_back( entity );
}
Esempio n. 4
0
void World::SetupScene()
{
    // Create walls
    {
        Entity entity;

        vec2 gpos{ 0.f, 0.f };
        vec2 gdim{ 1280.f, 16.f };
        vec2 ppos = GraphicsToPhysicsPos( gpos );
        vec2 pdim = GraphicsToPhysicsDim( gdim );

        ppos = ppos + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };

        entity.graphics = graphics->AddWall( gpos, gdim );
        entity.physics = physics->AddWall( ppos, pdim );

        entities.push_back( entity );
    }

    {
        Entity entity;

        vec2 gpos{ 0.f, 704.f };
        vec2 gdim{ 1280.f, 16.f };
        vec2 ppos = GraphicsToPhysicsPos( gpos );
        vec2 pdim = GraphicsToPhysicsDim( gdim );

        ppos = ppos + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };

        entity.graphics = graphics->AddWall( gpos, gdim );
        entity.physics = physics->AddWall( ppos, pdim );

        entities.push_back( entity );
    }

    {
        Entity entity;

        vec2 gpos{ 0.0f, 0.0f };
        vec2 gdim{ 16.f, 1280.f };
        vec2 ppos = GraphicsToPhysicsPos( gpos );
        vec2 pdim = GraphicsToPhysicsDim( gdim );

        ppos = ppos + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };

        entity.graphics = graphics->AddWall( gpos, gdim );
        entity.physics = physics->AddWall( ppos, pdim );

        entities.push_back( entity );
    }

    {
        Entity entity;

        vec2 gpos{ 1264.f, 0.f };
        vec2 gdim{ 16.f, 1280.f };
        vec2 ppos = GraphicsToPhysicsPos( gpos ); 
        vec2 pdim = GraphicsToPhysicsDim( gdim );

        ppos = ppos + vec2{ pdim.x * 0.5f, -pdim.y * 0.5f };

        entity.graphics = graphics->AddWall( gpos, gdim );
        entity.physics = physics->AddWall( ppos, pdim );
        
        entities.push_back( entity );
    }
}