So we are moving to GUI. Microsoft Visual C++ 2010 Express, just like every other software from Microsoft, is having an a-bit-clumsy interface. At first it took me some time to even locate the toolbox and the items I need. The “button” items in the menu only show up when “window form application” is chosen as the document type. It is also a requirement to enable the drag-and-drop IDE. But this is not mentioned in any tutorial I have gone through. Before knowing that, I started up with a normal window application, leaving the window form application as a second step to test out. But I gave up exploring the normal window application quickly after 15 minutes I discovered no matter how hard I dig into the user preferences to find the buttons, the toolbox still remains empty!
I started feeling optimistic because I felt like conquering the most ridicules issue I would be facing, and the WYSIWYG editing interface is soooo easy to get along with. Programming a simple tic-tac-toe should not be that difficult. I still remember the day I was learning Netbeans IDE for Java. That was totally a flash through my mind. Programming the buttons is just like programming anywhere else but a lot simpler… Well that was Java. In window form, the language, even though still C++ as it said, does not look like the C++ we used since the beginning of this quarter. Not apparent COUT and CIN is observed, neither do “<<” and “>>”. The “->” symbol and everything else look just like alien language. C++ is much bigger than I thought.
Surviving form this kind of uncertainty did not take me that long. The main challenge is actually parsing values in between the classes and functions. The window form is a template or framework pre-written with classes and stitched together. It is the same as Objective-C and iOS programming I am recently investigating. But in this stranger language, even declaration and assigning a variable become nightmare. All kinds of scary errors showed up! Wrong place to place the declaration, wrong place to assign the value, wrong type to pass, wrong syntax, not allowed type… So discouraging!
After many tests, failure, tutorial has gone through, most problems are solved. I can now assign the text in a textbox with int data with a convertToString function (finally!). The variables need to be declared here (above image) in order to make them usable by the form, function and event handlers. This is quite common. However, an array cannot be declared here. It said “only static data members can be initialized inside a ref class or value type”. This means it is not supported. What?? This might be common sense to programmer, but it seems non-sense to me, and I had searched for half an hour on how to declare and array, which used to be like this: char myChar; It allows me to declare it in the main of the form. But if I need to call it in a function, it is undeclared.
This is how it looks like at the stage I am about to implement the game logic with an array. Of course I can make a tic tac toe without using any array, but repetitive work is not my favor.
I started to think (because searching for solution seems like endless!). I need to make good use of tools in my hand to make a playable game with GUI. This should be the task, instead of trying to solve pointless issue I am facing in pure programming. I changed my game to Tamagochi — another flash in my mind.