[5SD033]Potato Pirates, Week Three – Potato GUI
|
This week I have been working on one of the integral parts of our game, namely dropping potatoes for the distilleries to make into booze. When the player is within a certain area of the distillery the player can press “Enter” to open up the potato drop menu. Here the player can press different buttons to increase or decrease the amount of potatoes to be dropped. Dropping a larger amount of potatoes will result in a larger amount of points but will also leave the player with less ammunition to use while returning to their base of operations to pick up more potatoes. The players amount of potatoes is displayed to the left and the amount of money on the right. The negative buttons decrease the amount of potatoes that will be dropped and the positive increase it. Sadly the screen-cap did not capture the mouse, but the mouse is supposed to be on the “+10” button. ![]() I had initially wanted either some kind of a slider or maybe a textbox where the player could simply enter the amount of potatoes they would wish to drop. But SFML had real no functionality for a textbox where a user could enter text. There probably was some way to do it but we had to many features that still had not been implemented and with the feature-freeze being on monday I settled with a slightly easier way for the player to choose how many potatoes to drop. The end result was what you can see in the picture above. I had some trouble with converting the floats for the amount of potatoes in the players cargo and amount of money the player currently has to strings to be displayed on the screen. After some Googling I found that C++ includes a function that can convert a numeric variable to a string. This however made the resulting string have five decimals, which were all zeroes. Luckily C++ also included a function to resize strings. So after setting up some if statements to change the amount of characters depending on the value of the floats I thought I had it fixed but, no, I did not. I spent quite some time moving the if statements around to make them work correctly and finally they did. But now afterwards when I look at the GUI I am starting to question if it is obvious enough for the player what everything means. I guess I will have my answer during the play-test on monday.
|
