Currently, we've been told to create a project where we're supposed to create a game. I'm having trouble with knowing how to work my way with introducing the scoreboard mainly because our professors haven't taught us how to do so (we've only reached arrays as of now, and we're going to pass this project in a week, or maybe after two days!)
I've already asked help from other forums before I resorted to coming here. Basically the guys on the other forum have taught me much to understand things that I bet our professors would never teach us in this quarter; vectors, classes, structs, and a whole lot more, all I been forcing down to my own throat.
Someone constructed for me (with a whole lot of thanks because he explained every part of it so nicely) a class that typically functions as a scoreboard.
The main problem with the scoreboard is that it isn't persistent; and this is help that I need because I don't have a clue in manipulating ifstream and ofstream. I know it requires making an external .txt file. I know how to save the vectors to the file and load them up and display the .txt file, but what I don't know how to do is to make the items in the .txt file be stored to the vector.
I'm assuming fread, fseekg and fget has some contributions to making it persistent, but like I said, I have limited knowledge on how to work with ifstream and ofstream.
We're supposed to make a game, and our professor is requiring us to do things she hasn't taught us at all. Examples are a timer, where she hasn't even explained the ctime library, graphics, where she hasn't even told us which approach or what the approaches actually are (OpenGL, SDML, et cetera), and lastly, a scoreboard.
If someone is telling you to do things they haven't actually taught you, its expected you do research and ask other professionals for help. At least, this is usually the case in our institute. I've done research (and still doing), and now I'm asking for help.
If you thought that this was a simple homework of making a scoreboard with initial names and scores, then sorry for not thoroughly explaining the situation.
Our project is to create a game (we choose which - mine is some kind of bowman game). I'm finished with coding the game, and the only thing I really need now is a scoreboard.
The thing is, our scoreboard will have to take its inputs from the performance of a player. If he finishes the level, then his score will be added to the list, all sorted out.
In a sense, I want the player's score to be compared with scores that are in the .txt file, and save his score there if its high enough to be there and be sorted out. The thing I can't actually figure out is how I would do so, as in, compare the new score with the old scores in the .txt file.
I assumed that the process goes like this:
• add new score to vector, m_scoreboard
• open file for loading
• get nth name and nth score inside .txt file
• save them inside the vector, m_scoreboard
• close file
• sort the scoreboard, and remove entries greater than 10
• open file for saving
• write contents of vector to the .txt file
• close file
What I really fail is how to get the vector to store the contents of the txt file correctly. e.g. How can I "get" the name and score of an entry, and then store them to the vector, or simple just set them to a variable.