Thursday, January 30, 2014

Project Aurora....something fishy

New game in the making!

General:
In this project I'm working in a group with 3 graphic students and 3 programmers.
For graphic we have Adam, Mikaela and Frida and for programmers we have me->Georgios, David, Oscar and Viktor.
(I will try to link them to their blogs at a later time)

In this project we have to make everything!....from the design document working with SCRUM and making the actual game. The game is based on a concept document made by another group from our first design course last autumn.

We had our first sprint planning today with our Scrum master Emma Matson (third year student) and with me as a producer. The producer role will change every week so all group members get to see how it feels.
If you aren't familiar with Scrum see the wikipedia link above.

Me and the other programmers will work together in this project using Git and Github to sync our code with eachothers. We will be coding in C++ and we will be using SFML graphic library instead of SDL that we used last course. I guess our teacher want to mess with our heads.
So there are alot of new things to learn and do.

Deadlines:
Scrum hand in: 31st Jan
Design Doc hand in: 14th Feb
Alpha: 21st Feb
Feature Freeze: 24th Feb
Write a Postmortem: 3rd Mars
Beta: 14th Mars
Game Finish:  28th Mars

Design:
The design of the game is and will be change all through this project but the main concept so far is that you are an Anglerfish that has lost her angler. You start out in shallow waters. You eat fish to survive. In game you find a fishin rod with a lightbulb attached to eat. with this you lure other fish closer. big and small so you have to lure small fish to eat and stay away from the big. The goal of the game is to survive and become the biggest fish in the sea. As the game progress you will transform from a cute fish to an ugly more scary fish.


Code:

I have bumped into some problems. When people are coding on so many different things at the same time its hard to know how my part will fit in.
After the sprint planning it was decided that I will start work on the DrawManager and GameObjectManager of the game.

The DrawManager is there to draw all the sprites to the screen. Only problem is that we have to make our own sprite class and I need to know the name of the class to finish my work.

When it comes to the GameObjectManager its much more difficult. This thing handle and update all game objects in game and I don't know what all object are. I have added some <vectors> that holds each type of object that is planned to be in. I'm not sure how to build the funtions in this class because well the design is not all ready so I will have to leave alot of functions blank so we can fill them in at a later time.
So this class will keep growing and be modified with.
So there are alot of guesswork going on right now. Im solving parts of this by looking back at my previous project and building in the same order where I can. Other things I build how I think it will work and some things I leave blank.
So now Im building attach functions that take object parameter that then is saved in a vector with push_back()-funtion for that type of object. I can also make a cleanup function to delete all the pointers to the objects. I will try to build update functions for each object type as well but Im not sure that can be done at this stage.

......
Edit
.....

Time spent for the basic DrawManager was about 30 minute to one hour and around 3 hours for the GameObjectManager. 1 hour was also spent on learning and understanding Git and fixing with commits/conflicts and solving them.

As a Producer I also noted that no one in the group has tested/verified another groupmembers work as agreed upon even though I told everyone to do so this afternoon. Even I haven't tested Viktors code that I was supposed to test because he haven't updated his status in the task tracker (Scrum) yet so I'm not sure if he is done.







Saturday, January 18, 2014

Day 23, Last Day!

Today I checked for memory leaks and I found six of them!!!! well actually it was more like two.

In one place I created a textobject and a sprite was created a few lines before that as well at the same time but not used or deleted.
And the animated sprites caused a leak when i deleted them because i deleted the sprite from the parent class and not the animated sprite in the actual object. I had already made the function and all for deleting it. I just forgot to change it in the cleanup funtion. So with those two fixed we are now leak free!
A thanks to my classmate Tomas for the tip of using Visual leak detector (https://vld.codeplex.com/)

I also went through some of the code and removed some lines of code not in use.

So we are now officially finished with this game! Hurrah!
Here are some screens of the first four levels:







And in some screens you see the bigger player. Here is another screen of that:



Day 22

Ok so...I thought I was finished with programming for this project but nope, Thanks to my classmate Tomas that spotted that my collision for box vs circle was wrongly made I went through the code and found also that circle vs circle was wrong.
I fixed circle vs circle fairly easy and I have the solution for box vs circle in my grasp but I just can't get the offset to work on the ball after the collision has occured and I am out of time. I also did a last minute change on the collision boxes for my borders and made 3 big ones instead of many small ones to decrease the chance of the ball wandering off.
I have decided one thing for the next game I make.....no bouncing balls in high speed.
Picutres of the finished game will come up as soon as I have time to add some.

I haven't started my report so I will spend the next 24 hours or so writing it.
Everything need to be handed in latest on sunday.


Friday, January 17, 2014

Day 21

I have been working all day and all night. Its now 5 in the morning and I need to sleep some before school later today. :-)
Finally we have something that feels like a game!
I added 10 levels to the game. I also added 3 more powerups with animation. So now you can get multiball, long pad, sticky pad and extra life. I polished the start screen little as well so it looks more "gamey" I added music and sound where it was needed. I didn't have time to get the MusicManager working as required, oh well, There is always a next project.

I really enjoy playing the game now. Its quite difficult. I haven't managed to get further than the 5th level.
Sure there are some bugs here and there but its something I can live with for the moment.

I will add screenshots tomorrow. Tomorrow I will be testing and polishing and writing the report.

Thursday, January 16, 2014

Day 20

So, I managed to fix collision between box vs circle and circle vs circle. I added an ingame brick that is round and have a Circle Collider so when the Ball Object hit it the code call a funtion to check circle vs circle. I also added collision between the balls but that caused alot of strange collisions so i removed that.

I added the WinState that Stefan made after I done som modifications like adding some TTF text to it.
I will probably add the highscore state Stefan made as well if I have time tomorrow.

I have also been fixing smaller things as well like the particle effect not stopping until it hits some bricks. I added that it also stops if the ball hit the wall. I shortened down the timer for the particles as well to about 2 seconds lifetime after they are created to prevent to many particles on screen.

I think the last day I will do work on my code is friday because i also need to start writing my report  for this project, Now in the last minute I am adding levels(smart eh?) and a transition between them.  I also added the ability to pause the game. I want to add more powerups as well because we only have one at the moment. I want to make it feel like a complete playable game I can be happy with when I leave it behind next week.


Wednesday, January 15, 2014

Day 19 (or rather night)

I worked half the night last night with adding different kinds of collisions. We already have a simple Box vs Box Collision. I moved the code that checked overlap between the boxes from the BoxCollider class to a function in the CollisionManager. I then added a CircleCollision class that holds one X-Y position and a radius.
I also added two functions in the CollisionManager to for check of overlap between circle vs circle and box vs circle. With all in place, I changed the BallObejct so when its created it gets a circle collider instead of a box collider.

I have learned the hard way how sensitive collision is for errors. One varible wrong and you screw up EVERYTHING!!!. I thought i lost it all and was almost about to get back the old code from our backups when i suddenly around 3 o'clock at night kind of solved it?? Don't ask me how but now it kind of works between box vs circle. I have to "fine tune" the code little bit more and then test and try to tune circle vs circle as well.

Oh, I forgot to take screenshots of the strange behaviours.

Monday, January 13, 2014

Day 18, Particle effect!

I finally added a particle effect. I made a new class called ParticleObject and added some functions and a vector to the GameObjectManager to handle the Particles. one particle is a 2 x2 sprite and they are drawn out and move in different directions after the ball. They start as soon as the ball is fired away and follow the ball until it hit the first brick and then they get deleted after about 3 seconds. I struggled most of the day to get everything to work. I'm not super happy about the looks but I'm satisified it works without any major crashes or memory leaks.

Early this morning I also fixed some bugs.

  • fixed a bug that caused some bricks not to get destroyed when hit.
  • fixed a bug that sent you to Game Over on your last life even though balls were still in play.

Here are some Pictures of the particle effect:





Day 17,

Today I fixed a huge bug I managed to miss last night. The bug caused all kinds of strange collision behavoirs when more balls were added to the game. With one ball everything worked fine. With two balls everything moved sligtly faster. The player pad started vibrating when touching the wall and the balls increased in speed in a strange way. With three balls in play everything went haywire. Bolls bouncing all over the screen they even bounced outside the game area. The player could move outside the border as well. luckily i could find the bug pretty fast and fix it...phew!

Then I went on to merge the SoundManager with the MusicManager that Stefan had made into an AudioManager when I learnt in class that they can be combined. It makes it easier to keep track of.

I then added a small config.txt file where the screen resolution is loaded from when the engine Initialize() is run.

I also moved some code from the GameState to the CollisionManager where I feel it belongs better. I added a function that is called in Gamestate that check all Collisions "CheckAllCollisions()"

Oh I almost forgot, I added Highscore into the game that is saved in a textfile. A check if you have beaten the highscore is done when you win or lose. If you have its then saved to a textdocument and loaded next time you play.

I also think I will skip adding an option state because time is running up. Only one week until the game and report have to be finished. I got about 4-5 days of programming left and I want to focus on features that give me a higher grade. Features like adding a GUI, particle/visual effects and maybe some more forms of collisions. and then we also need to clean up the code and remove unused code or "left overs" that might be hanging around. And we need to polish what we got.

Saturday, January 11, 2014

Day 16, Animation in place!

Thanks to Stefan we got our Animation class. The class files was in our shared Dropbox when i woke up and ready to be implemented. I had to change in some other files to get it to work.
I then added a ItemObject class that are the powerups you get. For now there is only one powerup and it gives you an extra ball. Original arkanoid gives you 2 new balls I think but I think we settle for 1 new ball.

With the new ItemObject i had to change the BrickObject class so they drop the items when destroyed. I also had to change the alot of the BallObject class so its now a vector in  our GameObjectManager that holds the balls instead of just one object like it was before. I put a limit of maximum 3 balls on screen at the same time. I had to do some smaller changes here and there to make it all work together. Was kind of tricky to get it to work without crashes. Here is a screen of what we got so far:


Next up is Highscore that can be saved and loaded to/from a file and also some tweaking music and soundmanagers and putting some sounds here and there. We also need to add a win state and I want an option state as well. Then I want visual effects in as well. We are running out of time and only have one week left now but I think we will pull it off.

Friday, January 10, 2014

Day 15, SCORE!!!!!

First I  had some problem implementing sound. The soundeffects played for a while then stopped but with some help from Jerry (co-teacher) I think we nailed it down so it works for now. haven't tested it too much.

And then....SCORE!! Yes after many hours of struggling i finally managed to nail it! We now got score in our game. If my way of doing it is the right way. I'm not sure??.....but it works!


The way it works is that an unsigned int keep track of the score. 100 points for each destroyed brick. It then change the int to a string with the function std::to_string();
After that is done I have to track down the text object that holds the score. I used a text string to "tag" the object since all textobjects are stored in a  <vector> I then delete that object and text and create a new object with the right score.

It works like a charm!
I also managed to get other text in game as well as you can see on the screenshot.
I then updated my black GameOverState to one with text. And with that I say good night and.......


Wednesday, January 8, 2014

Day 14,

I met with Stefan today as well, He finished up the sound/music classes and made the basic outline for the SoundManager and MusicManager. I will try to implement them to our project tomorrow.
We agreed that Stefan should carry on work on either ball vs ball collision or the animation class.

I didn't get much done. I worked some with adding TrueTypeFonts to the project so we can display score.
I will continue work on the score and how to save and load it to file for a highscore system.

Tuesday, January 7, 2014

Day 13,

I met with my partner for the first day in 3 weeks. We agreed that he should start with Music and Sound classes. And then move on to the Sound and MusicManagers together tomorrow when we meet again. I will continue work with text handling and the score system.

I didn't get much programming done today. But I did alot of testing and little tweaking with the collision between ball and bricks. It works better now but i still have some strange bugs.

I added some variables and functions to keep track if the brick is hit, damaged or destroyed. With those in place the game behave a little bit better than just destroying the bricks as soon as they had a collision with the ball.

Day 12, Some progress

I have left yesterdays mess behind me and today it went very well.
I cleaned up some stuff from yesterday and added some new things.
I  added a ButtonObject class that will take care of objects that can be clicked with the mouse like Start/Quit buttons. I had to do some work on the InputManager as well to get it all to work.

So I worked on the StartState and added the buttons and functionallity.
The buttons can be clicked but with no sound or animation. The menu button don't lead anywhere at the moment.


I also added some functionallity in game. You now lose a life when the ball goes outside the screen past the player. When all lives are lost, (Start + 3 lives) the GameState is stopped and you are sent to a black screen for 3 seconds(Game Over screen...work in progress).
Same goes when you destroy all bricks and win. Then you're also sent to the black screen.

I want a text on the win and game over screen and a score and some other text so I started working on how to solve that. I read up some on TTF and SDL and decided to download that.
I made a Textobject class and a TextManager that works basiclly as the Sprite class and SpriteManager class from the school workshop with Tommi.

I also drew some new sprites that i will use for animation and also an instruction sprite.



Tomorrow I will probably keep working on getting text into the game.


Monday, January 6, 2014

Day 11, What a mess!

The day started out well. I got some brilliant ideas about the code layout to get everything in order with the GameObjectManager so it could handle all kinds of GameObjects even from derived classes.
My plan was to put all my created GameObjects, PlayerObject, BallObject, BrickObject in my <GameObject*> vector.
I think I coded for 8 hours non stop, changing bascilly all code to a more dynamic way.
I must have been delusional because i went way ahead of my skill level and falled short when it came to accessing all derived Objects from said vector. I read up on Internet sources and I thought I had found a way.
Something like this (taken from Stackoverflow):
(edit: you can see the text below if you select the area with your mouse, don't know why it turned white)
std::vector<A*> aVector;
aVector.push_back(new B());
B* b = (B*)aVector[0];
cout << b->j;
(http://stackoverflow.com/questions/13569661/c-reach-derived-class-variables-from-vector)

where A is the parent class and B is the derived /inherited class.

B* b = (B*)aVector[0];
This line was my salvation. or so I thought. Instead it almost became my doom.
I got all sorts of crashes. I just didn't get it to work after alot of trying I gave up. Luckily I had made 2 backups.
When I went back to the backup and opened up the project to my FEAR it was the same project I just closed!! I checked and double checked and triple checked! I opened the second backup as well and it was also the same! I started sweating.....OMG!!! ALL IS LOST!!! all work the last few weeks. GONE!

It just couldn't be!....how could it? I made the backups way before the major changes. Why did all projects look the same! I think I spent an hour just panicing. But being a programmer and all I started to break down the problem and decided to open each cpp file one by one in notepad next to Visual studio so I could check the code line by line. Thank god I did! I shortly realized that when you copy a whole Visual Studio project/solution and it got the same name as the original folder it somehow opens the most recent file even if they are in different folders on your computer. It was so strange.
I created a new project with a different name and copied all the cpp and heather files to the new project. The joy to see my original code. I could breathe again. I was saved!

Tip: If you want to backup your project. just copy your cpp and .h files and all art and stuff. Do NOT copy the whole solution/project.

I spent the rest of the day repairing and improving the backup I salvaged.
This whole mess made me grow in understanding alot. why some crashes happen and how to code in a better way. Sure I didn't get much done compared to last time but I learned alot and I'm happy for this little incident.

(Sorry for bad English and writing. no spellchecking tonight. I'm too tired)

Friday, January 3, 2014

Day 10, Something looking like Arkanoid

I have been working since 06:00 in the morning both with programming and graphical things.
I developed the CollisonManager some more so it can handle both ball and player collision.
It still have some bugs like the ball getting stuck or bouncing in some strange ways. and  it rarely push through the game border and gets away. I'm thinking of changing how the collision is handled for the border.
I added a BrickObject class to keep track of the bricks. For example like how they are destroyed and how they are loaded.
In GameObjects I also added a boolean flag to check if an Object is destroyable or not.
Here is a screen of what we got so far:


Next I need to work on adding more states and devolping them and I also need to add a win and lose condition.
I have already worked some on the StartState (renamed from  MenuState) but it have no functionallity yet except pressing "spacebar" to move to next state.
After that I guess I will focus on lifes/Gamerounds with states in states, or maybe add animation in some way.

I have also managed to "break" my Visual Studio so I can't use breakpoints when debugging.
I guess its my great coding abilities that managed that. hopefully I sort out that problem soon :-)

Wednesday, January 1, 2014

Day 9, New Year, Box Collision solved!

New year and new thoughts. I solved the collision problem we had! Hurrah!
When collision was checked it checked all the objects in the ObjectManager including checking collision against PlayerObject vs PlayerObject. The Player sprite and collider is is 27 x 6 pixels so the 6 pixels wrong came from that somehow. When I took that out of the equation it worked perfectly! PlayerObject shouldn't be able to collide with  itself anyway.

I then rebuilt the whole Ball class we had so it inherit from the GameObject class and have a BoxCollider to start with to test functionallity of the game. The collision of the ball is okay but sometimes the ball get stuck in the wall. It might be because I made it so speed is added to the ball with every collision. Something that needs more testing.



 I also made it so that the ball stays on the playerObject until it gets shot even if the player moves.


I also started working with a CollisionManager so we can handle more kinds of collisions and handle it in a better way. I will continue this work tomorrow. If time permits I will also look at seperating loading of the bricks and the destruction of them.