I have made a small platformer with no issues. But I created a roguelike top down framework and for some reason the opendoors facing one direction are way darker. There is no sf::Color code or anything it is treated no different than any other texture sprite.
Just initialized setTexture() then for each tile in map window.draw()? What could be the issue?
//INITIALIZE TEXTURES//
enum textures{ENEMYTEX = 0, PLAYERTEX, GUNHANDTEX, BULLETTEX, MENUBLOCKTEX, WALLTEX, FLOORTEX1,FLOORTEX2,
FLOORTEX3,FLOORTEX4,UNUSEDTEX,SMALLHEALTHTEX,MEDIUMHEALTHTEX,SMALLMANATEX,MEDIUMMANATEX,GOLDSACKTEX,
UPSTAIRSTEX,DOWNSTAIRSTEX,CLOSEDDOORTEX,OPENDOORTEX,CLOSEDDOORROTATEDTEX,OPENDOORROTATEDTEX};
enum sounds{ENEMYHURT = 0, ENEMYDEATH, GUNSHOT, SAVEME, DONTWORRY, PROTAGANIST1, PROTAGANIST2
,NORMALBACKGROUND,BOSSBACKGROUND};
inline void loadTextures()
{
textureArray[ENEMYTEX].loadFromFile("data/images/enemy.png");
textureArray[PLAYERTEX].loadFromFile("data/images/player.png");
textureArray[GUNHANDTEX].loadFromFile("data/images/gunhand.png");
textureArray[BULLETTEX].loadFromFile("data/images/bullet.png");
textureArray[MENUBLOCKTEX].loadFromFile("data/images/menublock.png");
textureArray[WALLTEX].loadFromFile("data/images/wall.png");
textureArray[FLOORTEX1].loadFromFile("data/images/floor1.png");
textureArray[FLOORTEX2].loadFromFile("data/images/floor2.png");
textureArray[FLOORTEX3].loadFromFile("data/images/floor3.png");
textureArray[FLOORTEX4].loadFromFile("data/images/floor4.png");
textureArray[UNUSEDTEX].loadFromFile("data/images/unusedtile.png");
textureArray[SMALLHEALTHTEX].loadFromFile("data/images/smallhealth.png");
textureArray[MEDIUMHEALTHTEX].loadFromFile("data/images/mediumhealth.png");
textureArray[SMALLMANATEX].loadFromFile("data/images/smallmana.png");
textureArray[MEDIUMMANATEX].loadFromFile("data/images/mediummana.png");
textureArray[GOLDSACKTEX].loadFromFile("data/images/goldsack.png");
textureArray[UPSTAIRSTEX].loadFromFile("data/images/upstairs.png");
textureArray[DOWNSTAIRSTEX].loadFromFile("data/images/downstairs.png");
textureArray[CLOSEDDOORTEX].loadFromFile("data/images/closedDoor.png");
textureArray[OPENDOORTEX].loadFromFile("data/images/openDoor.png");
textureArray[CLOSEDDOORROTATEDTEX].loadFromFile("data/images/closedDoorRotated.png");
textureArray[OPENDOORROTATEDTEX].loadFromFile("data/images/openDoorRotated.png");
}
//INITIALIZE TEXTURES ON TILE SPRITE//
inline Tile::Tile(short type,sf::Vector2f position)
:GameEntity(position,TileSize)
{
switch(type)
{
case Unused:
GameEntity::setTexture(UNUSEDTEX);
break;
case Wall:
GameEntity::setTexture(WALLTEX);
break;
case Floor:case Corridor:
GameEntity::setTexture(FLOORTEX1);
break;
case ClosedDoor:
GameEntity::setTexture(CLOSEDDOORTEX);
break;
case ClosedDoorRotated:
GameEntity::setTexture(CLOSEDDOORROTATEDTEX);
break;
case OpenDoor:
GameEntity::setTexture(OPENDOORTEX);
break;
case OpenDoorRotated:
GameEntity::setTexture(OPENDOORROTATEDTEX);
break;
case DownStairs:
GameEntity::setTexture(DOWNSTAIRSTEX);
break;
case UpStairs:
GameEntity::setTexture(UPSTAIRSTEX);
break;
}
setColor(sf::Color(255,255,255,255)); //No effect
}
//DRAW TILE SPRITES WITHIN VIEW BOUNDS//
inline void Tile::draw(WINDOW& appWindow)
{
appWindow.draw(*this);
if(thingsOnTile.size() > 0)
{
appWindow.draw(*thingsOnTile[thingsOnTile.size()-1]);
}
}
inline void Map::draw(WINDOW& appWindow,sf::View& view)
{
sf::FloatRect viewRect = sf::FloatRect{view.getCenter().x-(view.getSize().x/2),
view.getCenter().y-(view.getSize().y/2),
view.getCenter().x+(view.getSize().x/2),
view.getCenter().y+(view.getSize().y/2)};
short yMax = floor(viewRect.height/TileSize.y);
short yMin = floor(viewRect.top/TileSize.y);
if(yMin < 0) yMin = 0;
short xMax = floor(viewRect.width/TileSize.x);
short xMin = round(viewRect.left/TileSize.x);
if(xMin < 0) xMin = 0;
print("Y MIN:" + tostr(yMin) + "Y MAX: " + tostr(yMax));
print(viewRect.top);
for(int y = yMin; y <=yMax; ++y)
for( int x = xMin; x <=xMax; ++x)
{
print(x+(y*tilesWide));
this->at((y*tilesWide)+x).draw(appWindow);
}
}
//Although the viewrect thing is irrelevent same thing happens when i just go auto i : Tiles window.draw(i);
Its a very strange thing because I have one tile for a door oriented vertically and one for a door oriented horizontally. and all I did is rotate the horizontal one to vertical in GIMP and save it and it comes out way darker than it looks in the PNG file when I draw it in the program. I know I could do the rotations in the program but meh. I honestly will have to try I guess. Just seems very strange that all I did was rotate the PNG file and save it as another PNG file and then add it to the program and it comes out all blacked out like its messed up transparency or something.
I can fix it by doing
case OpenDoor:
GameEntity::setTexture(OPENDOORROTATEDTEX);
setRotation(90);
move(50,0);
break;
with the texture that doesn't mess up. But still dunno why it occurs.