PDA

View Full Version : Mac Game Programming...coming from lots of languages




Allocin
Jun 17, 2009, 11:23 PM
Hi everyone. This is my first post here, and I'm sure this won't be my last, but I'm having a slight dilemma. No, don't worry, I don't have some error compiling something, but I have a much more debatable, probably more fun to answer dilemma: About a year ago, I got into programming out of...boredom, curiosity, impulse, whatever. I started with C++ and have an intermediate knowledge of that. I then moved to Python a while later and got up to a pretty solid level with that, being able to deal with OOP concepts quite well. Recently I've started to learn Objective-C and am reading a couple books on Mac OS X development.

My dilemma is...I've always wanted to get into game programming, but don't know how I can combine my basic understanding of C/C++, my knowledge of Python and my [hopefully future] familiarity with Objective-C into something useful. I've read about PyObjC, and eventually i think that would be ideal for me to program with. However, I have no idea how to go about programming a game in either Python or Objective-C from scratch. I assume I need some toolkits of sorts, and for macs I reckon those are hard to find. I just don't know what to do.

Any idea where I go from here??



kainjow
Jun 18, 2009, 12:05 AM
What kind of game? If you're going for a 3D game, you'll need to learn OpenGL or use an existing game engine, for example Unity (http://unity3d.com/). You can role your own though, but OpenGL is hard, especially if you're relatively new to programming. For basic 2D stuff you can do that with just the built-in controls and such (Core Animation makes it easy and fun).

GorillaPaws
Jun 18, 2009, 12:25 AM
I recently listened a Mac Developer Network Podcast Episode (http://www.mac-developer-network.com/shows/podcasts/mdnshow/mdn001/) that talked extensively about PyObjC. I have no experience with it, but from the interview, it sounds like a real pain to use.

Cromulent
Jun 18, 2009, 07:39 AM
Python and Pygame (http://www.pygame.org/news.html) sound like what you want.

Winni
Jun 18, 2009, 10:53 AM
pyglet could also be interesting for you.

Or try a completely different beast: BlitzMax. (www.blitzmax.com)

Allocin
Jun 18, 2009, 01:10 PM
Thanks guys I really appreciate the input.

I've heard of pygame, and I think that would be fine to start, but I was also wondering if game programming was possible in Objective-C. I think it has to be because of all of the games on the iPhone, etc. But I wouldn't know how to go about doing that.

Anyway...it doesn't look like I can be programming anything for a while now because my "gcc failed with exit code 1"...no matter how perfect my code is.

It think gcc is broken...how do I fix/re-install?

mongrol
Jun 18, 2009, 05:51 PM
For game programming I'd stick with C++ or Python with pyglet or pygame. Cross compatability will become important if you want a userbase.

Thomas Harte
Jun 18, 2009, 06:34 PM
Thanks guys I really appreciate the input.

I've heard of pygame, and I think that would be fine to start, but I was also wondering if game programming was possible in Objective-C. I think it has to be because of all of the games on the iPhone, etc. But I wouldn't know how to go about doing that.

Anyway...it doesn't look like I can be programming anything for a while now because my "gcc failed with exit code 1"...no matter how perfect my code is.

It think gcc is broken...how do I fix/re-install?
Before GCC fails it should print some details of the error that caused your code not to compile, or these will be available by clicking the red error symbol in Xcode if that's what you're using. Post those and one of us should be able to tell you what is wrong with your code.

It is, as you would expect, perfectly possible to write games in Objective-C. It'll make platform portability slightly more troubling, if that's a concern at all, but projects such as OOlite prove that you can write a game purely in Objective-C with the Mac as the only target and subsequently use publicly available tools to retarget for Windows and Linux without a major rewrite.

It's well worth starting with some sort of game framework like Unity, whether you're new to programming or not. The OpenGL library functions at a much lower level than you might assume, and it takes a reasonable amount of grunt work to get the basics down even if you know exactly what you're doing from the get go. Having a bunch of the generics already written is a major boon.

Allocin
Jun 18, 2009, 11:35 PM
Before GCC fails it should print some details of the error that caused your code not to compile, or these will be available by clicking the red error symbol in Xcode if that's what you're using. Post those and one of us should be able to tell you what is wrong with your code.

It is, as you would expect, perfectly possible to write games in Objective-C. It'll make platform portability slightly more troubling, if that's a concern at all, but projects such as OOlite prove that you can write a game purely in Objective-C with the Mac as the only target and subsequently use publicly available tools to retarget for Windows and Linux without a major rewrite.

It's well worth starting with some sort of game framework like Unity, whether you're new to programming or not. The OpenGL library functions at a much lower level than you might assume, and it takes a reasonable amount of grunt work to get the basics down even if you know exactly what you're doing from the get go. Having a bunch of the generics already written is a major boon.

Hey thanks a lot for the recommendations. Here's the error:

Building target “objc3try” of project “objc3try” with configuration “Debug” — (1 error)
cd "/Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk "-L/Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/Debug" "-F/Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/Debug" -filelist "/Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/objc3try.build/Debug/objc3try.build/Objects-normal/i386/objc3try.LinkFileList" -mmacosx-version-min=10.5 -framework Cocoa -o "/Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/Debug/objc3try.app/Contents/MacOS/objc3try"
ld: duplicate symbol _main in /Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/objc3try.build/Debug/objc3try.build/Objects-normal/i386/FracMath.o and /Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/objc3try.build/Debug/objc3try.build/Objects-normal/i386/main.o
collect2: ld returned 1 exit status
ld: duplicate symbol _main in /Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/objc3try.build/Debug/objc3try.build/Objects-normal/i386/FracMath.o and /Users/Nicola/Documents/Programming/C:Objective-C Programming/objc3try/build/objc3try.build/Debug/objc3try.build/Objects-normal/i386/main.o
collect2: ld returned 1 exit status
Build failed (1 error)

And here's my code...which compiles fine, just linking it produces the error. i don't think there's anything wrong with it, as no matter what I put in, I get the same error:

(this is just the .m):



#import "FracMath.h"


@implementation FracMath

-(void)showFrac
{
NSLog(@"The fraction is %i/%i\n", numerator, denominator);
}

-(void)showDec
{
NSLog(@"The decimal is %i\n", dec);
}

-(void)setNumerator:(int)num
{
numerator = num;
}

-(void)setDenominator:(int)den
{
denominator = den;
}

-(float)convertToDecimal
{
dec = (numerator/denominator);
return dec;
}

@end

int main (int argc, const char *argv[])
{
FracMath *frac1 = [[FracMath alloc] init];
FracMath *frac2 = [[FracMath alloc] init];

[frac1 setNumerator:3];
[frac1 setDenominator:4];

[frac1 showFrac];
[frac1 showDec];

[frac2 setNumerator:5];
[frac2 setDenominator:8];

[frac2 showFrac];
[frac2 showDec];
}

Catfish_Man
Jun 19, 2009, 02:10 AM
Doublecheck that Xcode didn't create a main() function for you in another file.

Allocin
Jun 19, 2009, 07:11 AM
Doublecheck that Xcode didn't create a main() function for you in another file.

It did, to go along with the prefix header. Should I delete that?

SRossi
Jun 19, 2009, 08:12 AM
What kind of application are you trying to set up because of the code you have posted I would use a Command Line - Foundation Tool to do that application.

This would allow you to create a main() in a .m file just like what you have set up.

Stephen

Catfish_Man
Jun 19, 2009, 11:25 AM
It did, to go along with the prefix header. Should I delete that?

Since you have two functions called main(), a linker error about duplicate symbols is to be expected. Delete one copy.

Allocin
Jun 19, 2009, 11:50 AM
Since you have two functions called main(), a linker error about duplicate symbols is to be expected. Delete one copy.

Hey, alright! That worked! Thanks a lot.

BravoBug
Jun 20, 2009, 06:55 AM
Any idea where I go from here??

Yes, iDevGames.

Forums: http://idevgames.com/forum
IRC: #idevgames

:)