hallo...i want to make a game using C. The game called tik tak tok...it's can b made using 2d matrics, there will b 3 rows and 3 column...if player one choos the box of first rows of the first culumn...he have to put x...then the 2nd playr's turn will come....he\she have to put "o" in anyremaining boxes...finally when any one could make 3 x or o in row or in culumn... or croos way 3 x or o...he will b the winner...so how can i do this? any one can help me with code pleas?

>> any one can help me with code pleas

Yes, start here

int main()
{
    // put your code here

}

It is that in standard C, you can only print the results line by line (you can also overwrite the line, but not go back). Therefore using only standard C, the only option is to print the board every move, which sometimes can be even quite satisfactory option, because when you always print the board in the end of the console, it always appears in the same place, and even may cause some impression of moving. But in standard C, the terminal input is always line-buffered, so you must end every input, even a single character, with newline. For better interaction, the standard way is to use ANSI terminal escape sequences, and some POSIX input functions, but if you use windows, these are not supported, there is some way to do it in cygwin though. And if you want better than this, you should use some graphics interface, say, GTK, or even opengl if you really want 3d graphics. But someone could really try my nice GTK console http://www.daniweb.com/code/snippet737.html :)

GDI+ and MFC maybe?

GDI is bad because it's not cross-platform. MFC is a horribly badly designed and unreliable library, never ever use this. And better don't rely on windows api, because microsoft tends to change its api, in windows vista it's not any more the same as in the descendants of windows nt, and this change is most likely not the last. For a commercial software, the changes may often be driven by commercial interests, one of which can often be the additional income from selling the information and support for any new solutions, which no one except them don't know completely enough. There they may not care about the developers and users. Therefore Linux and everything which comes from it always used to be much more reliable, of course they make changes as well, but in spite of all that, they care much more, as you can today use in Linux some programs which were written maybe in 1970-s, exactly as they worked then.

MFC is a horribly badly designed and unreliable library, never ever use this.

Those are fighting-words Mr. :) But MFC is C++, not C so its not relevent to this board and this thread.

>>And better don't rely on windows api, because microsoft tends to change its api, in windows vista it's not any more the same as in the descendants of windows nt, and this change is most likely not the last


You obviously have no clue what you are talking about. Win32 api in Vista is the same as previous versions of MS-Windows -- only enhanced and some additions.

ok let me try another way

_o__|_x_|_x__
_x__|_o_|_x__
_x__|_x_|_o__
| |

This is the game i wanted to make

Those are fighting-words Mr. :)

No, these are the words of good advice, and only intended as such. I care about developers, and about the users, but i don't care about the companies. Please don't interpret it so that not caring about the companies is always fighting against them, this is the same as demanding a full compliance.

> You obviously have no clue what you are talking about. Win32 api in Vista is the same as previous versions of MS-Windows -- only enhanced and some additions.

I don't quite agree, but even *if* there are only some enhancements and additions, then they are quite substantial, and profoundly change the way the api is used. But "only some" is not a minutia in programming, as i still remember the "small changes" from windows 98 to 2000, like some small changes of default fonts and how the fonts were measured, this made my programs written for windows 98, look like a complete mess in windows 2000.

commented: Damn right, tell it like is! +11
commented: For caring. +6

i've lost the path..what you are guys talking about...are those reply have any relation with my probleme? pleas just tell me what to do..

@tahnan
First write some code which say displays the current board, as outlined in your previous posts.

No it is something, in which the people never agree, and it concerns every little thing. If you use Linux, you use something more conservative and academic, where changes are made only if really necessary for practical reasons, and therefore what you learn once, you can mostly use for your lifetime. But otherwise you inevitably enter into commercial mincing machine, from where, once in, there is no way out, other than being ruined completely, and in the process of course spent all your money and other resources which might be in your disposal. Therefore these who are consumed by this mincing machine, cannot advise others anything outside it. And this dispute can never end, because the companies keep the fire burning, as they never agree to abandon their different solutions, which is more than clearly against their interests.

ok let me try another way

_o__|_x_|_x__
_x__|_o_|_x__
_x__|_x_|_o__
| |

This is the game i wanted to make

I think everyone over the age of 5 years old knows what tick-tack-toe games are like. I think others here have given you hints how to write the program. No one is going to do your homework for you, so post code and ask questions about how to resolve specific problems.

Yes also some may say, that GTK is slow for things like graphics, but the reason why GTK is slow, is exactly because it can do many other things, all the menus and dialog boxes. GTK is a wrapper around xlib, which is very fast, and therefore all the GTK graphics functions are very similar to these of xlib, porting to xlib is not difficult at all, the difference is mostly only in function name, and even this is often similar. The same is true about QT. Therefore SDL is not necessarily better, and quite unnecessary additional learning, unless you perhaps are not going to ever do anything else, than making games. If you really want 3d, then you certainly need opengl, but perhaps except a few fields, the 3d is necessary only for 3d games, and again it only makes sense to learn that, if making 3d games is what you are going to do in the future.

Look...i've weekness in english...that's y u couldn't understand the hints. But as anciant dragon said...i'l do it exectly as his advice...i knew no one will do my home work for me...i've to do it myself...but anyof u really want to help...pleas clear me with your hints....like may sigest me where should i start...and using whice look i can do the job or it may b other game...which will help to to make my own game...that's will b healpful...but if u talking like u talking with someone else and giving me hint from that....it'll b hard for me to understand. thank you

Like I said

1. Write a function which draws the board.

2. Add code to place a 'X' or 'O' at any valid position on the board. Having placed a piece, use the drawBoard() function from step 1.
The computer for it's part plays "dumb" and just picks any vacant position at random.

3. Add code which checks the board for a winning line. If someone has won, then announce the winner.

4. Add things like instructions and repeated play.

5. Replace the computer random play with something which is a bit smarter.

6. Update the board display to use either a better console interface like curses, or go for a more graphical display based on MFC/GTK/whatever else is flavour of the month.

7. Add sounds.

8. Add head-to-head network play.

9. Add win/loss statistics.

10. Refine the computer AI play with difficulty levels so that players of varying skill can all have a challenging game.

It is an iterative process. Show that you can make some progress on step 1 then we can help you.

If you try to do the whole thing in one step, then you'll fail.

Here is the source code to a workable program.

Thus proving once again that if you nag long enough and play dumb then someone will eventually post a link just to keep the noise down :(

It really depends whether you really want to learn this stuff, in which case you'll make an attempt to solve it yourself, or whether you just want to get a "right-click-save-as" qualification.

Thank you salem for your sugtion and thanks to the person who gave me total game! for this time..i've servived, i've to submit this assignment next week..I'm learning C for one month! i think you treat me as a very beganer in C...I'm very afride to aske you that can you tell me from where i can start learning C with the help of this forum? coz i realized that what ever i've learned last one month...i've gain nothing but troble in my head...you guys are really helpful...so i've asked one last fevor in this thread that is just tell me from where i can start again learning C staying with you.

You keep talking, but I don't see any code.

You're certainly not going to learn how to code simply by looking at other peoples code and reading some books. You've got to get down to it and try some stuff for yourself.

I've outlined a progression. How far you want to go along that in the time available is entirely up to you. But since you have only a week then I'd say it's down to the computer making only random moves, and just the basic "drawBoard()" and "checkForWin()" functions on your part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.