From bf82dd59140d32f4eb265ae69a44784b5fda116a Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Wed, 16 Dec 2015 07:32:28 -0500 Subject: Stuff --- assets/door.png | Bin 255 -> 252 bytes include/entities.h | 3 +-- src/entities.cpp | 7 +++++-- src/gameplay.cpp | 2 +- src/world.cpp | 2 +- xcf/door.xcf | Bin 1404 -> 1930 bytes 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/assets/door.png b/assets/door.png index 2a8b0dd..7db551d 100644 Binary files a/assets/door.png and b/assets/door.png differ diff --git a/include/entities.h b/include/entities.h index 1abe886..7a97200 100644 --- a/include/entities.h +++ b/include/entities.h @@ -138,7 +138,7 @@ public: virtual ~Entity(){} }; -class Player : public Entity { +class Player : public Entity{ public: QuestHandler qh; bool light = false; @@ -147,7 +147,6 @@ public: ~Player(); void interact(); }; - class NPC : public Entity{ public: std::vectoraiFunc; diff --git a/src/entities.cpp b/src/entities.cpp index 24c0d01..3b8b52b 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -155,8 +155,8 @@ Mob::Mob(int sub){ height = 2000; tex = new Texturec(0); case MS_DOOR: - width = HLINE * 10; - height = HLINE * 16; + width = HLINE * 12; + height = HLINE * 20; tex = new Texturec(1,"assets/door.png"); break; } @@ -416,7 +416,10 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ * with type NPC. */ + //((World*)(inWorld))->addNPC(loc.x + i * HLINE ,100); + //inWorld->addNPC(loc.x + i * HLINE, 100); currentWorld->addNPC(loc.x + i * HLINE ,100); + } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 69ae2cc..6b62465 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -133,7 +133,6 @@ void initEverything(void){ //playerSpawnHill->addMob(MS_TRIGGER,player->loc.x,0,story); - //worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); //playerSpawnHill->addStructure(STRUCTURET,FOUNTAIN,(rand()%120*HLINE)+100*HLINE,100,test,iw); //playerSpawnHill->addStructure(STRUCTURET,HOUSE2,(rand()%120*HLINE)+300*HLINE,100,test,iw); @@ -143,6 +142,7 @@ void initEverything(void){ currentWorld = worldSpawnHill1; + worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); player = new Player(); player->spawn(200,100); diff --git a/src/world.cpp b/src/world.cpp index 1b460a2..d26b0fb 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -903,7 +903,7 @@ void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *outside,W build.push_back(new Structures()); build.back()->spawn(t,sub,x,y); build.back()->inWorld=outside; - build.back()->inside=(void *)inside; + build.back()->inside=inside; entity.push_back(build.back()); } diff --git a/xcf/door.xcf b/xcf/door.xcf index 7965018..e4edc10 100644 Binary files a/xcf/door.xcf and b/xcf/door.xcf differ -- cgit v1.2.3 From 85fb9f0a75f9a441d35e0ed48f250d7b07301483 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Thu, 17 Dec 2015 08:29:01 -0500 Subject: Shit --- assets/door.png | Bin 0 -> 252 bytes include/common.h | 2 +- main.cpp | 21 +++++---------------- src/ui.cpp | 2 +- test.frag | 2 +- 5 files changed, 8 insertions(+), 19 deletions(-) create mode 100644 assets/door.png diff --git a/assets/door.png b/assets/door.png new file mode 100644 index 0000000..7db551d Binary files /dev/null and b/assets/door.png differ diff --git a/include/common.h b/include/common.h index 08ec73f..5c90222 100644 --- a/include/common.h +++ b/include/common.h @@ -70,7 +70,7 @@ typedef struct{ * The desired width of the game window. */ -#define SCREEN_WIDTH 1024 +#define SCREEN_WIDTH 1280 /** * The desired height of the game window. diff --git a/main.cpp b/main.cpp index a9cc2fa..f7a1e83 100644 --- a/main.cpp +++ b/main.cpp @@ -344,7 +344,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; @@ -571,10 +571,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 @@ -597,6 +594,7 @@ void render(){ * Call the world's draw function, drawing the player, the world, the background, and entities. Also * draw the player's inventory if it exists. */ + glUseProgramObjectARB(shaderProgram); player->near=true; // Draw the player's name @@ -606,17 +604,6 @@ void render(){ * 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) @@ -693,6 +680,8 @@ void render(){ /* * Here we draw a black overlay if it's been requested. */ + glUseProgramObjectARB(0); + if(fadeIntensity){ if(fadeWhite) diff --git a/src/ui.cpp b/src/ui.cpp index 08f503f..b759012 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -556,7 +556,7 @@ namespace ui { hub.y-=fontSize*1.15; glRectf(hub.x, hub.y, - hub.x+(player->health/player->maxHealth)*130, + hub.x+(player->health/player->maxHealth?player->maxHealth:1)*130, hub.y+12); } diff --git a/test.frag b/test.frag index c30ef4d..13fe6bc 100644 --- a/test.frag +++ b/test.frag @@ -1,4 +1,4 @@ #version 120 void main(){ - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); + gl_FragColor = glColor; } -- cgit v1.2.3 From 0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Fri, 18 Dec 2015 07:32:05 -0500 Subject: Added lights --- include/common.h | 3 ++- main.cpp | 12 ++++++++++-- src/entities.cpp | 4 ++-- src/world.cpp | 1 - test.frag | 21 +++++++++++++++++---- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/include/common.h b/include/common.h index 5c90222..9dcc110 100644 --- a/include/common.h +++ b/include/common.h @@ -14,6 +14,7 @@ #include #include #include +#include #define GLEW_STATIC #include @@ -34,7 +35,7 @@ typedef unsigned int uint; * This flag lets the compiler know that we want to use shaders. */ -#define SHADERSs +#define SHADERS /** * This structure contains a set of coordinates for ease of coding. diff --git a/main.cpp b/main.cpp index 80bbeb9..014d950 100644 --- a/main.cpp +++ b/main.cpp @@ -595,7 +595,6 @@ void render(){ * Call the world's draw function, drawing the player, the world, the background, and entities. Also * draw the player's inventory if it exists. */ - glUseProgramObjectARB(shaderProgram); player->near=true; // Draw the player's name @@ -676,12 +675,20 @@ void render(){ } glUseProgramObjectARB(0); } + + glUseProgramObjectARB(shaderProgram); + glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 250,250); + glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,0,0); + glColor4f(0.0f,0.0f,0.0f,1.0f); + glRectf(-SCREEN_WIDTH/2,0,SCREEN_WIDTH/2,SCREEN_HEIGHT); + glUseProgramObjectARB(0); + player->inv->draw(); /* * Here we draw a black overlay if it's been requested. */ - glUseProgramObjectARB(0); + //glUseProgramObjectARB(0); if(fadeIntensity){ @@ -772,6 +779,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. diff --git a/src/entities.cpp b/src/entities.cpp index 6a2f4db..cd8d29e 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -83,8 +83,8 @@ Player::Player(){ //sets all of the player specific traits on object creation subtype = 0; health = maxHealth = 100; speed = 1; - //tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png"); - tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png"); + tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png"); + //tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png"); inv = new Inventory(PLAYER_INV_SIZE); } Player::~Player(){ diff --git a/src/world.cpp b/src/world.cpp index 7f4d6f6..0ecf7ee 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -555,7 +555,6 @@ LOOP2: 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 glBegin(GL_QUADS); - std::cout<