PDA

View Full Version : iPong (Blobbo) vs. xPong (XLG)


XxtraLarGe
2004.01.26, 02:36 AM
I have created my own version of Pong, called "xPong" ;) You can download it here: xPong (http://www.msu.edu/~brinkma1/xPong.app.sitx). It is only 20k & the source code MacPong.sitx (http://www.msu.edu/~brinkma1/MacPong.sitx) is only 10k.

Please download it, play it, and check out the code. I'm sure there's a ton of memory leaks, I'd appreciate anybody telling me what's wrong (leave feedback in this thread). It's only at version 0.1, I still plan on adding difficulty levels, sounds & a drop-down sheet ala MacTacToe (http://www.msu.edu/~brinkma1/MacTacToe.app.sitx).

When I wake up in the morning, I'll take a look @ Blob's code, and see what he did different than mine. I'm sure there will be lots of things for both of us to learn. F'rinstance, my version is only one class - the NSView subclass. I'm sure Blob made his nice and object oriented, whereas mine's a hack.

I must admit, I did get some of the code from Mike Beam's "Intro to Cocoa Animation," at MacDevCenter, and Blob's own thread about his version were also helpful. I didn't know how to get the up & down arrow keys.

I don't know what my next project will be, but I'm sure that it won't be the same as Blob's, LOL! I think I need to tidy up my code in my first two games first before I move on though.

blobbo
2004.01.26, 05:28 PM
hey cool. i'll take a look at the code in a bit. yup, mine is MVC.

next up is cribbage for me. i'm doing it for the mini-contest...

XxtraLarGe
2004.01.26, 06:25 PM
hey cool. i'll take a look at the code in a bit. yup, mine is MVC.

next up is cribbage for me. i'm doing it for the mini-contest...

I was thinking about doing Othello, but I'm really not that talented to get it done in the amount of time they're giving. Best of luck to you!

blobbo
2004.01.27, 12:13 AM
well i've been thinking about it a lot. i mean, once you visualise how it'll work, and think up an ai solution, i think the coding gets much easier. i've got an idea of how the card deck is going to work, how the code i can reuse will work, etc... it's just a matter of freeing up time to work on it. in the past 3 days i've played 36 hours of violin, and i ache all over. i just want to go to bed. speaking of which... ciao!

menace690
2004.01.27, 01:07 AM
well i've been thinking about it a lot. i mean, once you visualise how it'll work, and think up an ai solution, i think the coding gets much easier. i've got an idea of how the card deck is going to work, how the code i can reuse will work, etc... it's just a matter of freeing up time to work on it. in the past 3 days i've played 36 hours of violin, and i ache all over. i just want to go to bed. speaking of which... ciao!

A card game's Deck class is easy.

It is an array of the 52 cards deck_array. Better would be array of 52 of a card object, but both will work.
1 int called placeholder = 0;
Two functions, shuffle and deal_a_card. Shuffle takes two random numbers between 0 and 51 and switches there positions and resets placeholder = 0. Have this switching happen thousands of time and you have your shuffling. deal_a_card returns the card at deck_array[placeholder]. (If you implement Card object it makes the code in game easier) or return the number at that position of the array (instead of the Card type) and have your main game figure out how to process it.

I have this deck/card/hand written in C++. It is not 100% polished, but I could email it to you if you want. Let me know.

blobbo
2004.01.27, 10:13 AM
thanks for the offer - i want to try from scratch first. that's basically what i was going to do, though :)