Tic Tac Toe almost done... Next up: Pong!

Member
Posts: 196
Joined: 2003.10
Post: #1
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 Smile
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #2
blobbo Wrote: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? Wink
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #3
Quote: 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! Smile
Quote this message in a reply
Moderator
Posts: 770
Joined: 2003.04
Post: #4
jabber Wrote: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? Wink

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. Smile
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2008.10
Post: #5
blobbo Wrote: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 Smile

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?
Quote this message in a reply
Member
Posts: 81
Joined: 2002.12
Post: #6
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.
Quote this message in a reply
Member
Posts: 196
Joined: 2003.10
Post: #7
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? Smile
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #8
I have THE pong code Rasp

It's based on some code Skyhawk gave me (that had one player Rasp). 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 Smile 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
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2008.10
Post: #9
blobbo Wrote:XxtraLarGe and applekid: i'd be happy to share code with you. learn as we learn, eh? Smile

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.
Quote this message in a reply
mnajera
Unregistered
 
Post: #10
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.

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.
Quote this message in a reply
Moderator
Posts: 438
Joined: 2003.08
Post: #11
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
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #12
You need to include the GLUT framework in your project. GLUT can be found at /System/Library/Frameworks/GLUT.framework.
Quote this message in a reply
Member
Posts: 196
Joined: 2003.10
Post: #13
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...
Quote this message in a reply
Moderator
Posts: 438
Joined: 2003.08
Post: #14
jabber Wrote: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
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2008.10
Post: #15
blobbo Wrote: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? Smile

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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Request] Pong Source &amp; One Question McSpider 6 7,179 Sep 18, 2011 07:21 AM
Last Post: fudog
  Pong AI trouble saxplayer13 15 7,523 Dec 16, 2005 10:40 AM
Last Post: jamil5454
  My first Cocoa Game that works! (Pong) blobbo 16 9,633 Aug 4, 2005 03:15 PM
Last Post: Andrew
  Pong "Physics" Nick 9 5,979 Sep 28, 2004 07:36 PM
Last Post: aarku
  Pong Questions: blobbo 8 4,028 Jan 21, 2004 08:16 PM
Last Post: blobbo