There will likely be several posts in this conversation, back and forth.
Start with an empty class.
Examine this code for all of those things you have 10 of. They are the data members for your new class.
Create a constructor function. It likely must take several parameters, the name of the sprint graphic being one of them.
That's a start. As to the rest, it seems to me you're thinking in terms of one function. That makes it long and confusing. Once you have a class representing the button/sprite combination, you'll need to consider the overall operation of your program. This appears to run straight through a series of processes and then end. I doubt that is your actual plan. I can't tell from out here, but it is likely you need a plan where after all the initialization stuff completes (which should probably be an initialization function main calls), you'll need some kind of loop which lets the user continuously select options until they choose to exit (a button or some command I don't see represented here).
Now, I realize it is probably that your loop which starts at line 93 may well be that loop I speak of, but with such a long main function there's no sense of obvious design.
If I'm correct, this loop is typical of an animation loop, or any kind of design where the program repeatedly checks input/provides output until exit is commanded by the user.
For that to be clear it is good design, and quite customary, to create a loop that just does those few things, and can be understood in a short bit of code. In a typical animation loop we see things as simple as:
1 2 3 4 5 6 7 8 9
|
bool exit_requested = false;
while( windows.IsOpen() && !exit_requested )
{
exit_requested = runloop();
}
|
This makes it clear how the program is animated. If there are other signals to stop this loop, it can be from the return of runloop. This is only a hint, not a design for you to follow.
The runloop function itself shouldn't just be all the code inside the loop dumped there. You need to consider structure here, too.
It appears that you poll for input at the top of this loop. If the window is closed, this code lets the rest of the material execute. It is not likely to be of any purpose (and might crash) because the window is already closed. This step should probably "return true" if you follow the notion I presented.
It appears that you check the various buttons. When you have a button class, you'll still create the 10 buttons, but now they are likely going to be stored in some kind of a container, perhaps a std::vector.
I'll stop here because I don't see evidence yet that a std::vector is familiar to you, and that would stop everything. Perhaps an array (if you're working old school)? How would you choose to store the 10 button classes? Certainly NOT as a set of values b1, b2, b3, etc....that's what arrays and vectors are for.
If that is foreign to you, it's time to learn it before you can finish this.