if statement problem

Started by
17 comments, last by TheUnbeliever 12 years, 1 month ago
Try printing the values of board right before the if statement and let us know what the output is and if you can get the values to match what you expect.

Yo dawg, don't even trip.

Advertisement
Okay, than you need to track the board over multiple updates. Meaning right now you have [font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]int[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2][] board = [/font][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]new[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2] [/font][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]int[/font][/font][/font][font=Consolas][size=2][font=Consolas][size=2][9];[/font][/font]

declared locally to your method. You need to move this outside of your method, then it will draw once you have 3 in a row. Also make sure you change your &'s to &&'s.

Remember to mark someones post as helpful if you found it so.

Journal:

http://www.gamedev.net/blog/908-xxchesters-blog/

Portfolio:

http://www.BrandonMcCulligh.ca

Company:

www.gwnp.ca

well that worked thanks alot, so it was a scoping error,that is a subtle problem but I did learn something.
Don't take this wrong because I am in no way trying to be an ass but I think you need to do some reading on the core concepts of programming before trying to go any further. You are going to keep stumbling over things like this until you have the core basics down but reading even 1 programming book would set you a lot further ahead.


Either way, glad I could help and best of luck.

Remember to mark someones post as helpful if you found it so.

Journal:

http://www.gamedev.net/blog/908-xxchesters-blog/

Portfolio:

http://www.BrandonMcCulligh.ca

Company:

www.gwnp.ca

well I am taking a c# class online and I am reading a book on c#.this language is very new to me,thats why I have so many questions.
That is good if you are, and there is nothing wrong with asking questions. More times than not though we see people asking questions that have read 2 tutorials and think they are a programmer now. All I was trying to say is variable scoping is a basic fundamental programming concept and that you might want to step back and study a book a little more before attempting a game...especially a visual game. Personally (and this is where I did start many years ago), if you are still set on making a game, I would still make your tic tac toe, but make it console based. That way what you are learning and practicing is the core programming concepts, looping, variables, data types, logical operations etc without all of the nitty gritty graphics stuff. Besides the DirectDraw API built into the .NET language you will not use (someone will say they do but most) for game development so in essence you are wasting your time with it.

Either way best of luck, you are in for a great ride :)

Remember to mark someones post as helpful if you found it so.

Journal:

http://www.gamedev.net/blog/908-xxchesters-blog/

Portfolio:

http://www.BrandonMcCulligh.ca

Company:

www.gwnp.ca

thanks chester for all the help and advice.
I have one more question,where on the net do I find help on optimizing code.

I have one more question,where on the net do I find help on optimizing code.


You really don't want to make this your concern as a beginner. Just write code that seems elegant, or at least straightforward, to you and that will likely be performant enough. You would have to try quite hard to have performance difficulties with Tic Tac Toe! :-) Even once you do start to have problems, you don't just start blindly 'optimizing', you use a profiler to identify where your bottlenecks are and apply specific solutions to those.
[TheUnbeliever]

This topic is closed to new replies.

Advertisement