Car Pollution Game: Week Two
- whereisbobgone
- Oct 4, 2014
- 2 min read
Hello again,
This week not much was done at Uni, it was mostly just going over and refreshing concepts that I learnt last year. But I was given the brief of a prototype game we are to make in a week. For my prototype, I ended up deciding to make a game where you need to buy cars to create pollution so the government can pay you, so you can then buy more cars.
I started the project and instantly got stuck on getting the mouse location so I can check to see if the player is clicking on a specific button. It took me a while to figure this one out. I made a class for the button, so it checks for me if the mouse is over it and I couldn't figure out how to get the mouse position to work inside of the button.cpp. Long story short turns out that I could use a pointer to my window to fix everything.
Then after I had a little party to celebrate the fixing of my bug, I instantly ran into another one. This time it was getting a mouse click; it took me 5 hours off and on, but mainly on to figure it out. First I had to figure out what I was going to use to get the mouse presses, there was the event.type = bla bla there was some other ones that google told me about that didn't work. Ended up going with Mouse::isButtonPressed. After figuring out what I was going to use, I then had to figure out how to get it to click, instead of holding down, I did have some old code of mine to go off, but it was very messy to follow and made me confused, so I searched for different ways of doing it. I ended up spacing all my code apart so I could see and keep track of everything and I went through it step by step until it finally worked for me. Still have a small problem of the click will detect even if it is a click outside of the game.
I learnt some things about myself from these two bugs I ran into today. First is that I don't give up very easily, I would have spent a total of 7-8 hours fixing the bugs, but not once did I rage and give up.
Second is that I can be really bad at using my time wisely; I did work on other parts of the game while I was thinking of ways to fixing my problems, but there still was a massive bottle neck for a long amount of time, I need to work on ways to not do this in the future.
But at the end of the day, I've made a class that all I need to do is tell it where its top, left, bottom and right positions on the screen are and I've got a button that can detect when it’s been clicked. And even then I think there is some code build into SFML that can tell me if the mouse is over a sprite.
I'd say a good day of work. Till next time.
Nathan out!
Comments