void quitGame(){
dialogBoxExists = false;
currentMenu = NULL;
- delete[] currentMenu;
gameRunning = false;
updateConfig();
saveConfig();
break;
case SDLK_l:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
- currentWorld->light.back().belongsTo = true;
- currentWorld->light.back().following = player;
- currentWorld->light.back().flame = true;
+ currentWorld->light.back().follow(player);
+ currentWorld->light.back().makeFlame();
break;
case SDLK_f:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
- std::cout << currentWorld->light.back().belongsTo << std::endl;
- currentWorld->light.back().belongsTo = false;
- std::cout << currentWorld->light.back().belongsTo << std::endl;
- currentWorld->light.back().following = nullptr;
- currentWorld->light.back().flame = true;
break;
case SDLK_g:
//currentWorld->addStructure(LAMP_POST, player->loc.x, player->loc.y, NULL);
case SDLK_b:
currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, "", "");
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
- currentWorld->light.back().belongsTo = false;
- currentWorld->light.back().following = nullptr;
- currentWorld->light.back().flame = true;
+ currentWorld->light.back().follow(currentWorld->build.back());
+ currentWorld->light.back().makeFlame();
break;
case SDLK_F12:
// Make the BYTE array, factor of 3 because it's RBG.
for(auto &l : light){
if(l.belongsTo){
l.loc.x = l.following->loc.x + SCREEN_WIDTH/2;
+ l.loc.y = l.following->loc.y;
+ }
+ if(l.flame){
+ l.fireFlicker = .9+((rand()%2)/10.0f);
+ l.fireLoc.x = l.loc.x + (rand()%2-1)*3;
+ l.fireLoc.y = l.loc.y + (rand()%2-1)*3;
+
+ //std::cout << l.fireLoc.x << "," << l.fireLoc.y << std::endl;
+ //std::cout << l.loc.x << "," << l.loc.y << std::endl << std::endl;
+ }else{
+ l.fireFlicker = 1.0f;
}
}
- std::unique_ptr<GLfloat[]> pointArrayBuf = std::make_unique<GLfloat[]> (2 * (light.size()));
+ std::unique_ptr<GLfloat[]> pointArrayBuf = std::make_unique<GLfloat[]> (2 * (light.size()));
auto pointArray = pointArrayBuf.get();
+ GLfloat flameArray[64];
- for ( i = 0; i < (int)light.size(); i++ ) {
- pointArray[2 * i ] = light[i].loc.x - offset.x;
- pointArray[2 * i + 1] = light[i].loc.y;
+ for (uint i = 0; i < light.size(); i++) {
+ if(light[i].flame){
+ pointArray[2 * i ] = light[i].fireLoc.x - offset.x;
+ pointArray[2 * i + 1] = light[i].fireLoc.y;
+ }else{
+ pointArray[2 * i ] = light[i].loc.x - offset.x;
+ pointArray[2 * i + 1] = light[i].loc.y;
+ }
}
+ for(uint i = 0; i < light.size(); i++){
+ flameArray[i] = light[i].fireFlicker;
+ }
+
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glUniform1i ( glGetUniformLocation( shaderProgram, "numLight" ), light.size());
glUniform2fv( glGetUniformLocation( shaderProgram, "lightLocation"), light.size(), pointArray );
glUniform3f ( glGetUniformLocation( shaderProgram, "lightColor" ), 1.0f, 1.0f, 1.0f );
+ glUniform1fv(glGetUniformLocation(shaderProgram,"fireFlicker"), light.size(),flameArray);
}
/*
}
void World::addLight(vec2 loc, Color color){
- Light l;
- if ( light.size() < 64 ) {
- l.loc = loc;
- l.color = color;
- light.push_back(l);
+ if(light.size() < 64){
+ light.push_back(Light(loc,color,1));
}
}
//glEnable(GL_TEXTURE_2D);
- std::cout << "Lights and shit" << std::endl;
for(auto &l : light){
if(l.belongsTo){
- std::cout << "Is following" << std::endl;
l.loc.x = l.following->loc.x + SCREEN_WIDTH/2;
l.loc.y = l.following->loc.y;
}
l.fireLoc.x = l.loc.x + (rand()%2-1)*3;
l.fireLoc.y = l.loc.y + (rand()%2-1)*3;
- std::cout << l.fireLoc.x << "," << l.fireLoc.y << std::endl;
- std::cout << l.loc.x << "," << l.loc.y << std::endl << std::endl;
+ //std::cout << l.fireLoc.x << "," << l.fireLoc.y << std::endl;
+ //std::cout << l.loc.x << "," << l.loc.y << std::endl << std::endl;
}else{
l.fireFlicker = 1.0f;
}
}
- std::cout << "Making light arrays" << std::endl;
std::unique_ptr<GLfloat[]> pointArrayBuf = std::make_unique<GLfloat[]> (2 * (light.size()));
auto pointArray = pointArrayBuf.get();
GLfloat flameArray[64];
- std::cout << "Setting array locations" << std::endl;
for (i = 0; i < light.size(); i++) {
if(light[i].flame){
pointArray[2 * i ] = light[i].fireLoc.x - offset.x;
}
}
- std::cout << "Flame array" << std::endl;
for(i = 0; i < light.size(); i++){
flameArray[i] = light[i].fireFlicker;
}
glUseProgram( shaderProgram );
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glUniform1f(glGetUniformLocation(shaderProgram, "amb" ), 0.02f + light.size()/50.0f);
- glUniform1i(glGetUniformLocation(shaderProgram, "fire" ), 1);
- std::cout << "Uniform sending" << std::endl;
if ( light.size() == 0)
glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0);
else {
//delete[] flameArray;
- std::cout << "Done shading" << std::endl;
-
bgTex->bind(0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
glUseProgram(0);
//glDisable(GL_TEXTURE_2D);
- std::cout << "Faggot" << std::endl;
-
/*
* Calculate the starting and ending points to draw the ground from.
*/
glEnd();
glUseProgram(0);
- std::cout << "Queer" << std::endl;
-
/*
* Draw all entities.
*/
e->draw();
p->draw();
-
- std::cout << "Cranmore Tubing park" << std::endl;
}
Arena::Arena(World *leave,Player *p,Mob *m){