Exemple #1
0
	void ActorProto::link() {
		ActorArmourProto::link();
		punch_weapon.link();
		kick_weapon.link();
		
		char text[256];
		for(int d = 0; d < DeathId::count; d++) {
			snprintf(text, sizeof(text), "human%s", deathName(d));
			human_death_sounds[d] = SoundId(text);
		}

		snprintf(text, sizeof(text), "%srun", sound_prefix.c_str());
		run_sound = text;
		
		snprintf(text, sizeof(text), "%swalk", sound_prefix.c_str());
		walk_sound = text;

		for(int n = 0;; n++) {
			char var_name[128];
			snprintf(var_name, sizeof(var_name), n == 0? "%s" : "%s%d", sound_prefix.c_str(), n);

			Sounds sounds;

			bool any_sound = false;

			for(int d = 0; d < DeathId::count; d++) {
				snprintf(text, sizeof(text), "%s%s", var_name, deathName(d));
				sounds.death[d] = SoundId(text);
				any_sound |= sounds.death[d].isValid();
			}
		
			snprintf(text, sizeof(text), "%sgetup", var_name);
			sounds.get_up = text;
			snprintf(text, sizeof(text), "%shit", var_name);
			sounds.hit = text;

			any_sound |= sounds.get_up.isValid() | sounds.hit.isValid();

			if(!any_sound && n >= 1)
				break;
			if(any_sound)
				this->sounds.emplace_back(sounds);
		}
		if(sounds.empty())
			sounds.emplace_back(Sounds());
	}
Exemple #2
0
void CreateResources(ResourceManager &resourceManager)
{
    std::vector<Textures> texVec;
    std::vector<Sounds> soundVec;

    if(!resourceManager.GetTexture("geoff.png"))
        texVec.push_back(Textures("geoff.png"));
    if(!resourceManager.GetTexture("wolf.png"))
        texVec.push_back(Textures("wolf.png"));
    if(!resourceManager.GetTexture("bear.png"))
        texVec.push_back(Textures("bear.png"));
    if(!resourceManager.GetTexture("scenery.png"))
        texVec.push_back(Textures("scenery.png"));
    if(!resourceManager.GetTexture("scenery2.png"))
        texVec.push_back(Textures("scenery2.png"));
    if(!resourceManager.GetTexture("text.png"))
        texVec.push_back(Textures("text.png"));
    if(!resourceManager.GetTexture("snake.png"))
        texVec.push_back(Textures("snake.png"));

    if(!resourceManager.GetSound("bear.ogg"))
        soundVec.push_back(Sounds("bear.ogg"));
    if(!resourceManager.GetSound("chainsaw.ogg"))
        soundVec.push_back(Sounds("chainsaw.ogg"));
    if(!resourceManager.GetSound("chop.ogg"))
        soundVec.push_back(Sounds("chop.ogg"));
    if(!resourceManager.GetSound("death.ogg"))
        soundVec.push_back(Sounds("death.ogg"));
    if(!resourceManager.GetSound("snake.ogg"))
        soundVec.push_back(Sounds("snake.ogg"));
    if(!resourceManager.GetSound("wolfhowl.ogg"))
        soundVec.push_back(Sounds("wolfhowl.ogg"));
    if(!resourceManager.GetSound("woodpile.ogg"))
        soundVec.push_back(Sounds("woodpile.ogg"));

    resourceManager.GetOrCreateProgram("textured.vs", "textured.fs");
    resourceManager.GetOrCreateProgram("character.vs", "textured.fs");
    resourceManager.GetOrCreateProgram("colouredsquare.vs", "colouredsquare.fs");

    std::shared_ptr<unsigned int> buffer(resourceManager.GetVao("buffer"));

    if(!buffer)
    {
        buffer = std::make_shared<unsigned int>(CreateBuffer());
        resourceManager.AddVao("buffer", buffer);
    }
    if(!resourceManager.GetVao("full vao"))
    {
        std::shared_ptr<unsigned int> vao(new unsigned int (CreateVAO(*buffer, 1)));
        resourceManager.AddVao("full vao", vao);
    }
    if(!resourceManager.GetVao("vao top left"))
    {
        std::shared_ptr<unsigned int> vaoTopLeft(new unsigned int (CreateVAO(*buffer, 2)));
        resourceManager.AddVao("vao top left", vaoTopLeft);
    }
    if(!resourceManager.GetVao("vao top right"))
    {
        std::shared_ptr<unsigned int> vaoTopRight(new unsigned int (CreateVAO(*buffer, 3)));
        resourceManager.AddVao("vao top right", vaoTopRight);
    }
    if(!resourceManager.GetVao("vao bottom left"))
    {
        std::shared_ptr<unsigned int> vaoBottomLeft(new unsigned int (CreateVAO(*buffer, 4)));
        resourceManager.AddVao("vao bottom left", vaoBottomLeft);
    }
    if(!resourceManager.GetVao("vao bottom right"))
    {
        std::shared_ptr<unsigned int> vaoBottomRight(new unsigned int (CreateVAO(*buffer, 5)));
        resourceManager.AddVao("vao bottom right", vaoBottomRight);
    }
    if(!resourceManager.GetVao("vao plain colour"))
    {
        std::shared_ptr<unsigned int> vaoPlainColour(new unsigned int (SetupStandardVAO(*buffer)));
        resourceManager.AddVao("vao plain colour", vaoPlainColour);
    }

    CreateTexturesAndSound(texVec, soundVec);
    for(auto object(texVec.begin()); object != texVec.end(); ++object)
    {
        std::shared_ptr<unsigned int> ptr(
                    new unsigned int(CreateOpenGLTexture((*object).texVec, (*object).width,
                                                         (*object).height)));
        resourceManager.AddTexture((*object).filename, ptr);
    }
    texVec.clear();
    for(auto object(soundVec.begin()); object != soundVec.end(); ++object)
    {
        std::shared_ptr<unsigned int> ptr(
                    new unsigned int(object->sound));
        resourceManager.AddSound((*object).filename, ptr);
    }
    soundVec.clear();
}