Beispiel #1
0
SoundSystem::SoundSystem(Game *game){
    this->game = game;

    Renderable* entity = game->scene->getWorld()->createRenderable("box");
    entity->setPosition(glm::vec3(0,0,0));
    entity->setColor(glm::vec3(1.0,1.0,1.0));

    Renderable* entity2 = game->scene->getWorld()->createRenderable("cube");
	entity2->setPosition(glm::vec3(2.0, 0, 0));
	entity2->setColor(glm::vec3(0.5, 1.0, 1.0));

    Renderable* entity3 = game->scene->getWorld()->createRenderable("cube");
	entity3->setPosition(glm::vec3(-2.0, 0.0, 0));

	entity3->setColor(glm::vec3(0.5, 0.5, 1.0));

    soundcube = game->scene->getWorld()->createRenderable("cube");
	soundcube->setPosition(glm::vec3(0.0, 0.0, 0));
	soundcube->setColor(glm::vec3(0.2, 0.2, 0.2));

    Renderable* floorEntity = game->scene->getWorld()->createRenderable("floor");
	floorEntity->setPosition(glm::vec3(0, -2.0f, 0));
	floorEntity->setColor(glm::vec3(1.0, 1.0, 1.0));

    game->input->mapButton("W", new KeyboardButtonHandler(SDL_SCANCODE_W, game->input));
    game->input->mapButton("A", new KeyboardButtonHandler(SDL_SCANCODE_A, game->input));
    game->input->mapButton("S", new KeyboardButtonHandler(SDL_SCANCODE_S, game->input));
    game->input->mapButton("D", new KeyboardButtonHandler(SDL_SCANCODE_D, game->input));

    game->input->mapButton("Up", new KeyboardButtonHandler(SDL_SCANCODE_UP, game->input));
    game->input->mapButton("Left", new KeyboardButtonHandler(SDL_SCANCODE_LEFT, game->input));
    game->input->mapButton("Right", new KeyboardButtonHandler(SDL_SCANCODE_RIGHT, game->input));
    game->input->mapButton("Down", new KeyboardButtonHandler(SDL_SCANCODE_DOWN, game->input));
    game->input->mapButton("Escape", new KeyboardButtonHandler(SDL_SCANCODE_ESCAPE, game->input));
    game->input->mapButton("Left Click", new MouseButtonHandler(SDL_BUTTON_LEFT, game->input));
    game->input->mapButton("Right Click", new MouseButtonHandler(SDL_BUTTON_RIGHT, game->input));

    generalShader = new ShaderProgram();
    generalShader->load("./shaders/quad_vertex.glsl", "./shaders/quad_fragment.glsl");
    vbo = VertexBuffer::createQuad();

    game->scene->camera->position = glm::vec3(0.0f,0.0f,5.0f);
    game->scene->camera->focus = glm::vec3(0.0f,0.0f,0.0f);

    sound_1 = game->sounds->open("assets/sounds/beep-01a.wav");
    game->sounds->loop(sound_1, true);
    game->sounds->play(sound_1);
        
}
Beispiel #2
0
void ClosestHud::draw(const Matrix& mat, double wdt, double hgt)
{
    if (!m_bValid) return;
    Renderable rend = Renderable::temporary();
    rend.setImageName(L"sphere.png");
    rend.setScale(0.1);
    rend.setFixedSizeDistance(100);
    Gosu::Color col = Gosu::Colors::green;
    rend.setColor(col);
    rend.setPosition(m_vecPos);
    rend.draw(mat, wdt, hgt);
}