tictac toe marks

Started by
28 comments, last by phil67rpg 10 years, 11 months ago

well I have decided since I SUCK at c++ maybe I should try c# and do apps NOT games

Advertisement

Games are apps.

Three steps to heaven:

1) Make a plan

2) Write code

3) Debug code

I think you are doing too much (2) and not enough (1) and (3). Moving to a different language isn't going to be a magic bullet. Most apps are MUCH more complicated than tic-tac-toe.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

so I should plan things out very carefully more, should I use pseudocode or flowcharts or uml

With my latest game plans in the planning stage, I find myself adding onto the game design document slowly. While sitting here, I have notecards and a pen beside me where I can write a note on, then add it to a pile based on whether its a gameplay feature or a technical implementation detail. Obviously, the features pile grows faster, but it still helps me keep thoughts together. I just figured out that a linked list may be the best way to handle a specific data set in my game. Written down and added to the technical implementation pile.

If it's something that will take more than a week to program, it's worth spending at least a few weeks gathering ideas, writing them down, figuring out some implementation details, and researching what you don't know. Keeping notes is great.

well I have decided to do a simple little calculator application, where should I start, maybe with index cards a stated above.

so I should plan things out very carefully more, should I use pseudocode or flowcharts or uml

A combination of all 3, depending on how big your application is. It is best to visualise everything before you start coding. The amount of times I code something, have difficulty understanding it (drawing with your finger in the air only goes so far!) and then map out everything (coordinates, the next positions, grid squares, calculations) really helps me understand what is going on. Trust me, draw it out on a big sheet of A4!

Back to the original question, I really think you should have taken on repeated advice by now of eliminating magic numbers from you code. This:

if(x>=300 && x <=350 && y>=225 && y <=275)
{
font_rect.left=310;
font_rect.top=235;
font_rect.right=330;
font_rect.bottom=255;
board_x[0][0]=true;
}

if(x>=350 && x <=400 && y>=225 && y <=275)
{
font_rect.left=360;
font_rect.top=235;
font_rect.right=380;
font_rect.bottom=255;
board_x[0][1]=true;
}

I can only assume means that you are checking for a collision in a top-left quadrant, or top-right quadrant, and then setting font_rect at a new position. I also guess that board_x[][] = true means that you are setting that grid box to no longer accept shapes. I can only assume because it is impossible to tell with properly named variables to represent these coordinates. I am unable to help to the fullest extent if you are unable to provide enough information.

On a side-note, a calculator application might not be as simple as you might think depending on what you want it to do. Alas, it won't work without proper variables..

Stitchs.

Trust me, draw it out on a big sheet of A4!

How big do sheets of A4 get where you live? We can only get A4 in A4 size in my country... ;)

what is A4 paper

http://en.wikipedia.org/wiki/Paper_size#A_series

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Sorry, I don't see any of these attempts of an "easy way out" working. Looking at this code and the breakout code, no amount of switching language, UML drawings or doing apps instead of games will allow avoiding to take a huge step back and learn some basic and fundamental programming first. That means understanding and knowing how and when to apply them, not "research" as in "I skimmed over a tutorial and compiled the code".

The code is an insane mess of copy/paste, arrays are used, but then stuff is just copied and hard coded for every field in the array, showing a complete lack of understanding WHY an array is used in the first place.

Data that should be grouped in a class or struct is instead spread over a bunch of different arrays, functions are just doing all kinds of stuff.

There's endless if/else-copy/paste replacing a simple division.

Despite making the same mistake in the breakout thread, this function is again presenting an entire frame when it should just set a value (so I doubt that it was even understood what those magical D3D functions are actually doing).

There is also no recognizable understanding of the difference between game logic and graphics. Graphical representation isn't the game, it's what you put ON TOP of the game, so a player can see what he's doing. The "core" of the game doesn't care about graphics, sprites, 2D/3D, keyboards or mice. Inputs are used to trigger functions of the game and graphics are used to display the state of the game.

You can't buy a Spanish dictionary, learn how to pronounce two or three words and then try to write an entire novel. You need to learn the grammar and rules, have a decent vocabulary and know common phrases and idioms.

In this case: you need to learn programming. The language here isn't C++ (or C#, Basic or any other specific language), it's basic programming concepts. Not just knowing what a loop looks like, but how to use them. Forget about GUI and 3D (or even 2D). Running requires knowing how to walk first. Otherwise you're not getting far and keep hurting yourself.

Planning for TicTacToe or a calculator by using ULM and flow charts is overkill. Maybe a nice practice, but if you need a flow chart to understand the game logic behind TicTacToe (of which 95% should be covered by a standard game loop), you are clearly overcomplicating a very simple thing. Frankly, at this point it seems more like avoiding the real issue rather than tackling it. Like constantly "taking a break from programming" it won't magically make you write better code.

f@dzhttp://festini.device-zero.de

This topic is closed to new replies.

Advertisement