Ejemplo n.º 1
0
/** 
 * Constructor with initialize parameters.
 * @param   meshFileName is LaserBlast mesh file name.
 * @param   textureFileName is LaserBlast mesh texture file name.
 * @param	position is LaseBlast origin position vector.
 * @param	direction is LaserBlast move direction;
 * @param	orientation is LaserBlast initial orientation represented by Quaternion.
 * @param	id is laser blaster id.
 */
LaserBlast::LaserBlast(const char* meshFileName, const char* textureFileName,const Vector3D& position, const Vector3D& direction, const Quaternion& orientation,int id)
{
	this->position = position;
	this->moveDirection = direction;
	this->orientation = orientation;
	this->id = id;

	isDead = false;
	haveCollided = false;
	healthPoints = 1;
	lifeTime = 5.0f;
	acceleration = Vector3D(1.0f,1.0f,1.0f);
	velocity = Vector3D(100.0f,100.0f,100.0f);
	faction = LASER; //INDEPENDENT;

	ResourceManager* resManager = ResourceManager::getInstance();
	texture = resManager->getResource(std::string(textureFileName), std::string(textureFileName), TEXTURE);
	mesh = resManager->getResource(std::string("LaserBlastMesh"), std::string(meshFileName), MESH);
	Mesh* tempMesh = static_cast<Mesh*>(mesh.get());
	collisionBox = new BoundingBox(tempMesh->getVerts(),tempMesh->getPoints());

	if(Extensions::vboSupported)
		entityVBO = new VBO(*tempMesh);
	
	//if(Extensions::shaderSupported)
	//	shader.initializeShader("Shaders/texture.vert","Shaders/texture.frag");
}
Ejemplo n.º 2
0
  Graphics::Graphics() {
	glewExperimental = GL_TRUE;
    glewInit();

    glGenVertexArrays(1, &vertexArray);
    glBindVertexArray(vertexArray);

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glEnableVertexAttribArray(2);

    fragShader = new FragmentShader("data/fragment.glsl");
    vertShader = new VertexShader("data/vertex.glsl");
    shaderProgram = new ShaderProgram();

    shaderProgram->setFragmentShader(fragShader);
    shaderProgram->setVertexShader(vertShader);

    shaderProgram->addBinding(0, "inVertex");
    shaderProgram->addBinding(1, "inTexCoord");
    shaderProgram->addBinding(2, "inColour");

    shaderProgram->link();
    shaderProgram->makeActive();

    modelMatrixUniform = shaderProgram->getUniformLocation("inModelMatrix");
    projectionMatrixUniform = shaderProgram->getUniformLocation("inProjectionMatrix");
    viewMatrixUniform = shaderProgram->getUniformLocation("inViewMatrix");
    texUniform = shaderProgram->getUniformLocation("inTexture");

    setMatrixMode(MatrixMode::MODEL);
    loadIdentity();

    setMatrixMode(MatrixMode::VIEW);
    loadIdentity();

    setMatrixMode(MatrixMode::PROJECTION);
    loadIdentity();
    //ortho(-8, 8, -8, 8, 0, 0);
    frustum(-(1 + ((3.0 / 4.0) / 2.0)), 1 + ((3.0 / 4.0) / 2.0), -1, 1, 1, 512);

    setMatrixMode(MatrixMode::MODEL);

    ResourceManager* rm = ResourceManager::getInstance();
    
    floorMesh = rm->getResource("data/model.obj")->toOBJModel()->compose();
    wallMesh = rm->getResource("data/wall.obj")->toOBJModel()->compose();
    ceilingMesh = rm->getResource("data/ceiling.obj")->toOBJModel()->compose();
    
    font = rm->getResource("data/DejaVuSansMono.ttf")->toFont();
    if (!font) {
      //  Throw an error;
      throw std::runtime_error("Graphics::Graphics():  Could not load font.");
    }
  }
Ejemplo n.º 3
0
	IntroState(Game* game)
	{
		this->game = game;
		ResourceManager* resManager = ResourceManager::getInstance();
		longTime = resManager->getResource(std::string("LongTime"), std::string("Data/longTime.jpg"),TEXTURE);
		logo = resManager->getResource(std::string("Logo"), std::string("Data/logo.png"),TEXTURE);
		timeAccumulator = 0.0f;
		blendAccumulator = -3.0f;
		space = new SkyBox(Vector3D(0,0,0),Vector3D(2000,2000,2000),0);
		introMusic = new AudioManager();
	};
Ejemplo n.º 4
0
/** 
 * Constructor with initialize parameters.
 * @param   meshFileName is Asteroid mesh file name.
 * @param   textureFileName is Asteroid mesh texture file name.
 * @param	position is origin position vector.
 */
Asteroid::Asteroid(const char* meshFileName, const char* textureFileName,const Vector3D& position)
{
	this->position = position;
	isDead = false;
	healthPoints = 1;
	faction = ASTEROID; //INDEPENDENT; 

	velocity = Vector3D(2.0f,2.0f,2.0f);
	ResourceManager* resManager = ResourceManager::getInstance();
	texture = resManager->getResource(std::string("AsteroidText"), std::string(textureFileName), TEXTURE);
	mesh = resManager->getResource(std::string("AsteroidMesh"), std::string(meshFileName), MESH);
	Mesh* tempMesh = static_cast<Mesh*>(mesh.get());
	collisionBox = new BoundingBox(tempMesh->getVerts(),tempMesh->getPoints());

	if(Extensions::vboSupported)
		entityVBO = new VBO(*tempMesh);
	
	if(Extensions::shaderSupported)
		shader.initializeShader("Shaders/texture.vert","Shaders/texture.frag");
}
/**
 * Constructor with initialize parameters.
 * @param	origin is effect start position.
 */
ExplosionEffect::ExplosionEffect(const Vector3D& origin) : ParticleSystem(100)
{
	this->origin = origin;
	this->effectTime = 2.5f;
	this->isDead = false;

	ResourceManager* resManager = ResourceManager::getInstance();
	texture = resManager->getResource(string("Particle"), string("Data/particle.png"), TEXTURE);

	initialize();
}
Ejemplo n.º 6
0
/** 
 * Constructor with initialize parameters.
 * @param   meshFileName is AT-ST mesh file name.
 * @param   textureFileName is AT-ST mesh texture file name.
 * @param	position is origin position vector.
 */
ATST::ATST(const char* meshFileName, const char* textureFileName,const Vector3D& position)
{
	this->position = position;
	isDead = false;
	healthPoints = 10;
	faction = IMPERIAL;
	velocity = Vector3D(2.0f,2.0f,2.0f);
	blasterAccumulator = static_cast<float>(rand() % 2 + 1);

	ResourceManager* resManager = ResourceManager::getInstance();
	texture = resManager->getResource(std::string("ATSTText"), std::string(textureFileName), TEXTURE);
	mesh = resManager->getResource(std::string("ATSTMesh"), std::string(meshFileName), MESH);
	Mesh* tempMesh = static_cast<Mesh*>(mesh.get());
	collisionBox = new BoundingBox(tempMesh->getVerts(),tempMesh->getPoints());

	if(Extensions::vboSupported)
		entityVBO = new VBO(*tempMesh);
	
	if(Extensions::shaderSupported)
		shader.initializeShader("Shaders/texture.vert","Shaders/texture.frag");
}
/** 
 * Constructor with initialize parameters.
 * @param   meshFileName is StarDestroyer mesh file name.
 * @param   textureFileName is StarDestroyer mesh texture file name.
 * @param	moveDirection is StarDestroyer move direction vector.
 * @param	orientation is StarDestroyer initial orientation represented by Quaternion.
 */
StarDestroyer::StarDestroyer(const char* meshFileName, const char* textureFileName,const Vector3D& moveDirection,const Quaternion& orientation)
{
	this->position = Vector3D(0.0f,0.0f,0.0f);
	this->orientation = orientation;
	this->moveDirection = moveDirection;
	isDead = false;
	healthPoints  = 10;
	blasterAccumulator = static_cast<float>(rand() % 5 + 2);

	velocity = Vector3D(0.0f,0.0f,0.0f);
	faction = IMPERIAL;

	ResourceManager* resManager = ResourceManager::getInstance();
	texture = resManager->getResource(std::string("StarDestroyerText"), std::string(textureFileName), TEXTURE);
	mesh = resManager->getResource(std::string("StarDestroyerMesh"), std::string(meshFileName), MESH);
	Mesh* tempMesh = static_cast<Mesh*>(mesh.get());
	collisionBox = new BoundingBox(tempMesh->getVerts(), tempMesh->getPoints());
	if(Extensions::vboSupported)
		entityVBO = new VBO(*tempMesh);
	if(Extensions::shaderSupported)
		shader.initializeShader("Shaders/texture.vert","Shaders/texture.frag");

}
AudioStreamResource* AudioStreamResource::createAudioStreamResource (
    const String& fileName, unsigned int buff, unsigned int samples )
{

	// Criamos a mensagem de carregamento
	String str ( "File " + fileName );

	// Instancia de ResourceManager
	ResourceManager* rscMap = ResourceManager::Instance();

	// Verificamos se o Resource ja foi carregado
	AudioStreamResource* rsc =
	    static_cast<AudioStreamResource*> ( rscMap->getResource ( fileName ) );

	if ( rsc == nullptr ) {

		// Criamos o AudioStream
		ALLEGRO_AUDIO_STREAM* stream =
		    al_load_audio_stream ( fileName.c_str(), buff, samples );

		if ( stream == nullptr ) {
			throw Ludic::Exception ( "ERROR: Error to load AudioStreamResource " + fileName );
			return nullptr;
		}

		// Criamos o AudioStreamResource
		rsc = new AudioStreamResource ( fileName, stream, buff, samples );

		// Adicionamos ao mapa
		rscMap->addResource ( fileName, rsc );

		str += " loaded successfully!";

	}
	else {
		str += " already exists!";
	}

	// Imprimims a mensagem de carregamento
	std::cout << str << std::endl;

	return rsc;
}
Ejemplo n.º 9
0
// (¯`'•.¸//(*_*)\\¸.•'´¯`'•.¸//(*_*)\\¸.•'´¯`'•.¸//(*_*)\\¸.•'´¯) 
//  
//  Constructor
//
// (¯`'•.¸//(*_*)\\¸.•'´¯`'•.¸//(*_*)\\¸.•'´¯`'•.¸//(*_*)\\¸.•'´¯) 
Player::Player(ResourceManager<sf::Texture> &txtMgr, ResourceManager<sf::Font> &fntMgr, std::string name, int num)
{
	starship = new Starship(txtMgr, fntMgr);
	colonyZone = new Zone<ColonyCard>(txtMgr, fntMgr, "Colony");
	tradeZone = new Zone<TradeCard>(txtMgr, fntMgr, "Trade");
	pirateZone = new Zone<Pirate>(txtMgr, fntMgr, "Pirate");
	advZone = new Zone<AdventureCard>(txtMgr, fntMgr, "Adventure");

	statistics = new Object*[STATNUM];

	statistics[player] = new Object(txtMgr.getResource(ICNFLE), { 10, 820 }, num, { 75, 75 });
	statistics[player]->initString(fntMgr.getResource(FNTFLE), { 90, 820 }, name);

	statistics[astro] = new Object(txtMgr.getResource(SYM1FLE), { 90, 860 }, 25, { 35, 35 }, { 3, 0 });
	statistics[astro]->initString(fntMgr.getResource(FNTFLE), { 130, 855 });
	
	statistics[vicPt] = new Object(txtMgr.getResource(SYM1FLE), { 180, 860 }, 1, { 35, 35 });
	statistics[vicPt]->initString(fntMgr.getResource(FNTFLE), { 220, 855 });
	
	statistics[frdPt] = new Object(txtMgr.getResource(SYM1FLE), { 260, 860 }, 0, { 35, 35 }, { 1, 0 });
	statistics[frdPt]->initString(fntMgr.getResource(FNTFLE), { 300, 855 });

	statistics[fmPt] = new Object(txtMgr.getResource(SYM1FLE), { 340, 860 }, 0, { 35, 35 }, { 2, 0 });
	statistics[fmPt]->initString(fntMgr.getResource(FNTFLE), { 380, 855 });

	statistics[science] = new Object(txtMgr.getResource(RICNFLE), { 420, 860 }, 1, { 35, 35 }, { 0, 0 });
	statistics[science]->initString(fntMgr.getResource(FNTFLE), { 460, 855 });
		
	statistics[ore] = new Object(txtMgr.getResource(RICNFLE), { 500, 860 }, 1, { 35, 35 }, { 1, 0 });
	statistics[ore]->initString(fntMgr.getResource(FNTFLE), { 540, 855 });
	
	statistics[fuel] = new Object(txtMgr.getResource(RICNFLE), { 580, 860 }, 1, { 35, 35 }, { 2, 0 });
	statistics[fuel]->initString(fntMgr.getResource(FNTFLE), { 620, 855 });

	statistics[tradeGood] = new Object(txtMgr.getResource(RICNFLE), { 660, 860 }, 1, { 35, 35 }, { 3, 0 });
	statistics[tradeGood]->initString(fntMgr.getResource(FNTFLE), { 700, 855 });

	statistics[wheat] = new Object(txtMgr.getResource(RICNFLE), { 740, 860 }, 1, { 35, 35 }, { 4, 0 });
	statistics[wheat]->initString(fntMgr.getResource(FNTFLE), { 780, 855 });

	statistics[carbon] = new Object(txtMgr.getResource(RICNFLE), { 820, 860 }, 1, { 35, 35 }, { 5, 0 });
	statistics[carbon]->initString(fntMgr.getResource(FNTFLE), { 860, 855 });

	bool friendOfThePeople = false;
	bool heroOfThePeople = false;
}
Ejemplo n.º 10
0
	PauseState(Game* game)
	{
		this->game = game;
		ResourceManager* resManager = ResourceManager::getInstance();
		pause = resManager->getResource(std::string("Pause"), std::string("Data/pause.png"), TEXTURE);
	};
Ejemplo n.º 11
0
	GameOverState(Game* game)
	{
		this->game = game;
		ResourceManager* resManager = ResourceManager::getInstance();
		gameOver = resManager->getResource(std::string("GameOver"), std::string("Data/gameover.png"), TEXTURE);
	};