PDA

View Full Version : Tic Tac Toe almost done... Next up: Pong!


blobbo
2004.01.08, 10:21 PM
So I'm learning cocoa and objC, right?

And I'm new at this, too. I've done a compsci course that tought java up to data structures. I'm now doing (wait for the wonderful course title) "Data Structures and Complex Algorithms in Java." So I have a fair idea of what I'm doing, object-oriented-wise.

That said, I'm still a newb. I've only been programming seriously for about 3months now, and I still make silly mistakes...

So what better way to get better than to practise, practise practise! So I wrote tic tac toe in command line c (i.e. c that printed out the results in the term). And now I've used cocoa and obj-C to make a version that works with a gui. And it kind of works. It's getting there.

The point of all this being that, I'm almost done Tic Tac Toe. This raises two questions:

1) Would someone be willing to take a look at the code of my project (PB) and tell me some things that I'm doing right/wrong? That would be very helpful.

2) Could someone point me in the direction of some source code for pong? I figured it would be a good next step... If not pong, then source code to a similarily simple game that would provide me experience with programming?

Thanks in advance. Love this site. Just discovered it, and the community is really nice :)

Josh
2004.01.08, 11:46 PM
2) Could someone point me in the direction of some source code for pong? I figured it would be a good next step... If not pong, then source code to a similarily simple game that would provide me experience with programming?The news item on our front page links to a Cocoa tetris clone. I haven't looked at the source, but how complicated can tetris be? ;)

Fenris
2004.01.09, 07:09 AM
1) Would someone be willing to take a look at the code of my project (PB) and tell me some things that I'm doing right/wrong? That would be very helpful.

Sure, just send it over. I'm at ivan (at) rusted (dot) se
Glad you like the site, welcome! :)

PowerMacX
2004.01.09, 12:10 PM
The news item on our front page links to a Cocoa tetris clone. I haven't looked at the source, but how complicated can tetris be? ;)

It has network play so... :wacko:
OK, is not really THAT complicated, but if your previos game was tic-tac-toe I wouldn't recommend it. :)

XxtraLarGe
2004.01.09, 12:41 PM
So I'm learning cocoa and objC, right?

And I'm new at this, too. I've done a compsci course that tought java up to data structures. I'm now doing (wait for the wonderful course title) "Data Structures and Complex Algorithms in Java." So I have a fair idea of what I'm doing, object-oriented-wise.

That said, I'm still a newb. I've only been programming seriously for about 3months now, and I still make silly mistakes...

So what better way to get better than to practise, practise practise! So I wrote tic tac toe in command line c (i.e. c that printed out the results in the term). And now I've used cocoa and obj-C to make a version that works with a gui. And it kind of works. It's getting there.

The point of all this being that, I'm almost done Tic Tac Toe. This raises two questions:

1) Would someone be willing to take a look at the code of my project (PB) and tell me some things that I'm doing right/wrong? That would be very helpful.

2) Could someone point me in the direction of some source code for pong? I figured it would be a good next step... If not pong, then source code to a similarily simple game that would provide me experience with programming?

Thanks in advance. Love this site. Just discovered it, and the community is really nice :)

Great. This is actually quite ironic. I'm doing the exact same thing. I have MY tic tac toe game open right now. I should be done in a couple of hours. And I was going to do a pong clone next. How is it that this could happen?

applekid
2004.01.09, 04:11 PM
Wow. You're my new inspiration. I'm at about a similar level to you are as far as Java goes. I'm in the process of switching over to Obj. C and Cocoa for non-school work, so hopefully things will go well.

blobbo
2004.01.09, 05:19 PM
wow. ok, so i'm not alone.

tetris is complicated, because the gameplay is complicated. not to mention it does realtime drawing stuff. i thought pong would be a good introduction to that. plus it lets me do another example of ai - my tic tac toe ai is ok, i guess. but i think it's innefficient.

so i've slowed down a bit here. tic tac toe now works with the ai being random. but i'm duplicating code where i shouldn't...

as soon as i implement the ai i wrote, i'll shoot it off to those who offered to look at it. thanks again!

XxtraLarGe and applekid: i'd be happy to share code with you. learn as we learn, eh? :)

Joseph Duchesne
2004.01.09, 08:08 PM
I have THE pong code :p

It's based on some code Skyhawk gave me (that had one player :P). I made it what it is today in 6 days. It usus CocoaBlitz (a free Cocoa+OpenGL+Quicktime 2D sprite library). It has lots of features and more than 20 options, although not all of them work.
http://jdz.staronesw.com/Downloads/CBpongSource.sit <- the source
http://jdz.staronesw.com/Downloads/CBPongv.8.5.app.sit <- the compiled game

The code is under the iDG liscence... I guess :) although you can use it for whatever with no credit to me (skyhawk might want some).

Keep in mind that this is the ABSOLUTE LEAST iffecient code on earth. Of course that makes it more understandable, but... OSC and Skyhawk might kill me for posting it :lol:

XxtraLarGe
2004.01.10, 12:06 AM
XxtraLarGe and applekid: i'd be happy to share code with you. learn as we learn, eh? :)

That's cool with me, but I'm going to try completing my own first before I look at anybody else's. I've come up with the logic for mine completely on my own. I looked at the Java Tic Tac Toe example and got confused by the bitwise operations, and was having a difficult time following what was going on.

Mine will probably end up being used as the example of how not to make a game, but as long as I learn a few things, it's alright with me.

mnajera
2004.01.12, 09:52 PM
If anyone wants help building a simple tetris game on the mac, you can take a look at my quick (and somewhat well-documented) program gluttris (http://banarnar.com/gluttris).

The whole project took only a few days, and I explain a little bit about how I got started (with mac-specific concerns) on the webpage.

Feel free to email me if you have any questions. I personally feel that every game programmer should know how to do tetris, as it gives you a taste of just about every aspect of game development.

EvolPenguin
2004.01.12, 10:24 PM
I tried compiling your code and I got an error. "ZeroLink: unknown symbol '_glutBitmap8By13' " what's that mean. Also, I can find it in the code, so, what should I do?

never mind

Alex

Josh
2004.01.13, 12:53 AM
You need to include the GLUT framework in your project. GLUT can be found at /System/Library/Frameworks/GLUT.framework.

blobbo
2004.01.13, 03:53 PM
see what i was wondering is if anyone had code for a cocoa pong game that used a custom view as a drawing space?

i mean, that's minor. the underlying code is what's important...

EvolPenguin
2004.01.13, 09:20 PM
You need to include the GLUT framework in your project. GLUT can be found at /System/Library/Frameworks/GLUT.framework.

I know, that's why i added the never mind part later. Just a second there my mind when blank and i got confused, but then, unfortunately after i posted, i realized, "doh!!". But thanks anyway

XxtraLarGe
2004.01.15, 10:43 PM
so i've slowed down a bit here. tic tac toe now works with the ai being random. but i'm duplicating code where i shouldn't...

as soon as i implement the ai i wrote, i'll shoot it off to those who offered to look at it. thanks again!

XxtraLarGe and applekid: i'd be happy to share code with you. learn as we learn, eh? :)

Have you finished your game yet? I still have to do the A.I. too. Right now, it's just drawing the "O's" in a pre-defined pattern, and the game knows if you've won or not. All together, it's about 300 lines of code, including comments, white space & closing brackets, so maybe 120 in reality :-)

I am going to have it drop down a sheet to let you know if you've won. Which shouldn't happen if I get the A.I. down right. I should have it finished by the end of the weekend, I'll post it, along with code on my web space.

blobbo
2004.01.16, 09:33 PM
cool. actually, truth be known, i got bored and busy. i moved on to pong. pong is a bit more interesting so far, i find. it also lends itself to object-oriented design much better, imho.

anyway, i'd be very interested in your code.