PDA

View Full Version : Game Programming question



sirdude
February 2nd, 2008, 08:04 PM
Hi Troy,

I had a couple of programming questions and I figured I'd try and ask them on the website instead of sending you a private email like I have in the past. Other people may be looking for the same info so I thought it might be better this way. Then again this stuff may be too techy for people on these boards, if so I apologize in advance... and feel free to delete this post ;)

Anyway here is the basic thing. I've done quite a bit with SDL, most of the time I do development on a Linux machine. I've recently bought a mac, and I have a couple of newbie questions. First off how do you manage the resource files in code when your building an application for multiple platforms. I created a simple test file to explain what I mean.

http://www.cs.umn.edu/~mein/game/draw_title.c All it does is take a png and display it. But do you have different paths for the different platforms, in the code, or how do you deal with it?

I looked at DirkDashing and know how your dirs are setup on both platforms, I'm just wondering if you need to do something tricky in the code, or does OSX just automatically look in Contents/Resources by default like it was the current directory?

My second question will explain some of my confusion. If you could answer my questions and or point me to some documentation you think I should read that would be great.
I'm able to build a SDL project on OSX but I'm still using Makefiles and not sure how to turn things into an "app" I started playing with Xcode but I'm having a couple of issues, mostly to do with how do you take an existing c SDL project and configure Xcode to work with it.
Lets say I had the example file above and the image file it references data/images/title.png

How would you go about turning it into an Xcode project?
Would you start with an empty Project, or an Application->Carbon Application, or something else?

Then how do you add a target for your existing c file.
What do you need to do to create the app and tie in the png file?

Thanks,

Kent Mein

TroyHepfner
February 2nd, 2008, 08:40 PM
Hi Kent,

Here are some links that might help:

SDL and OpenGL on Mac OS X (this helped me get started with XCode):
http://www.meandmark.com/sdlopenglpart1.html

iDevGames (a great forum to search for answers and ask questions):
http://www.idevgames.com

As for the first part of your question, I have a C++ class that contains all the OS-specific code. One of the functions is called getApplicationDirectory, which returns the path to where the game can write files like high-scores, saved games, etc. This function returns a different directory depending on the player's operating system (OS). The directories are based on where Microsoft, Apple, or the Linux Standards Base says I should write the files. I then append the game name to the end of this path (e.g., "dirkdashing"), and this is where the game writes its data.

Hope that helps!

sirdude
February 5th, 2008, 04:54 AM
Yep that helps.

I was using the SDL packaged with fink which doesn't supply
the templates. Now I just need to get busy and finish getdefaultdir.

Thanks,

Kent