- Mar 31, 2011
- 392
- 0
- 71
I'm currently dusting off the cobwebs with my C++ and making a real concerted effort to learn how to make some small games. With my most recent breakthroughs I was able to create a small Tic Tac Toe game in C++ & SFML. It works, and does what I originally set out to do, but was looking for some feedback on it from you knowledgeable folks as I know there are probably some gross inefficiencies with my code.
I applied things I have learned from various paths of learning, but there are also a number of cases where I basically tried something out to see if it worked, or tried to work out how to make something happen by rifling through documentation.
The code itself can be found here. Feel free to paste whatever elements you wish to comment on back on this topic. And here are some examples of it in action:
Pic1
Pic2
Pic3
The main questions I had really were:
I applied things I have learned from various paths of learning, but there are also a number of cases where I basically tried something out to see if it worked, or tried to work out how to make something happen by rifling through documentation.
The code itself can be found here. Feel free to paste whatever elements you wish to comment on back on this topic. And here are some examples of it in action:
Pic1
Pic2
Pic3
The main questions I had really were:
- I didn't use any dynamic memory allocation (blah = new blah) in my entire code, though I see that it is popular to do from looking at other code samples. What is the benefit of this, and where should I have used it here?
- I was originally considering using a class (or classes) for the player pieces but went with functions instead. Should I have gone the class route?
- The overall logic that I used works (if the mouse click is within this area, mark that sector as claimed by whatever player's go it is), but I couldn't help but feel I was taking a cumbersome path somehow. Would you have done this differently, and if so, how?
- The logic to check the game state I also felt was cumbersome (the really... really extensive if/else statements). Could that have been cleaned up in any way?