aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp96
1 files changed, 20 insertions, 76 deletions
diff --git a/main.cpp b/main.cpp
index 45d4fdd..5fcd65e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -123,6 +123,7 @@ unsigned int deltaTime = 0;
GLuint fragShader;
GLuint shaderProgram;
GLuint colorIndex;
+GLuint mouseTex;
Mix_Chunk *crickets;
@@ -306,7 +307,7 @@ int main(/*int argc, char *argv[]*/){
*/
ui::initFonts();
- ui::setFontFace("ttf/Perfect DOS VGA 437.ttf"); // as in gamedev/ttf/<font>
+ ui::setFontFace("ttf/VCR_OSD_MONO_1.001.ttf"); // as in gamedev/ttf/<font>
/*
* Initialize the random number generator. At the moment, initRand is a macro pointing to libc's
@@ -405,6 +406,7 @@ int main(/*int argc, char *argv[]*/){
*/
invUI = Texture::loadTexture("assets/invUI.png" );
+ mouseTex = Texture::loadTexture("assets/mouse.png");
initInventorySprites();
@@ -469,7 +471,7 @@ void mainLoop(void){
currentTime = millis();
deltaTime = currentTime - prevTime;
- if(currentMenu != NULL)goto MENU;
+ if(currentMenu)goto MENU;
/*
* Run the logic handler if MSEC_PER_TICK milliseconds have passed.
@@ -609,10 +611,6 @@ void render(){
currentWorld->draw(player);
- /*
- * Apply shaders if desired.
- */
-
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)
@@ -622,68 +620,6 @@ 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){
- vec2 light;
- int lightStr = 150;
- vec2 curCoord;
-
- light.x = player->loc.x + player->width;
- light.y = player->loc.y + player->height/2;
-
- std::vector<Ray>fray(60);
- unsigned int a = 0;
- float angle = 0;
-
- glColor3f(0.0f, 0.0f, 0.0f);
-
- for(auto &r : fray){
- r.start = light;
- curCoord = r.start;
- angle = .5*a + handAngle;
- //for length
- for(int l = 0;l<=lightStr;l++){
- //std::cout << a << ": " << curCoord.x << "," << curCoord.y << "\n";
- curCoord.x += float((HLINE) * cos(angle*PI/180));
- curCoord.y += float((HLINE) * sin(angle*PI/180));
- for(auto &en : currentWorld->entity){
- if(curCoord.x > en->loc.x && curCoord.x < en->loc.x + en->width && en->type!=STRUCTURET){
- if(curCoord.y > en->loc.y && curCoord .y < en->loc.y + en->height){
- r.end = curCoord;
- l=lightStr;
- }
- }
- }
- 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;
- }//end length
- glBegin(GL_LINES);
- glVertex2f(r.start.x,r.start.y);
- glVertex2f(r.end.x, r.end.y);
- glEnd();
- //std::cout << angle << "\n";
- a++;
- }
-
- glUseProgramObjectARB(shaderProgram);
- glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,300);
- glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
- glUniform1f(glGetUniformLocation(shaderProgram, "lightStrength"), 5);
- glColor4f(1.0f, 1.0f, 1.0f, .5f);
- for(unsigned int r = 0; r < fray.size(); r++){
- glBegin(GL_TRIANGLES);
- glVertex2f(fray[r].start.x, fray[r].start.y);
- glVertex2f(fray[r].end.x, fray[r].end.y);
- r==fray.size()-1 ? glVertex2f(fray[r].end.x, fray[r].end.y) : glVertex2f(fray[r+1].end.x, fray[r+1].end.y);
- glEnd();
- }
- glUseProgramObjectARB(0);
- }*/
player->inv->draw();
@@ -691,8 +627,6 @@ void render(){
/*
* Here we draw a black overlay if it's been requested.
*/
- //glUseProgramObjectARB(0);
-
if(fadeIntensity){
if(fadeWhite)
@@ -750,7 +684,7 @@ void render(){
}
- if(currentMenu != NULL){
+ if(currentMenu){
ui::drawMenu(currentMenu);
}
@@ -759,12 +693,15 @@ void render(){
*/
glColor3ub(255,255,255);
-
- glBegin(GL_TRIANGLES);
- glVertex2i(ui::mouse.x ,ui::mouse.y );
- glVertex2i(ui::mouse.x+HLINE*3.5,ui::mouse.y );
- glVertex2i(ui::mouse.x ,ui::mouse.y-HLINE*3.5);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, mouseTex);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);glVertex2i(ui::mouse.x ,ui::mouse.y );
+ glTexCoord2f(1,0);glVertex2i(ui::mouse.x+HLINE*5 ,ui::mouse.y );
+ glTexCoord2f(1,1);glVertex2i(ui::mouse.x+HLINE*5 ,ui::mouse.y-HLINE*5 );
+ glTexCoord2f(0,1);glVertex2i(ui::mouse.x ,ui::mouse.y-HLINE*5 );
glEnd();
+ glDisable(GL_TEXTURE_2D);
/**************************
**** END RENDERING ****
@@ -825,12 +762,19 @@ void logic(){
* that the NPC doesn't move when it talks to the player.
*/
+/*<<<<<<< HEAD
+ if(n->canMove) n->wander((rand() % 120 + 30));
+
+ if(!player->inv->usingi) n->hit = false;
+ if(player->inv->usingi && !n->hit && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){
+=======*/
if(n->canMove)
n->wander((rand() % 120 + 30));
/*if(!player->inv->usingi) n->hit = false;
if(player->inv->usingi && !n->hit && player->inv->detectCollision((vec2){n->loc.x, n->loc.y},(vec2){n->loc.x+n->width,n->loc.y+n->height})){
+>>>>>>> 7ab072caaaec09720ad79cfed5738e89bc60c44f
n->health -= 25;
n->hit = true;
for(int r = 0; r < (rand()%5);r++)