Basic programs in Cocoa

KenMouse
Unregistered
 
Post: #1
Hi guys, I'd like to get back into programming, but I haven't programmed anything in almost a decade. The last language I used was QBasic.

Anyway, I've been playing around with the XCode Tools utility on my mac, but can't seem to make heads or tails of how you're supposed to make a program with it. I thought I would start out small, but I could use a little help.

Here are two simple game programs written in plain English. How would I build these in Cocoa?

1. Jumble - Computer scrambles words, you have to guess what it is
- retrieve random word from txt file
- break into letters
- scramble letters
- display scrambled letters
x get text input
- if input matches original word, then display "You Win!" and end else
- display "Wrong answer"
x loop x

2. Tic-tac-toe - A strange game. The only winning move is not to play.
- draw game board
x get user place "X"
- draw "X" in user place
- if win, then [user win] else
- calculate best move
- draw "O" in best move
- if win, then [computer win] else
- if no moves remaining, then [tie] else
x loop x

[user win]
- display "You Win!"
- end

[computer win]
- display "You Lose!"
- end

[tie]
- display "Tie Game"
- end
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #2
While they are very simply games they are still very advanced for a first project in xcode. As with any programming environment you want to start off very slowly. If you are having trouble getting a program to run then you want to start with the very basics.

Here is a link to a xcode intro that will walk you through setting up a button in a GUI and providing feedback when that button is pressed.

http://web.mac.com/elvis.dowson/Tutorial...vents.html

Once you get the basics down then you can start playing around with reading in a file, breaking it into chars, randomizing the order then displaying them on the screen. Once you get the how things work then you can start playing around with that stuff. When you get there pull up the documentation for NSString should be what you are looking for.
Quote this message in a reply
Moderator
Posts: 453
Joined: 2008.04
Post: #3
A temperature converter is a good place to start. It's got a simple GUI with a text field or two and a button. It's a good project to get you familiar with connecting actions to the cocoa buttons.
Quote this message in a reply
Post Reply