Skip to content

Commit

Permalink
Fixed sky changing colors on settings changed
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeSilva committed Nov 13, 2015
1 parent 410d686 commit 0dc722c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions source/dayNight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "worldRender.h"
int timeTillChange = 0;

int lastWorldBrightness = 0;
u8 r[15] = {12, 12, 11, 10, 10, 9, 8, 6, 6, 5, 4};
u8 g[15] = {15, 13, 13, 11, 10, 8, 7, 5, 4, 3, 2};
u8 b[15] = {31, 31, 30, 29, 28, 27, 26, 26, 24, 23, 15};
Expand All @@ -28,6 +30,9 @@ void dayNightUpdate(WorldObject &world)
else if (world.timeInWorld > 110) world.worldBrightness = 10 - (world.timeInWorld - 110);
else if (world.timeInWorld >= 90) world.worldBrightness = 10;
else world.worldBrightness = 0;

lastWorldBrightness = world.worldBrightness;

setSkyColor(r[world.worldBrightness], g[world.worldBrightness], b[world.worldBrightness],
r2[world.worldBrightness], g2[world.worldBrightness], b2[world.worldBrightness]);
setSun(world.worldBrightness);
Expand All @@ -46,8 +51,8 @@ bool isDay(WorldObject &world)
return world.timeInWorld >= 0 && world.timeInWorld < 80;
}

void setSkyDay()
void resetSky()
{
setSkyColor(r[0], g[0], b[0], r2[0], g2[0], b2[0]);
setSkyColor(r[lastWorldBrightness], g[lastWorldBrightness], b[lastWorldBrightness], r2[lastWorldBrightness], g2[lastWorldBrightness], b2[lastWorldBrightness]);
}

2 changes: 1 addition & 1 deletion source/dayNight.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#include "world.h"
void dayNightUpdate(WorldObject &world);
bool isDay(WorldObject &world);
void setSkyDay();
void resetSky();
2 changes: 1 addition & 1 deletion source/graphics/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void graphicsInit()
{
loadTexture(getGlobalSettings()->textureName.c_str());
worldRender_Init();
setSkyDay();
resetSky();

clearMainGraphics();
vramSetBankD(VRAM_D_SUB_SPRITE);
Expand Down
2 changes: 1 addition & 1 deletion source/titleScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void audioScreen()
void changeSkyProperty(UIElement *element, int property, bool state)
{
setPropertyAction(element, property, state);
setSkyDay();
resetSky();
}

void settingsScreen()
Expand Down

0 comments on commit 0dc722c

Please sign in to comment.