Jump to content

  • Log In with Google      Sign In   
  • Create Account






8) A poor man's day/night cycle.

Posted by AFS, 30 November 2013 · 2,010 views

I have a secret to tell: I noticed than I enjoy creating worlds much more than actually creating games. This is why I spent all this time (around 9 months now, time flies!) just creating a nice map editor and trying to draw the best placeholder assets that my my lack of skills can manage, instead of, you know, actually making a game.

Just thinking about implementing gameplay mechanics turns me off, but thinking about creating a huge city with the map editor makes me giggle like a little girl (I'm a guy). Maybe it's because I have a very clear idea of the world I want to make, but I have no idea about the gameplay mechanics (besides Jump / Shoot / Walk, which are obvious).

So, with that said, I spent these last two months just refactoring code to improve the use of the editor, or making some unnecesary stuff like new placeholders or a day/night cycle (which wasn't on my original idea of the game, and doesn't affect gameplay).

To archieve it, I just changed the tone of each sprite using SFML's "setColor()" method. With this method you can change the R/G/B values of any sprite. So, using a clock, I change slowly the values depending of the time. The values are:

Day: 255 - 255 - 255

Posted Image

Sunset: 200 - 130 - 130

Posted Image

Night - 80 - 80 - 130

Posted Image

It's a very low budget approach, but it's decent... I guess.

Here's a video of it in motion:



Cheers! :D




Looks really good. While I am not great at graphics I would think your approach would not be overly taxing on the computer to render night and day like this.

^ I'm very ignorant about how graphics work behind the scenes, so I appreciate the information, thanks!

 

It works "decent" (40-60 FPS) on my sister's laptop (512 RAM, 128 MB Intel integrated graphics, Intel Celeron M 1.73 GHz, singlecore, very dated). It drops to 40 when there's way too many sprites on screen (like on the screenshots above), regardless if the day/night cycle is on or off, so I guess I shouldn't worry about the cycle affecting performance :)

Still you have some awesome spirits.

:D

That's so cool!

Looks really good. While I am not great at graphics I would think your approach would not be overly taxing on the computer to render night and day like this.

 

If SFML sprites are implemented in a reasonable way (i.e. with every sprite having a fragment shader that gets the color passed in as a uniform - which is what cocos2d does) this should be really cheap (more likely it will have zero overhead).

SFML sprites are implemented as such. Though I wouldn't be surprised if videocards optimized the "(255,255,255)", and (0,0,0) cases.

July 2014 »

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27282930 31   
PARTNERS