Game Development! Blogg post 2
|
Hi! This is the second week of blog writing during our project for the game development course. This is the week we will present our Alpha up on stage, something I was chosen to do by our group. But enough of that this blog is supposed to showcase something I have programmed this week. For my second post I will be focusing on the fog of war that I implemented this week with the help of Pontus Persson’s tutorial and a helping hand by Johan Holmér, a fellow programmer from a different project in my class. What it basically does is cover the map in darkness and allow a small radius around the player, Otto (who is our villain) and the glow sticks to shine through and show the map underneath them. This is to simulate a basic lighting that gives us the “fog of war” effect that we are looking for in our game to increase the tension. This was achieved by using a sf::RenderTexture which basically is a mini version of the sf::RenderWindow that we use to draw things on the screen. We can take all of the different lights, and the big box of shadow, and draw them all to the RenderTexture using sf::BlendAdd for all the light sources that should blend with the big darkness that we create whe we do RenderTexture.clear(Black). Then when we actually draw the RenderTexture onto our main window we use sf::BlendMultiply to make the map shine through in the light from the objects. We have a separate class called Light that every entity the need a light source connected to in will instantiate. There we create a new Light with the parameters position, scale, color, and the sprite that we want that light to have. This gives us a nice way of controlling and customizing the light for different uses, for example, we made Otto’s light red so the player realizes that he is dangerous and that they should probably run for their lives. The light class also has methods for controlling the light that it will show, so that we on the fly can change things like color, size and rotation of the light. This has so far only been utilized with Otto, which I gave a pulsing effect by changing his light scaling in his update slowly bigger and then smaller again. These utilities are very convenient as they can later be used to create fireplaces, lamps or windows that get struck by lightning, all things that are very effective at raising the tension and immersion in the game. |