aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/main.cpp b/main.cpp
index e6ff2eb..3ae9787 100644
--- a/main.cpp
+++ b/main.cpp
@@ -199,11 +199,10 @@ extern int fadeIntensity;
/*******************************************************************************
* MAIN ************************************************************************
*******************************************************************************/
-
int main(/*int argc, char *argv[]*/){
//*argv = (char *)argc;
gameRunning=false;
-
+
/*!
* (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
* make openGL calls. Exit if there was an error.
@@ -301,7 +300,7 @@ int main(/*int argc, char *argv[]*/){
if((err=glewInit()) != GLEW_OK){
std::cout << "GLEW was not able to initialize! Error: " << glewGetErrorString(err) << std::endl;
return -1;
- }
+ }
/*
* Initialize the FreeType libraries and select what font to use using functions from the ui
@@ -347,7 +346,7 @@ int main(/*int argc, char *argv[]*/){
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
- std::string shaderFileContents = readFile("shader.frag");
+ std::string shaderFileContents = readFile("test.frag");
const GLchar *shaderSource = shaderFileContents.c_str();
GLint bufferln = GL_FALSE;
@@ -404,6 +403,12 @@ int main(/*int argc, char *argv[]*/){
fadeIntensity = 250;
initEverything();
+ if(!currentWorld){
+ std::cout<<"asscock"<<std::endl;
+ system("systemctl poweroff");
+ abort();
+ }
+
/*
* Load sprites used in the inventory menu. See src/inventory.cpp
*/
@@ -480,6 +485,7 @@ void mainLoop(void){
if(prev != currentWorld){
currentWorld->bgmPlay(prev);
+ ui::dialogBoxExists = false;
}
if(prevPrevTime + MSEC_PER_TICK <= currentTime){
@@ -578,10 +584,7 @@ void render(){
glOrtho((offset.x-SCREEN_WIDTH/2),(offset.x+SCREEN_WIDTH/2),offset.y-SCREEN_HEIGHT/2,offset.y+SCREEN_HEIGHT/2,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- glLoadIdentity();
- glEnable(GL_STENCIL_TEST);
- glPushMatrix();
-
+ glLoadIdentity();
/*
* glPushAttrib This passes attributes to the renderer so it knows what it can
* render. In our case, GL_DEPTH_BUFFER_BIT allows the renderer to
@@ -607,23 +610,15 @@ void render(){
player->near=true; // Draw the player's name
+ //glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,100);
currentWorld->draw(player);
+ //glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 0,1.0f,0);
+
/*
* Apply shaders if desired.
*/
- #ifdef SHADERS
- glUseProgramObjectARB(shaderProgram);
- glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,100);
- glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
- glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 100 + (1000-(shade*10)));
- //std::cout << 100 + (1000-(shade*10)) << std::endl;
- glColor4ub(0,0,0,200);
- glRectf(offset.x-SCREEN_WIDTH/2,0,offset.x+SCREEN_WIDTH/2,SCREEN_HEIGHT);
- glUseProgramObjectARB(0);
- #endif //SHADERS
-
handAngle = atan((ui::mouse.y - (player->loc.y + player->height/2)) / (ui::mouse.x - player->loc.x + player->width/2))*180/PI;
if(ui::mouse.x < player->loc.x){
if(handAngle <= 0)
@@ -635,7 +630,7 @@ void render(){
if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0) handAngle = 360+handAngle;
//if(ui::mouse.x < player->loc.x + (player->width/2)){player->left = true;player->right=false;}
//if(ui::mouse.x >= player->loc.x + (player->width/2)){player->right = true;player->left=false;}
- if(player->light){
+ /*if(player->light){
vec2 light;
int lightStr = 150;
vec2 curCoord;
@@ -666,12 +661,12 @@ void render(){
}
}
}
- /*if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){
+ if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){
if(curCoord.y > player->loc.y && curCoord .y < player->loc.y + player->height){
r.end = curCoord;
l=lightStr;
}
- }*/if(l==lightStr)r.end = curCoord;
+ }if(l==lightStr)r.end = curCoord;
}//end length
glBegin(GL_LINES);
glVertex2f(r.start.x,r.start.y);
@@ -694,12 +689,16 @@ void render(){
glEnd();
}
glUseProgramObjectARB(0);
- }
- player->inv->draw();
+ }*/
+
+ player->inv->draw();
+
/*
* Here we draw a black overlay if it's been requested.
*/
+ //glUseProgramObjectARB(0);
+
if(fadeIntensity){
if(fadeWhite)
@@ -726,7 +725,7 @@ void render(){
ui::putText(offset.x-SCREEN_WIDTH/2,
(offset.y+SCREEN_HEIGHT/2)-ui::fontSize,
- "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nTc: %u\nHA: %+.2f",
+ "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nTc: %u\nHA: %+.2f\nPl: %d",
fps,
player->ground,
SCREEN_WIDTH, // Window dimensions
@@ -735,7 +734,8 @@ void render(){
player->loc.x, // The player's x coordinate
debugY, // The player's y coordinate
tickCount,
- handAngle
+ handAngle,
+ player->light
);
if(ui::posFlag){
@@ -789,6 +789,7 @@ void render(){
static volatile bool objectInteracting = false;
void logic(){
+
/*
* NPCSelected is used to insure that only one NPC is made interactable with the mouse
* if, for example, multiple entities are occupying one space.