Lighting in the darkness

Hi and welcome to this week of programming 1.1.

This week I was going to work with something I dreaded and was excited to learn from first choosing colossus core as our Concept the lightning where we wanted it to be dark except where we light up in the game to see where we are looking or effects from things as secondary weapons such as missiles, lasers or even our time bomb.

We will also use our lights to show how much damage our ship has taken and when we are exploring the caves we will happen upon old ship parts from previous ships (not previous runs) and they will blink I think.

The colossus core concept had a dynamic lightning system where the light collides with objects and don’t show up behind but as I was looking upon guides to see how it was made I found some who was plausible and I took what I learned and discussed it with one of our graphic students in our group named Oscar. We decided we shouldn’t implement dynamic lightning and decided on a static lightning where it won’t collide with the surroundings because it was easier and removed a lot of work from our graphic designers too.

Now to begin with I decided to make everything dark I made a sf::RenderTexture and a sf::Sprite in a class for the darkness then I used .create (Screen width , Screen Height) and then I set the texture but I had to Sprite. Get Texture for it to work. By this time It was time to work in main where I prototype where I cleared the texture of the render texture then this is where I have to draw out the lights it out before the clear of window then I had to draw out the darkness.

Now it was time for my light class to begin with I added sf::Texture and sf::Sprite then I began by setting the texture I was going to use for my experiment and fixed the colors at 255,255,255 and the transparency at 255.

Now something I still have some problems with is I have to use Blendmode::BlendAdd to work which is needed to make it see through the darkness but I will burrow through to and hope I can succeed.

For I will only make a single object instead of a vector for our lights since I only want to try how it works. Now I will draw it out before I display it on the black canvas.12784570_10153975642788620_1627045639_n

If you want the link for the tutorial from this work just pm me.

Programming our Heads up display

I began our fifth week by fixing a few problems I had with my missile movement by taking the values from inside the window so now they work properly.

I had an exciting task ahead of me this week I had to program our Heads up display and what my group wanted was something different from what you would normally see in a game. Where in games you have numbers and health bars everywhere but not to different and it ended as a good experience for me. They wanted 3 energy bars on the bottom half of the screen with the bars increasing on a timely basis.

I started by taking a sprite one of your graphic designers made and loaded the texture onto a sprite inside the HUD class as well as the setting other options such as the color with a transparency which was easily done by adding a forth number inside sf:Color(x,x,x,X) and to make things easier I set the origin of the sprite in the middle of it.

Now I had some problems since I wanted to use my Heads up display class and make an array to draw out three sprites on my window but it did not want to be push backed. My solution was simply to make my array into a std::vector and create tree objects.

Now I had to draw out my sprites on the window but since my view moves I had to bind them to my view instead, I did this by setting the position by calculation using the views center x minus or plus the view size x and depending on where I wanted it on my screen I used differential of 2 or 4 then I took the view center y plus view size differential 2 minus the Heads up display local height.

By this time I had three outlays to draw my energy meters upon so I started by making a similar class as the Heads up display and this time I also needed a vector for my energy meter class so i created the object 100 times using a for loop to make bar. Then I set the position for inside the first heads up display object and used used another for loop with an integer with the current energy you possessed this was in a white color.

To be sure it wouldn’t continue forever I set a maximum value and used if statements to stop the white bar. Then I made a new sprite and draw it out using the same object on the same surface behind the current bar so you should see when the white bar was full in a gray color.

gz0SOsg

Haiku

Coding is fun

in the bad, messy, main.

The code comes toghter!

A Beginning and Movement with Math

Our team have choosen to work on the concept “Colossus Core” made by another team where you explore caves on a foreign planet with dangerous enemies that you have to fight with your special made hovercraft.

As the week has past we have had alot of technical problems and a slow start but now as time getting close to the deadline for our Alpha everyone have started to pull their o own weight and we are now racing to finish our every aspect that is needed for our Alpha in time.

But now that the forth week has began i have started experimenting on  our entities movement issues in our game, i started with our Player Avatar which i realized had very boring feeling movements after prototyping it’s movement felt way to strict so i made it more fluent by using easy mathematical calculations.Movement.gif

To make our Avatar to move where he is “looking” i used the angle and to calculate it i used (PI/180) * Avatars rotation and then 0.01*cos(angle) for x and 0.01*sin(angle) for y. By doing this i was now able to change our controls to move the ship forward and in reverse by pressing W and S. Then i changed A and D so you are able to rotate the ship in the direction you wish to go.

But what problems have given me the biggest amount of headache would be to get our ships missile to fly from our ship towards the position you click at with the mouse. I finally i got help from a friend with the calculations to move the missile and used the calclutation to move the missiles sprite from point A to point B.

angle = atan2(player position y – enemy globalbounds height / 2) – enemy position y and (player position x – enemy globalbounds width /2) – enemy position x then inside the move function for my enemy sprite i put in the cos(angle) * the movementspeed i decided in the x and sin(angle) * the movementspeed in y.

To finish this weeks work with movements i fixed the attack of one our monster to move towards our player which is one of the easier monster patterns to face in our game to program this i decided to mirror my movement for the missile and only change the parameters.

I have no finished with movement calculations for the moment and will  now close of this week off.