From 82c75b0a97eba2f78206d3b97d47eaa580a82f0c Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 8 Mar 2016 08:42:20 -0500 Subject: [PATCH] world lighting fixed --- Changelog | 6 ++++++ Makefile | 2 +- include/{freetype2 => freetype}/config/ftconfig.h | 0 include/{freetype2 => freetype}/config/ftheader.h | 0 include/{freetype2 => freetype}/config/ftmodule.h | 0 include/{freetype2 => freetype}/config/ftoption.h | 0 include/{freetype2 => freetype}/config/ftstdlib.h | 0 include/{freetype2 => freetype}/freetype.h | 0 include/{freetype2 => freetype}/ft2build.h | 4 ++-- include/{freetype2 => freetype}/ftadvanc.h | 0 include/{freetype2 => freetype}/ftautoh.h | 0 include/{freetype2 => freetype}/ftbbox.h | 0 include/{freetype2 => freetype}/ftbdf.h | 0 include/{freetype2 => freetype}/ftbitmap.h | 0 include/{freetype2 => freetype}/ftbzip2.h | 0 include/{freetype2 => freetype}/ftcache.h | 0 include/{freetype2 => freetype}/ftcffdrv.h | 0 include/{freetype2 => freetype}/ftchapters.h | 0 include/{freetype2 => freetype}/ftcid.h | 0 include/{freetype2 => freetype}/fterrdef.h | 0 include/{freetype2 => freetype}/fterrors.h | 0 include/{freetype2 => freetype}/ftgasp.h | 0 include/{freetype2 => freetype}/ftglyph.h | 0 include/{freetype2 => freetype}/ftgxval.h | 0 include/{freetype2 => freetype}/ftgzip.h | 0 include/{freetype2 => freetype}/ftimage.h | 0 include/{freetype2 => freetype}/ftincrem.h | 0 include/{freetype2 => freetype}/ftlcdfil.h | 0 include/{freetype2 => freetype}/ftlist.h | 0 include/{freetype2 => freetype}/ftlzw.h | 0 include/{freetype2 => freetype}/ftmac.h | 0 include/{freetype2 => freetype}/ftmm.h | 0 include/{freetype2 => freetype}/ftmodapi.h | 0 include/{freetype2 => freetype}/ftmoderr.h | 0 include/{freetype2 => freetype}/ftotval.h | 0 include/{freetype2 => freetype}/ftoutln.h | 0 include/{freetype2 => freetype}/ftpfr.h | 0 include/{freetype2 => freetype}/ftrender.h | 0 include/{freetype2 => freetype}/ftsizes.h | 0 include/{freetype2 => freetype}/ftsnames.h | 0 include/{freetype2 => freetype}/ftstroke.h | 0 include/{freetype2 => freetype}/ftsynth.h | 0 include/{freetype2 => freetype}/ftsystem.h | 0 include/{freetype2 => freetype}/fttrigon.h | 0 include/{freetype2 => freetype}/ftttdrv.h | 0 include/{freetype2 => freetype}/fttypes.h | 0 include/{freetype2 => freetype}/ftwinfnt.h | 0 include/{freetype2 => freetype}/ftxf86.h | 0 include/{freetype2 => freetype}/t1tables.h | 0 include/{freetype2 => freetype}/ttnameid.h | 0 include/{freetype2 => freetype}/tttables.h | 0 include/{freetype2 => freetype}/tttags.h | 0 include/{freetype2 => freetype}/ttunpat.h | 0 main.cpp | 13 +------------ src/entities.cpp | 8 ++++++++ src/ui.cpp | 4 ++++ src/world.cpp | 15 +++++++++++---- 57 files changed, 33 insertions(+), 19 deletions(-) rename include/{freetype2 => freetype}/config/ftconfig.h (100%) rename include/{freetype2 => freetype}/config/ftheader.h (100%) rename include/{freetype2 => freetype}/config/ftmodule.h (100%) rename include/{freetype2 => freetype}/config/ftoption.h (100%) rename include/{freetype2 => freetype}/config/ftstdlib.h (100%) rename include/{freetype2 => freetype}/freetype.h (100%) rename include/{freetype2 => freetype}/ft2build.h (95%) rename include/{freetype2 => freetype}/ftadvanc.h (100%) rename include/{freetype2 => freetype}/ftautoh.h (100%) rename include/{freetype2 => freetype}/ftbbox.h (100%) rename include/{freetype2 => freetype}/ftbdf.h (100%) rename include/{freetype2 => freetype}/ftbitmap.h (100%) rename include/{freetype2 => freetype}/ftbzip2.h (100%) rename include/{freetype2 => freetype}/ftcache.h (100%) rename include/{freetype2 => freetype}/ftcffdrv.h (100%) rename include/{freetype2 => freetype}/ftchapters.h (100%) rename include/{freetype2 => freetype}/ftcid.h (100%) rename include/{freetype2 => freetype}/fterrdef.h (100%) rename include/{freetype2 => freetype}/fterrors.h (100%) rename include/{freetype2 => freetype}/ftgasp.h (100%) rename include/{freetype2 => freetype}/ftglyph.h (100%) rename include/{freetype2 => freetype}/ftgxval.h (100%) rename include/{freetype2 => freetype}/ftgzip.h (100%) rename include/{freetype2 => freetype}/ftimage.h (100%) rename include/{freetype2 => freetype}/ftincrem.h (100%) rename include/{freetype2 => freetype}/ftlcdfil.h (100%) rename include/{freetype2 => freetype}/ftlist.h (100%) rename include/{freetype2 => freetype}/ftlzw.h (100%) rename include/{freetype2 => freetype}/ftmac.h (100%) rename include/{freetype2 => freetype}/ftmm.h (100%) rename include/{freetype2 => freetype}/ftmodapi.h (100%) rename include/{freetype2 => freetype}/ftmoderr.h (100%) rename include/{freetype2 => freetype}/ftotval.h (100%) rename include/{freetype2 => freetype}/ftoutln.h (100%) rename include/{freetype2 => freetype}/ftpfr.h (100%) rename include/{freetype2 => freetype}/ftrender.h (100%) rename include/{freetype2 => freetype}/ftsizes.h (100%) rename include/{freetype2 => freetype}/ftsnames.h (100%) rename include/{freetype2 => freetype}/ftstroke.h (100%) rename include/{freetype2 => freetype}/ftsynth.h (100%) rename include/{freetype2 => freetype}/ftsystem.h (100%) rename include/{freetype2 => freetype}/fttrigon.h (100%) rename include/{freetype2 => freetype}/ftttdrv.h (100%) rename include/{freetype2 => freetype}/fttypes.h (100%) rename include/{freetype2 => freetype}/ftwinfnt.h (100%) rename include/{freetype2 => freetype}/ftxf86.h (100%) rename include/{freetype2 => freetype}/t1tables.h (100%) rename include/{freetype2 => freetype}/ttnameid.h (100%) rename include/{freetype2 => freetype}/tttables.h (100%) rename include/{freetype2 => freetype}/tttags.h (100%) rename include/{freetype2 => freetype}/ttunpat.h (100%) diff --git a/Changelog b/Changelog index a24650f..bac3a64 100644 --- a/Changelog +++ b/Changelog @@ -743,3 +743,9 @@ - andy got here ~ Total of 7,379 lines of code! + +3/8/2016: +========= + + - fixed world draw shadings + - improved merchant menu diff --git a/Makefile b/Makefile index db92260..e49ff04 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ifeq ($(TARGET_OS),win32) endif CXXFLAGS = -m$(TARGET_BITS) -std=c++14 -CXXINC = -Iinclude -Iinclude/freetype2 +CXXINC = -Iinclude -Iinclude/freetype CXXWARN = -Wall -Wextra -Werror -pedantic-errors CXXSRCDIR = src diff --git a/include/freetype2/config/ftconfig.h b/include/freetype/config/ftconfig.h similarity index 100% rename from include/freetype2/config/ftconfig.h rename to include/freetype/config/ftconfig.h diff --git a/include/freetype2/config/ftheader.h b/include/freetype/config/ftheader.h similarity index 100% rename from include/freetype2/config/ftheader.h rename to include/freetype/config/ftheader.h diff --git a/include/freetype2/config/ftmodule.h b/include/freetype/config/ftmodule.h similarity index 100% rename from include/freetype2/config/ftmodule.h rename to include/freetype/config/ftmodule.h diff --git a/include/freetype2/config/ftoption.h b/include/freetype/config/ftoption.h similarity index 100% rename from include/freetype2/config/ftoption.h rename to include/freetype/config/ftoption.h diff --git a/include/freetype2/config/ftstdlib.h b/include/freetype/config/ftstdlib.h similarity index 100% rename from include/freetype2/config/ftstdlib.h rename to include/freetype/config/ftstdlib.h diff --git a/include/freetype2/freetype.h b/include/freetype/freetype.h similarity index 100% rename from include/freetype2/freetype.h rename to include/freetype/freetype.h diff --git a/include/freetype2/ft2build.h b/include/freetype/ft2build.h similarity index 95% rename from include/freetype2/ft2build.h rename to include/freetype/ft2build.h index 6f8eb7f..419b80a 100644 --- a/include/freetype2/ft2build.h +++ b/include/freetype/ft2build.h @@ -4,7 +4,7 @@ /* */ /* FreeType 2 build and setup macros. */ /* */ -/* Copyright 1996-2001, 2006, 2013 by */ +/* Copyright 1996-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -34,7 +34,7 @@ #ifndef __FT2BUILD_H__ #define __FT2BUILD_H__ -#include +#include #endif /* __FT2BUILD_H__ */ diff --git a/include/freetype2/ftadvanc.h b/include/freetype/ftadvanc.h similarity index 100% rename from include/freetype2/ftadvanc.h rename to include/freetype/ftadvanc.h diff --git a/include/freetype2/ftautoh.h b/include/freetype/ftautoh.h similarity index 100% rename from include/freetype2/ftautoh.h rename to include/freetype/ftautoh.h diff --git a/include/freetype2/ftbbox.h b/include/freetype/ftbbox.h similarity index 100% rename from include/freetype2/ftbbox.h rename to include/freetype/ftbbox.h diff --git a/include/freetype2/ftbdf.h b/include/freetype/ftbdf.h similarity index 100% rename from include/freetype2/ftbdf.h rename to include/freetype/ftbdf.h diff --git a/include/freetype2/ftbitmap.h b/include/freetype/ftbitmap.h similarity index 100% rename from include/freetype2/ftbitmap.h rename to include/freetype/ftbitmap.h diff --git a/include/freetype2/ftbzip2.h b/include/freetype/ftbzip2.h similarity index 100% rename from include/freetype2/ftbzip2.h rename to include/freetype/ftbzip2.h diff --git a/include/freetype2/ftcache.h b/include/freetype/ftcache.h similarity index 100% rename from include/freetype2/ftcache.h rename to include/freetype/ftcache.h diff --git a/include/freetype2/ftcffdrv.h b/include/freetype/ftcffdrv.h similarity index 100% rename from include/freetype2/ftcffdrv.h rename to include/freetype/ftcffdrv.h diff --git a/include/freetype2/ftchapters.h b/include/freetype/ftchapters.h similarity index 100% rename from include/freetype2/ftchapters.h rename to include/freetype/ftchapters.h diff --git a/include/freetype2/ftcid.h b/include/freetype/ftcid.h similarity index 100% rename from include/freetype2/ftcid.h rename to include/freetype/ftcid.h diff --git a/include/freetype2/fterrdef.h b/include/freetype/fterrdef.h similarity index 100% rename from include/freetype2/fterrdef.h rename to include/freetype/fterrdef.h diff --git a/include/freetype2/fterrors.h b/include/freetype/fterrors.h similarity index 100% rename from include/freetype2/fterrors.h rename to include/freetype/fterrors.h diff --git a/include/freetype2/ftgasp.h b/include/freetype/ftgasp.h similarity index 100% rename from include/freetype2/ftgasp.h rename to include/freetype/ftgasp.h diff --git a/include/freetype2/ftglyph.h b/include/freetype/ftglyph.h similarity index 100% rename from include/freetype2/ftglyph.h rename to include/freetype/ftglyph.h diff --git a/include/freetype2/ftgxval.h b/include/freetype/ftgxval.h similarity index 100% rename from include/freetype2/ftgxval.h rename to include/freetype/ftgxval.h diff --git a/include/freetype2/ftgzip.h b/include/freetype/ftgzip.h similarity index 100% rename from include/freetype2/ftgzip.h rename to include/freetype/ftgzip.h diff --git a/include/freetype2/ftimage.h b/include/freetype/ftimage.h similarity index 100% rename from include/freetype2/ftimage.h rename to include/freetype/ftimage.h diff --git a/include/freetype2/ftincrem.h b/include/freetype/ftincrem.h similarity index 100% rename from include/freetype2/ftincrem.h rename to include/freetype/ftincrem.h diff --git a/include/freetype2/ftlcdfil.h b/include/freetype/ftlcdfil.h similarity index 100% rename from include/freetype2/ftlcdfil.h rename to include/freetype/ftlcdfil.h diff --git a/include/freetype2/ftlist.h b/include/freetype/ftlist.h similarity index 100% rename from include/freetype2/ftlist.h rename to include/freetype/ftlist.h diff --git a/include/freetype2/ftlzw.h b/include/freetype/ftlzw.h similarity index 100% rename from include/freetype2/ftlzw.h rename to include/freetype/ftlzw.h diff --git a/include/freetype2/ftmac.h b/include/freetype/ftmac.h similarity index 100% rename from include/freetype2/ftmac.h rename to include/freetype/ftmac.h diff --git a/include/freetype2/ftmm.h b/include/freetype/ftmm.h similarity index 100% rename from include/freetype2/ftmm.h rename to include/freetype/ftmm.h diff --git a/include/freetype2/ftmodapi.h b/include/freetype/ftmodapi.h similarity index 100% rename from include/freetype2/ftmodapi.h rename to include/freetype/ftmodapi.h diff --git a/include/freetype2/ftmoderr.h b/include/freetype/ftmoderr.h similarity index 100% rename from include/freetype2/ftmoderr.h rename to include/freetype/ftmoderr.h diff --git a/include/freetype2/ftotval.h b/include/freetype/ftotval.h similarity index 100% rename from include/freetype2/ftotval.h rename to include/freetype/ftotval.h diff --git a/include/freetype2/ftoutln.h b/include/freetype/ftoutln.h similarity index 100% rename from include/freetype2/ftoutln.h rename to include/freetype/ftoutln.h diff --git a/include/freetype2/ftpfr.h b/include/freetype/ftpfr.h similarity index 100% rename from include/freetype2/ftpfr.h rename to include/freetype/ftpfr.h diff --git a/include/freetype2/ftrender.h b/include/freetype/ftrender.h similarity index 100% rename from include/freetype2/ftrender.h rename to include/freetype/ftrender.h diff --git a/include/freetype2/ftsizes.h b/include/freetype/ftsizes.h similarity index 100% rename from include/freetype2/ftsizes.h rename to include/freetype/ftsizes.h diff --git a/include/freetype2/ftsnames.h b/include/freetype/ftsnames.h similarity index 100% rename from include/freetype2/ftsnames.h rename to include/freetype/ftsnames.h diff --git a/include/freetype2/ftstroke.h b/include/freetype/ftstroke.h similarity index 100% rename from include/freetype2/ftstroke.h rename to include/freetype/ftstroke.h diff --git a/include/freetype2/ftsynth.h b/include/freetype/ftsynth.h similarity index 100% rename from include/freetype2/ftsynth.h rename to include/freetype/ftsynth.h diff --git a/include/freetype2/ftsystem.h b/include/freetype/ftsystem.h similarity index 100% rename from include/freetype2/ftsystem.h rename to include/freetype/ftsystem.h diff --git a/include/freetype2/fttrigon.h b/include/freetype/fttrigon.h similarity index 100% rename from include/freetype2/fttrigon.h rename to include/freetype/fttrigon.h diff --git a/include/freetype2/ftttdrv.h b/include/freetype/ftttdrv.h similarity index 100% rename from include/freetype2/ftttdrv.h rename to include/freetype/ftttdrv.h diff --git a/include/freetype2/fttypes.h b/include/freetype/fttypes.h similarity index 100% rename from include/freetype2/fttypes.h rename to include/freetype/fttypes.h diff --git a/include/freetype2/ftwinfnt.h b/include/freetype/ftwinfnt.h similarity index 100% rename from include/freetype2/ftwinfnt.h rename to include/freetype/ftwinfnt.h diff --git a/include/freetype2/ftxf86.h b/include/freetype/ftxf86.h similarity index 100% rename from include/freetype2/ftxf86.h rename to include/freetype/ftxf86.h diff --git a/include/freetype2/t1tables.h b/include/freetype/t1tables.h similarity index 100% rename from include/freetype2/t1tables.h rename to include/freetype/t1tables.h diff --git a/include/freetype2/ttnameid.h b/include/freetype/ttnameid.h similarity index 100% rename from include/freetype2/ttnameid.h rename to include/freetype/ttnameid.h diff --git a/include/freetype2/tttables.h b/include/freetype/tttables.h similarity index 100% rename from include/freetype2/tttables.h rename to include/freetype/tttables.h diff --git a/include/freetype2/tttags.h b/include/freetype/tttags.h similarity index 100% rename from include/freetype2/tttags.h rename to include/freetype/tttags.h diff --git a/include/freetype2/ttunpat.h b/include/freetype/ttunpat.h similarity index 100% rename from include/freetype2/ttunpat.h rename to include/freetype/ttunpat.h diff --git a/main.cpp b/main.cpp index af962db..1ff97ca 100644 --- a/main.cpp +++ b/main.cpp @@ -128,16 +128,6 @@ ThreadPool pool(10); GLuint colorIndex; -/* - * initEverything - * - * Before the main loop, things like the player, entities, and worlds should - * be created. This game has not reached the point that these can be scripted - * or programmed, so this function substitues for that. It is defined in - * src/gameplay.cpp. - * -*/ - /** * TODO */ @@ -205,11 +195,10 @@ void render(void); void mainLoop(void); - - /******************************************************************************* * MAIN ************************************************************************ *******************************************************************************/ + int main(int argc, char *argv[]){ (void)argc; (void)argv; diff --git a/src/entities.cpp b/src/entities.cpp index 06269d6..8a10428 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -8,6 +8,7 @@ extern std::istream *names; extern Player *player; // main.cpp extern World *currentWorld; // main.cpp extern unsigned int loops; // main.cpp +extern unsigned int tickCount; // main.cpp GLuint waterTex; @@ -295,6 +296,10 @@ void Object::reloadTexture(void){ void Entity::draw(void){ //draws the entities glPushMatrix(); glColor3ub(255,255,255); + + if ( !alive ) + return; + if(type==NPCT){ if(NPCp(this)->aiFunc.size()){ glColor3ub(255,255,0); @@ -626,6 +631,7 @@ void Player::save(void){ data.append(std::to_string((int)loc.y) + "\n"); data.append(std::to_string((int)health) + "\n"); data.append(std::to_string((int)maxHealth) + "\n"); + data.append(std::to_string((int)tickCount) + "\n"); data.append(std::to_string((int)inv->items.size()) + "\n"); for(auto &i : inv->items) @@ -666,6 +672,8 @@ void Player::sspawn(float x,float y){ health = std::stoi(ddata); std::getline(data,ddata); maxHealth = std::stoi(ddata); + std::getline(data,ddata); + tickCount = std::stoi(ddata); std::getline(data,ddata); for(i = std::stoi(ddata);i;i--){ diff --git a/src/ui.cpp b/src/ui.cpp index 97121b4..eb25e2e 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -30,6 +30,7 @@ extern std::vector AIpreaddr; */ extern bool gameRunning; +extern unsigned int tickCount; /* * Freetype variables, and a GLuint for referencing rendered letters. @@ -1276,6 +1277,9 @@ DONE: } else if ( !dialogBoxExists || dialogPassive ) { tmp = currentWorld; switch(SDL_KEY){ + case SDLK_t: + tickCount += 50; + break; case SDLK_a: if(fadeEnable)break; player->vel.x=-.15; diff --git a/src/world.cpp b/src/world.cpp index 4de6e39..0a84c20 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -407,6 +407,13 @@ draw( Player *p ) // world width in pixels int width = worldData.size() * HLINE; + // shade value for GLSL + float shadeAmbient = -worldShade / 50.0f + 0.5f; // -0.5f to 1.5f + if ( shadeAmbient < 0 ) + shadeAmbient = 0; + else if ( shadeAmbient > 0.9f ) + shadeAmbient = 1; + /* * Draw background images. */ @@ -459,7 +466,7 @@ draw( Player *p ) glEnable( GL_TEXTURE_2D ); bgTex->bindNext(); - safeSetColorA( 150 - shadeBackground, 150 - shadeBackground, 150 - shadeBackground, 220 ); + safeSetColorA( 150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255 ); glBegin( GL_QUADS ); for ( i = 0; i <= (int)(worldData.size() * HLINE / 1920); i++ ) { @@ -472,7 +479,7 @@ draw( Player *p ) for ( i = 0; i < 4; i++ ) { bgTex->bindNext(); - safeSetColorA( bgDraw[i][0] - shadeBackground, bgDraw[i][0] - shadeBackground, bgDraw[i][0] - shadeBackground, bgDraw[i][1] ); + safeSetColorA( bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][1] ); glBegin( GL_QUADS ); for( int j = worldStart; j <= -worldStart; j += 600 ){ @@ -534,7 +541,7 @@ draw( Player *p ) glUseProgram( shaderProgram ); glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 ); - glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), -worldShade / 50.0f ); + glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), shadeAmbient ); if ( p->light ) { pointArray[2 * (light.size() + 1) ] = (float)( p->loc.x + SCREEN_WIDTH / 2 ); @@ -1196,7 +1203,7 @@ void IndoorWorld::draw(Player *p){ glUseProgram( shaderProgram ); glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 ); - glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), 0.5f - worldShade / 50.0f ); + glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), 0.3f ); if ( p->light ) { pointArray[2 * (light.size() + 1) ] = (float)( p->loc.x + SCREEN_WIDTH / 2 ); -- 2.39.5