From 763c18abe97ccaaf977cb4d09d53ef3b230100d7 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 5 Nov 2015 09:20:33 -0500 Subject: indoor ortho fix --- Changelog | 10 ++++++++++ main.cpp | 18 +++++++++++++----- src/world.cpp | 4 ++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index d11bfe5..1dd169d 100644 --- a/Changelog +++ b/Changelog @@ -239,3 +239,13 @@ - added y-binding to ortho (if player is high in the sky ortho and UI will match it) - added maximum to gravity's pull - worked on storyline + +11/5/2015: +=========== + + - wrote more storyline (up to 7 pages) + - fixed ortho for when player is inside a building + - began work on ray shading (flashlight) + - (out of class) began experimenting with writing game soundtracks + + ~ About 3400 lines of code + documentation written diff --git a/main.cpp b/main.cpp index 07e2fb0..cc42acf 100644 --- a/main.cpp +++ b/main.cpp @@ -91,6 +91,12 @@ World *currentWorld=NULL; Player *player; extern std::vector entity; +/* + * Tells if player is currently inside a structure. +*/ + +extern bool worldInside; + /* * tickCount contains the number of ticks generated since main loop entrance. * This variable might be used anywhere. @@ -577,10 +583,12 @@ void render(){ * see past the world render */ - if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f) - offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2; - if(player->loc.x + SCREEN_WIDTH/2 > currentWorld->getTheWidth() * 0.5f) - offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2) + player->width / 2; + if(!worldInside){ + if(player->loc.x - SCREEN_WIDTH/2 < currentWorld->getTheWidth() * -0.5f) + offset.x = ((currentWorld->getTheWidth() * -0.5f) + SCREEN_WIDTH / 2) + player->width / 2; + if(player->loc.x + SCREEN_WIDTH/2 > currentWorld->getTheWidth() * 0.5f) + offset.x = ((currentWorld->getTheWidth() * 0.5f) - SCREEN_WIDTH / 2) + player->width / 2; + } if(player->loc.y > 300 ) offset.y = player->loc.y + player->height; @@ -778,7 +786,7 @@ void render(){ glUseProgramObjectARB(0); #endif //SHADERS - #define rays + #define raysSHITUPMYASS #ifdef rays //LIGHT diff --git a/src/world.cpp b/src/world.cpp index 5e7fb41..77872c1 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -22,6 +22,8 @@ extern std::vector entity; extern std::vector build; +bool worldInside = false; + float worldGetYBase(World *w){ float base = 0; World *ptr = w; @@ -543,11 +545,13 @@ World *World::goInsideStructure(Player *p){ if(build[i]->inWorld==this){ if(p->loc.x > build[i]->loc.x && p->loc.x + p->width < build[i]->loc.x + build[i]->width){ + worldInside = true; return (World *)build[i]->inside; } }else if(build[i]->inside==this){ p->loc.x=build[i]->loc.x + build[i]->width / 2 - p->width / 2; p->loc.y=build[i]->loc.y + HLINE; + worldInside = false; return (World *)build[i]->inWorld; } } -- cgit v1.2.3