Grog-Knight

some game in C++
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/Grog-Knight

commit cb99c6da30efbd91452e629689d35b7c390919b5
parent 52b98cdd408621d22f71814c8f0232537dffdd6f
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 22 May 2015 17:55:54 +0200

Fix(Graphix): Fix the graphics:
AWEEEEEEEEEEEEEEEEEEESOME FIX TO THE SKY
Angel need a recomp !

Diffstat:
MAngel/Infrastructure/Common.h | 3+++
MAngel/Infrastructure/Textures.cpp | 24++++++++++++++++++------
MMakefile | 3++-
MMaps/MapCastle_3.json | 2+-
AMaps/test.json | 269+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AResources/Images/test.png | 0
MSources/src/Elements.cpp | 5+----
MSources/src/Game.cpp | 7++++---
8 files changed, 298 insertions(+), 15 deletions(-)

diff --git a/Angel/Infrastructure/Common.h b/Angel/Infrastructure/Common.h @@ -97,6 +97,9 @@ #include <GLFW/glfw3.h> #endif +#include <glext.h> +//#define GL_CLAMP GL_CLAMP_TO_EDGE + #include <math.h> #include <iostream> #include <string> diff --git a/Angel/Infrastructure/Textures.cpp b/Angel/Infrastructure/Textures.cpp @@ -144,8 +144,8 @@ bool PurgeTexture(const String& filename) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ClampMode); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, FilterMode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilterMode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); @@ -301,12 +301,12 @@ bool PurgeTexture(const String& filename) glGenTextures(1, &texRef); glBindTexture(GL_TEXTURE_2D, texRef); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clampmode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clampmode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtermode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtermode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexImage2D( GL_TEXTURE_2D, @@ -331,6 +331,18 @@ const int GetTextureReference(const String& filename, GLint clampmode, GLint fil bool cached = false; TextureCacheEntry* currentCacheEntry = NULL; + /* + * + *nameThe path to the file to load. Must be readable by DevIL. ( http://openil.sourceforge.net/) + clampmodeEither GL_CLAMP or GL_REPEAT. + filtermodeOne of: GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, G L_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, or GL_LINEAR_MIPMAP_LINEAR + optionalIf true, the engine won't complain if it can't load it. + */ + // HARD WAY + clampmode = GL_CLAMP_TO_EDGE; + filtermode = GL_NEAREST; + + //check cache to see if it's loaded already std::map<String,TextureCacheEntry>::iterator it = theTextureCache.find(filename); diff --git a/Makefile b/Makefile @@ -20,7 +20,8 @@ INCLUDE = \ -I/usr/include/freetype2 \ -I./Tools/jsoncpp/include \ -ISources/inc/ \ - -ILibraries/DevIL-SDK-1.7.8/mac/include/ + -ILibraries/DevIL-SDK-1.7.8/mac/include/ \ + -IAngel/Infrastructure/ ifneq ($(ANGEL_DISABLE_FMOD), 1) INCLUDE += -IAngel/Libraries/FMOD/inc diff --git a/Maps/MapCastle_3.json b/Maps/MapCastle_3.json @@ -12,7 +12,7 @@ "y":0 }, { - "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 19, 20, 21, 0, 0, 0, 0, 0, 0, 0, 72, 77, 72, 72, 72, 72, 72, 77, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72, 72, 72, 77, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 48, 48, 48, 48, 48, 48, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 63, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":16, "name":"Tile Layer 2", "opacity":1, diff --git a/Maps/test.json b/Maps/test.json @@ -0,0 +1,268 @@ +{ "height":16, + "layers":[ + { + "data":[1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 9, 10, 11, 12, 13, 14, 15, 7, 9, 10, 11, 12, 13, 14, 15, 9, 10, 11, 12, 13, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 15, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 25, 26, 27, 28, 29, 30, 31, 25, 26, 27, 28, 29, 30, 31, 23, 25, 26, 27, 28, 29, 30, 31, 25, 26, 27, 28, 29, 33, 34, 35, 36, 37, 38, 39, 33, 34, 35, 36, 37, 38, 39, 31, 33, 34, 35, 36, 37, 38, 39, 33, 34, 35, 36, 37, 41, 42, 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, 46, 47, 39, 41, 42, 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 9, 10, 11, 12, 13, 14, 15, 9, 10, 11, 12, 13, 14, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 25, 26, 27, 28, 29, 30, 31, 25, 26, 27, 28, 29, 30, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 33, 34, 35, 36, 37, 38, 39, 33, 34, 35, 36, 37, 38, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, 46, 41, 42, 43, 44, 45, 46, 47, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 52, 53, 54, 55, 49, 50, 51, 52, 53, 54, 49, 50, 51, 52, 53, 54, 55, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 41, 56, 36, 48, 41, 42, 43, 44, 45, 46, 47, 48, 54, 55, 56, 49, 49, 56, 56, 53, 54, 55, 56, 49, 44, 44, 44, 53, 54, 55, 56, 49, 50, 52, 49, 52, 56, 52, 52, 52, 52, 52, 58, 59, 60, 61, 62, 63, 64, 57, 58, 59, 60, 61, 62, 63, 64, 57, 58, 59, 60, 57, 58, 59, 60, 61, 62, 63, 64], + "height":16, + "name":"Tile Layer 1", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":27, + "x":0, + "y":0 + }], + "nextobjectid":1, + "orientation":"orthogonal", + "properties": + { + + }, + "renderorder":"right-down", + "tileheight":32, + "tilesets":[ + { + "firstgid":1, + "image":"Resources\/Images\/test.png", + "imageheight":256, + "imagewidth":256, + "margin":0, + "name":"etst", + "properties": + { + + }, + "spacing":0, + "tileheight":32, + "tileproperties": + { + "0": + { + "physic":"0" + }, + "1": + { + "physic":"0" + }, + "10": + { + "physic":"0" + }, + "11": + { + "physic":"0" + }, + "12": + { + "physic":"0" + }, + "13": + { + "physic":"0" + }, + "14": + { + "physic":"0" + }, + "15": + { + "physic":"0" + }, + "16": + { + "physic":"0" + }, + "17": + { + "physic":"0" + }, + "18": + { + "physic":"0" + }, + "19": + { + "physic":"0" + }, + "2": + { + "physic":"0" + }, + "20": + { + "physic":"0" + }, + "21": + { + "physic":"0" + }, + "22": + { + "physic":"0" + }, + "23": + { + "physic":"0" + }, + "24": + { + "physic":"0" + }, + "25": + { + "physic":"0" + }, + "26": + { + "physic":"0" + }, + "27": + { + "physic":"0" + }, + "28": + { + "physic":"0" + }, + "29": + { + "physic":"0" + }, + "3": + { + "physic":"0" + }, + "30": + { + "physic":"0" + }, + "31": + { + "physic":"0" + }, + "32": + { + "physic":"0" + }, + "33": + { + "physic":"0" + }, + "34": + { + "physic":"0" + }, + "35": + { + "physic":"0" + }, + "36": + { + "physic":"0" + }, + "37": + { + "physic":"0" + }, + "38": + { + "physic":"0" + }, + "39": + { + "physic":"0" + }, + "4": + { + "physic":"0" + }, + "40": + { + "physic":"0" + }, + "41": + { + "physic":"0" + }, + "42": + { + "physic":"0" + }, + "43": + { + "physic":"0" + }, + "44": + { + "physic":"0" + }, + "45": + { + "physic":"0" + }, + "46": + { + "physic":"0" + }, + "47": + { + "physic":"0" + }, + "48": + { + "physic":"0" + }, + "49": + { + "physic":"0" + }, + "5": + { + "physic":"0" + }, + "50": + { + "physic":"0" + }, + "51": + { + "physic":"0" + }, + "52": + { + "physic":"0" + }, + "53": + { + "physic":"0" + }, + "54": + { + "physic":"0" + }, + "55": + { + "physic":"0" + }, + "6": + { + "physic":"0" + }, + "7": + { + "physic":"0" + }, + "8": + { + "physic":"0" + }, + "9": + { + "physic":"0" + } + }, + "tilewidth":32 + }], + "tilewidth":32, + "version":1, + "width":27 +}+ \ No newline at end of file diff --git a/Resources/Images/test.png b/Resources/Images/test.png Binary files differ. diff --git a/Sources/src/Elements.cpp b/Sources/src/Elements.cpp @@ -122,10 +122,7 @@ void Elements::setFrameSprite(int frame) { tY2 -= fY; } } - if (frame < nbPerColumn) - this->SetUVs(Vector2(tX + 0.01, tY + 0.01), Vector2(tX2 - 0.01, tY2 - 0.01)); - else - this->SetUVs(Vector2(tX + 0.01, tY + 0.01), Vector2(tX2 - 0.01, tY2 - 0.01)); + this->SetUVs(Vector2(tX, tY), Vector2(tX2, tY2)); } //! Display an element diff --git a/Sources/src/Game.cpp b/Sources/src/Game.cpp @@ -112,7 +112,8 @@ void Game::start(void) { Game::currentX = 1; Game::currentY = 1; theCamera.SetPosition(this->maps->getMapXY()[Game::currentY][Game::currentX]->getXMid(), - this->maps->getMapXY()[Game::currentY][Game::currentX]->getYMid() + 1.8, 9.2); + this->maps->getMapXY()[Game::currentY][Game::currentX]->getYMid() + 1.8, 9.001); + // 9.2 hero->init(); hero->equipWeapon(Game::wList->getWeapon("Sword")); hero->equipRing(Game::rList->getRing("SmallRing")); @@ -188,7 +189,7 @@ int Game::getNextId(void) { } void Game::checkHeroPosition(void) { - if (Game::started == 1) + if (Game::started == 1) Game::currentGame->moveCamera(); } @@ -212,7 +213,7 @@ void Game::moveCamera(void) { if (asChanged) { theCamera.SetPosition(this->maps->getMapXY()[Game::currentY][Game::currentX]->getXMid(), - this->maps->getMapXY()[Game::currentY][Game::currentX]->getYMid() + 1.8, 9.2); + this->maps->getMapXY()[Game::currentY][Game::currentX]->getYMid() + 1.8, 9.001); } }