Mac Game Programming...coming from lots of languages

Discussion in 'Mac Programming' started by Allocin, Jun 17, 2009.

  1. macrumors newbie

    Joined:
    Jun 17, 2009
    #1
    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??
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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. 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).
     
  3. macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #3
    I recently listened a Mac Developer Network Podcast Episode that talked extensively about PyObjC. I have no experience with it, but from the interview, it sounds like a real pain to use.
     
  4. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Python and Pygame sound like what you want.
     
  5. macrumors 68030

    Winni

    Joined:
    Oct 15, 2008
    Location:
    Germany.
    #5
    pyglet could also be interesting for you.

    Or try a completely different beast: BlitzMax. (www.blitzmax.com)
     
  6. thread starter macrumors newbie

    Joined:
    Jun 17, 2009
    #6
    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?
     
  7. macrumors regular

    Joined:
    Jul 16, 2007
    #7
    For game programming I'd stick with C++ or Python with pyglet or pygame. Cross compatability will become important if you want a userbase.
     
  8. macrumors 6502

    Joined:
    Nov 30, 2005
    #8
    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.
     
  9. thread starter macrumors newbie

    Joined:
    Jun 17, 2009
    #9
    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];
    }
     
  10. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #10
    Doublecheck that Xcode didn't create a main() function for you in another file.
     
  11. thread starter macrumors newbie

    Joined:
    Jun 17, 2009
    #11
    It did, to go along with the prefix header. Should I delete that?
     
  12. macrumors regular

    Joined:
    May 27, 2009
    Location:
    Glasgow, Scotland
    #12
    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
     
  13. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #13
    Since you have two functions called main(), a linker error about duplicate symbols is to be expected. Delete one copy.
     
  14. thread starter macrumors newbie

    Joined:
    Jun 17, 2009
    #14
    Hey, alright! That worked! Thanks a lot.
     
  15. macrumors newbie

    Joined:
    Dec 8, 2008
    Location:
    Oregon, USA
    #15

Share This Page