PDA

View Full Version : Starting from scratch? (PHP Background)


Cronikeys
2005.08.04, 06:43 PM
Hey, this is my first post at iDevGames and I am a complete n00b to Mac (and PC) programming. I have a HUGE background in PHP, but I just got a powerbook and I really want to get into game development. I realize that most everyone here knows something about programming, but I know absolutely zero (I have fumbled through some obj-c tutorials). I am using Xcode newest version and would really appreciate a nice starting point for understanding all this.

I guess what I am asking for is maybe an in-depth guide to getting started. I saw a "flip tile" tutorial or something, but that really isn't the kind of game that I would want to make. Are there any basic tutorials that just show you how to make an image move when you push the keyboard buttons?

Any advice? How did you get started in game development, or programming in general?

(If it means anything, I have used GameMaker for Windows before)

unknown
2005.08.04, 07:02 PM
http://www.geocities.com/ed72678954/GridGridGridGridBuild.tgz
http://www.geocities.com/ed72678954/GridGridGridGridSource.tgz

This is a more complicated example than what you are looking for probably but its still very simple. It can be used as reference on how to do events (Mouse and Keyboard), Graphics (Image drawing, Tile splitting) and it also implements scripting but thats easy to ignore if you feel like it.
If you know how to make an NSView and subclass it (You could learn that from fliptile I think). Then looking at the code for this should be enough for you to make a simple moving image game.

(Oh yeah, change that main.lua file to load different scripts to see what the program does first of all)

socksy
2005.08.04, 07:48 PM
Hi and welcome to idevgames! First off - don't say n00b as it doesn't actually mean newbie, but actually quite annoying and not very pleasant person; that is, to name two of the usual properties.

The first thing I would recommend to someone new like you would be PlayKode (http://www.idevgames.com/forum/showthread.php?t=9397). Even though it is in beta, it's more than capable of being able to those things stated and teaches the basics of programming well, using an extended version of lua (http://www.lua.org/). It's also very fun ;)

Although, you say you know PHP - you may be slightly advanced for it :) The mainly used language for mac games and applications is Objective - C. This implements the Cocoa API which is the norm for most new apps (and mostly the norm for games) in this day in age. The other API is Carbon, which uses C++ generally for it's main language. Both APIs use a form of C, which can most easily be learned from this (http://www.cocoadevcentral.com/articles/000081.php) article. It is from Cocoa Dev Central (http://www.cocoadevcentral.com/), a good resource for the Cocoa API. The particular article linked is specifically one for programmers of PHP to learn C. From then on you can learn Objective - C, OpenGL and GLUT, and SDL (http://www.libsdl.org/).

Like PlayKode, there is also some other scripting languages. Many types of BASIC such as TNT Basic (http://www.tntbasic.com/), Future Basic (http://www.stazsoftware.com/futurebasic/index.php), METAL (BASIC metacompiler) (http://www.iit.edu/~sarimar/GDS/metal.html), and REALbasic (http://www.realsoftware.com/) to name a few. Another scripting languages that is popular include Blitzmax (http://www.blitzmax.com/). These are all beginner languages (although people who are very experienced can produce amazing products from them, just check out the gallery (http://www.blitzmax.com/Community/topics.php?forum=61) for Blitzmax!). I'm sure someone will jump up and say something about Ruby (http://www.ruby-lang.org/) and RBuild (http://onesadcookie.com/svn/repos/RBuild/), but I'll leave that to someone who has more knowledge. Used and made by Guru OneSadCookie (aka Keith) not a beginner language, but beginners can probably use it all the same.

If you chose not to go down the compiled languages route, or the scripting language route, then there is also the Game Engine way. Often in 3D, the game engines do the boring bits for you, with content creation up to you. From order of cheapest to err... not cheapest:
•Dim3 (http://www.klinksoftware.com/) is a free game engine that is made by Brian Barnes. Even though the demo is a shooter, it is possible to make nearly anything, as long as you're good enough ;) It is open source so you're not restricted. Good for people with low budgets ;) The forum itself is on idevgames, here (http://www.idevgames.com/forum/forumdisplay.php?f=49).
•Torque (http://www.garagegames.com/) is an engine that you may have heard of before. The tools aren't too well supported on the mac and apparently you need to compile to get it running. Recently released is a much more friendly(apparently) Torque 2D. I believe Chris (crackbunny) is using it, so you should get better answers from him. Torque is around the cost of $100 USD
•Unity (http://www.otee.dk/) is a very promising looking engine that incorporates the very nice Novodex (http://www.ageia.com/novodex.html) Physics engine. It is very flexible and is as easy to use as making a model and dropping it in to Unity editor. Very little code is needed to master and results are usually great :D It's cost varies as there is an Indie and Pro version, but currently it's going at $250 USD with an early adopters cheap version. Get it whilst it lasts!
I did not include igame3d to this list, as a)you can't get it, and b)I've never used it. It's currently being debugged by igame3d ( the forum member).


All in all, I wish you luck with your time here, and hope you enjoy it. :)

Note to self: Stop using so many smilies!
Edit: It seems that about two or three lines disappeared when I posted this, so I'm off to type them again...

Dan Potter
2005.08.04, 08:20 PM
I did not include igame3d to this list, as a)you can't get it, and b)I've never used it.

Also it gives angsty, Lewis Black-esque commentary on your game while you use it. I kid, I kid! ;)

Honestly if you are able to push your way through any of the Obj-C tutorials, it might be a good place to start off on the right foot to do the Cocoa GL tutorial in the Xcode docs. I'm speaking of the one where it shows you how to receive mouse and timer events, and draw a triangle to the window based on it. It's a good start. Of course once you start getting into things like loading textures/images, playing an audio track, etc, it gets much simpler to go with some pre-made toolkit like SDL (or Tiki if I ever get around to releasing it).

Leisure Suit Lurie
2005.08.05, 12:21 AM
Many types of BASIC such as TNT Basic (http://www.tntbasic.com/), Future Basic (http://www.stazsoftware.com/futurebasic/index.php), METAL (BASIC metacompiler) (http://www.iit.edu/~sarimar/GDS/metal.html), and REALbasic (http://www.realsoftware.com/) to name a few. Other scripting languages that are pop These are all beginner languages (although people

Yes...?

Although people... ?

Anywho, lets not forget BlitzMax (http://www.blitzmax.com)

aarku
2005.08.05, 01:45 AM
From what I've seen, PHP has C-ish syntax, so you might want to start with SDL or GLUT and C.

SDL - http://www.libsdl.org/index.php
GLUT should come with the developer tools.

Good luck and welcome.
-Jon

Leisure Suit Lurie
2005.08.05, 09:10 AM
@Socksy BlitzMax isn't a scripting language. It compiles to a standalone app.

imikedaman
2005.08.05, 10:34 AM
From what I've seen, PHP has C-ish syntax, so you might want to start with SDL or GLUT and C.
C is prodecural, so I wouldn't recommend it for games - use the object-oriented C++. I tried making a game using C once, and it was a bad idea. I quickly scrapped the idea and used C++, although technically C structs come in handy quite a bit.

socksy
2005.08.05, 10:51 AM
@Socksy BlitzMax isn't a scripting language. It compiles to a standalone app.

Really? My bad. I don't like it too much...

Also, technically PlayKode has a build to standalone app option, yet it's still a scripting language.

How does Blitzmax work then if it doesn't use assembly? Is it really compiling it or is it linking to a compiled language modified with APIs and such?

C is good for simple games, and from there you should learn another language. C++ is known for not actually being an extension to C, whilst Objective - C is.

ThemsAllTook
2005.08.05, 11:30 AM
The other API is Carbon, which uses C++ generally for it's main language.

Carbon is a C API. No C++ involved.

C is prodecural, so I wouldn't recommend it for games - use the object-oriented C++. I tried making a game using C once, and it was a bad idea. I quickly scrapped the idea and used C++, although technically C structs come in handy quite a bit.

C is perfectly usable for games. I've written several fully-fledged games entirely in C, and I never saw any need for C++. All you have to do is establish a few disciplines to follow, and you can write pseudo-object-oriented C code in a very clean and efficient manner. If C++ is more your thing, go for it, but there's nothing it can do that C can't.

- Alex Diener

Leisure Suit Lurie
2005.08.05, 01:30 PM
@Socksy My idea of a scripting language is something that dumps a bunch of text files in a folder with some separate runtime that's required to execute it.

Blitz compiles all your code to machine language...somewhere under the hood it uses gcc...

akb825
2005.08.05, 02:16 PM
C++ would really shine for more complex games where you have objects or characters or events that have similar actions. It also would help for more complex graphics engines. (such as having everything be derived from a "Drawable" class and have each have specific virtual drawing functions so you can put them in a container) For simple games, though, C should be fine.

Dan Potter
2005.08.05, 07:06 PM
C++ would really shine for more complex games where you have objects or characters or events that have similar actions. It also would help for more complex graphics engines. (such as having everything be derived from a "Drawable" class and have each have specific virtual drawing functions so you can put them in a container) For simple games, though, C should be fine.

That's exactly what Tiki is. :) It's got a Drawable class you can subclass, Animation classes, Trigger classes, and now Timeline and Timepoints. You can link all those together to form whole animation sequences and use them in an ongoing manner to make games. There are also utility classes for Texture, Sound, Stream, and an OggVorbis stream subclass.

I just need to get around to open sourcing it ^_^;; :blush:

AnotherJake
2005.08.07, 06:12 PM
For simple games, though, C should be fine.
Ack! Stop! That's the second or third time in this thread I've seen that comment. Just as a reminder, id used C for all of their engines up until just recently with Doom III. If C is good enough for John Carmack to get all the way to Quake3, it's good enough for... well, any game you can imagine. Then there's always the next whining complaint, "but I don't know how to program C in an object oriented fashion". Hint: Probably the biggest concept that gets missed by many inexperienced C programmers is the technique of encapsulating function pointers in their structs. Whammo! You have an object. It's magic! Do a google on object oriented C if you need more ideas. [end rant]

To back up what aarku and Lurie mentioned, SDL or GLUT would be a fine place to start from scratch if you already know C.

Leisure Suit Lurie
2005.08.07, 06:34 PM
To back up what aarku and Lurie mentioned, SDL or GLUT would be a fine place to start from scratch if you already know C.

I omitted GLUT because you need to know OpenGL before Glut. Also it doesn't handle sound or joysticks. To further confuse you, in lieu of GLUT, check out GLFW. (http://glfw.sourceforge.net/)

SDL and PTK handle all that poop.

Depends how simply you want to start, I guess.

Dan Potter
2005.08.08, 12:25 AM
If C is good enough for John Carmack to get all the way to Quake3, it's good enough for... well, any game you can imagine.

I think that's beside the point :)

Both C and C++ are turing-complete languages, as are pretty much any other modern programming language. You could write object oriented assembly for that matter. But why subject yourself to the extra pain of doing it by hand when the compiler is there to do it for you? I think that's what they meant.

After all, C++ just started out as a C preprocessor that adds a hidden "this" argument to method calls, and function pointers for virtuals.

AnotherJake
2005.08.08, 02:11 AM
I think that's beside the point
???

The argument I attacked is that "C isn't as good as C++ for games" and I offered a pretty logical counter.

But why subject yourself to the extra pain of doing it by hand when the compiler is there to do it for you?
How is using C++ not "doing it by hand"? :rolleyes:

Leisure Suit Lurie
2005.08.08, 02:57 AM
(waits for thread to get ugly)

Dan Potter
2005.08.08, 03:08 AM
(waits for thread to get ugly)

Hah! I really couldn't care less about the subject. Perhaps it'd be better to pretend I didn't comment.

It's just that there are two common rants between "C people" and "C++ people". The one AnotherJake already covered ("C can't do stuff C++ can!!") with a good rebuttal. The other, "there's no good reason to use C++ for games because Mr. X-and-Foo didn't" is what I was covering. The C++ compiler inserts "this" pointers and handles the function pointers for you, so you might as well use it. That's why it's less manual. Whether that's a good thing or not is a whole other debate... :) Arguably it's more intuitive though to do:

robot->move(2, 10);

than:

robot->move(robot, 2, 10);

Anyway, ignore me.. back to your regularly scheduled new game code help. :)

AnotherJake
2005.08.08, 03:49 AM
Ignore me too. No ugly thread needed.

Arguably it's more intuitive though to do:

robot->move(2, 10);

than:

robot->move(robot, 2, 10);
"Arguably" being the operative term here. It does suck that "this" has to be passed to the object for it to have a sense of "self" with C. I guess I'm just saying that it can be done to good effect with C regardless. You nailed the central theme though. Things get twitchy right there. Built-in flexibility with C vs. built-in functionality with C++? For those who don't know, please don't pee on C for it's *apparent* lack of functionality.

OneSadCookie
2005.08.08, 05:11 AM
I'd rather stick to good ol' dependable C than get stuck in a quagmire of multiple virtual protected inheritance with templates, operator overloading and copy constructors in C++ ;)

Dan Potter
2005.08.08, 01:25 PM
I'd rather stick to good ol' dependable C than get stuck in a quagmire of multiple virtual protected inheritance with templates, operator overloading and copy constructors in C++ ;)

Heheh... C++ certainly does give you plenty of rope to hang yourself. Then again the existence of raw pointers in both kinda does that. :)

akb825
2005.08.08, 01:56 PM
I love C and have done Object Oriented in it. However, I still think C++ is better suited for large game engines. Besides, it would take a much more experienced programmer to do such a thing in C rather than C++.

For my upcoming game engine, I have no doubt that I could write it in C. However, with C++, it will have a much smaller source, be easier to debug, and be easier to add other objects, since I'd like the classes to not only hold the models, but also the AI etc. Sure, it is possible in C, but it's more efficient and less prone to mistake in C++.

aarku
2005.08.08, 03:17 PM
Why is it so hard to read the question asked in this thread, form an answer, post it, and avoid squabbling over what flavor of ice cream we all like best?

The guy has a strong PHP background, and has used GameMaker before. That should be the greatest influence to a response, I think.

-Jon

atek3000
2005.10.22, 10:32 PM
OK...here's one for you guys.

I'm a Civil Engineering student. I doodle/draw/paint in my spare time...as well as play video games. I did a very rudimentary C++ course during one of my first engineering semesters and loved it. I want to try and find a gaming industry job when I finish my degree in the next 2.5 years so I'm taking courses in art to improve my "skittles" and am looking to learn about game programming.

So...

Very little coding experience...alot of enthusiasm...own a Powerbook. Where do you guys think I should start?

I've been looking online and around this forum for the past few days and I'm coming across terms like "API", "game engine", "OpenGL"...and others. I know what these things are, but nothing about how they come together to make a game.

Any directions people could point me?

Byron Clarke
2005.10.23, 01:22 AM
I'd suggest you start small.

There's no real easy way to get into it, at least none that I know of. If you enjoy engineering than my guess is that you will be able to pick things up fairly quickly. Programming is kind of like virtual engineering. If you're serious about game development, I'd suggest picking up a few books... OpenGL for 3D, any of the C flavours (c, obj-c, c++)... mind you I am in no way an expert on the subject

emilmont
2005.10.23, 07:53 AM
If you want to see a simple example of "Object Oriented C" you can take a look at: http://www.emilmont.net/?q=node/3

By the way, to start a new game without a well organized team of developers, I suggest to develop in Java and not in C :)

unknown
2005.10.23, 09:11 AM
And most importantly get something finished and presentable as often as you can, otherwise you will just learn how to program but not what you can do. Which is a lot more satisfying.

atek3000
2005.10.25, 12:10 PM
Wow...thanks for actually responding guys. :)

I knew learning a programming language would be the obvious place to start, and it seems there is C, C++, ObjC, and Java to pick from. So, I guess my next question is, "Of these, which would be the most beneficial for me to know?".

With school, art, and life...I don't have all the time in the world to devote to learning to program, so I'd like to start out by learning something that will allow me to create a tangible game in the next 2 or 3 years. ..which will be understandably rudimentary...but a game nonetheless.

I don't want to start any wars between purists...hahaha...just wondering which one would be the easiest to learn and let me do cool stuff.

Thanks.

AnotherJake
2005.10.25, 01:18 PM
Java doesn't have much API support in the game industry and is not widely recommended for games. The best scenario would be to learn all three of C, C++, and Objective-C. C++ is a "superset" of C, but it's harder to pick up than just plain C. Objective-C requires you to know C first, but it's really easy to learn after that. So my recommendation is to learn C first and then Obj-C and C++ later - although you can easily make powerful games without Obj-C or C++, all the id games up to Quake3 are pure C if you have any doubts. I should note that C++ is a little more popular for game development these days and you'll see lots of example code using it, so the argument *could* (and probably *will*) be made that you might want to jump in at the deep end and go for C++ right away, but I personally think it's overkill, especially for beginners. Also, most support APIs used with games (OpenGL, OpenAL, etc.) have a C public API so you can utilize those with just plain C skills. For graphics the standard API on the Mac is OpenGL. The quickest way to get into OpenGL is GLUT. If you can learn C and do some stuff with GLUT you will be well on your way.

Another short descriptive comparison of the C family of languages:

C - the basis of it all. It's the fastest and most flexible, but does not have any built-in object orientation facilities which can be seen as a major bummer. However, that does not mean that it cannot be used in an object-oriented fashion as many seem to believe.

Objective-C - is C with object orientation added. It's primarily used on Mac OS X for use with the Cocoa API. Cocoa is Apple's wiz-bang user interface API for making powerful menus and windows, etc. Objective-C is pretty efficient and is fast enough to be used for entire games but many of us just use it for the user interface and leave the faster graphics code in C or C++.

C++ - the focus of bitter debate between lovers and haters. C++ is probably the king of all programming languages today. It's object-oriented and very powerful and basically as fast as C for all intents and purposes. The new id games such as Doom3 and Quake4 use C++ as well as virtually every other major game in the industry. C++ also has the characteristic ability of encouraging programmers to write virtually unreadable code. Make no mistake about it C++ can be *very* complex and can take quite some effort to learn versus other languages, but many would argue the benefits outweigh the drawbacks.

atek3000
2005.10.25, 01:46 PM
AnotherJake...that is the best reply I've gotten to any question I've ever asked. hahaha Thank you so very much.

TomorrowPlusX
2005.10.25, 02:38 PM
I'd rather stick to good ol' dependable C than get stuck in a quagmire of multiple virtual protected inheritance with templates, operator overloading and copy constructors in C++ ;)

That "quagmire" of templates and operator overloading has allowed me to shorten my code by about 10 to 15% on average, leaving me with cleaner, more legible algorithms. Frankly, I like having a templated lrp() function ( and dozens of others that work on anything with the right operators exposed ), and vector, matrix and quaternion classes with full operator support.

Plus, the STL is fantastic. Many times I've been able to go from dozens of lines of c-like code to a handful of STL, with better performance in the end, because the algorithms could be focused on over the implementation.

I'm not knocking c. But I do have love for C++. It just has to be used wisely, is all.

Byron Clarke
2005.10.25, 03:55 PM
I second everything Another Jake said... wow textbook example of a great post

When I first decided to delve into the cryptic world of programming I bought myself a copy of "Programming in C++" and "C++ for dummies" without any forsight. I tried to follow but ended up completely lost... then again I was 16 and rather immature...

C seems to be a good starting point, being powerful enough to create large projects (as games usually are) and still remain friendly to newcomers.

I'm excited to see your progress, stick around!

AnotherJake
2005.10.25, 04:55 PM
>>AnotherJake...that is the best reply I've gotten to any question I've ever asked.

>>I second everything Another Jake said... wow textbook example of a great post

Wow, that doesn't happen very often. Thanks for the compliments! :)

BinarySpike
2005.10.26, 12:28 AM
*claps*
*claps* this is his 360th post

I just had a simple thought... My C++ tutorial starts teaching C++ specific things in chapter 14...

The first 13 are all C compatible. (except for the cout)

The only reason I use C++ in my test apps is for the debugging application of cout.

If anybody want's to create a game it all reverts back to Machine Code/Assembly language...
SAVE
LOAD

Ok, the only difference between C and C++ are the classes, which enhances support for STL which in turn gives your API's a much more to work with...

If you understand structure's you'll easly understand classes 101, and once you understand inheritance and virtual functions, which I learned in three days *shudders*, you have a much easyer time controlling things...

For instance... all C class functions you would have to add pointer argument in all of them... and you don't support virtual functions which in a large product can save up to 3000 lines of switch code....

In my latest project I'm crossing Cocoa/ObjC with C++ which I find extremly cool.
(even thought those ObjC++ files take for-ever to compile)


I see that the first poster has 1 post...

So an actual reply would probably just be wasting my time... (no offense)


Anyway, I suggest learning C++ first... because the first few chapters will use C stuff only.
(except for cout which is a really advanced object)

Great C/C++ tutorial (http://www.cplusplus.com/doc/tutorial/)
this tutorial does not cover function pointers. which are a pain in the tail to link sometimes.

Carlos Camacho
2005.10.26, 06:17 AM
I'd suggest you start small.
You mean like this...

http://www.ambrai.com/smalltalk/
http://www.ambrai.com/smalltalk/screenshots/Debugger.png

:lol:

Though on a more helpful note, you could actually try SmallTalk via Squeak:
Intro at Apple
http://www.apple.com/downloads/macosx/development_tools/squeak.html
Official Page
http://www.squeak.org/

This is an old article at O'Reilly, but it has interesting tidbits for newcomers:
http://www.macdevcenter.com/pub/a/mac/2001/12/04/osx_java.html
Like,
Much is made of the fact that Java syntax is similar to C/C++ syntax. The use of the familiar C-like syntax helped Java quickly become a widely accepted language. Experienced programmers new to Java could quickly write working code, but often this code didn't capture the spirit of Java. What was missing was the object-orientedness of Java. You'll find much of Java's OO roots in Smalltalk.

Also, WikiBooks has a short intro to ObjC:
http://en.wikibooks.org/wiki/Programming:Objective-C_syntax

This bit is from Usenet (very old post) but neat history...
[QUOTE>>> BZZT. Wrong. Java was modelled on a number of languages, most
>>> importantly Modula-3 and C++.

>> Of course, it's nonsense that Java was modelled off of NewtonScript,
>> but it's even goofier to say that Java was based on Modula-3 and C++.

>> Java's *syntax* may resemble C++, but it has no similarity to C++
>> as a language. Java's chief *semantics* are dynamically-bound and
>> use single inheritance, class objects, and an extensive runtime system.
>> C++ and Modula-3 are as far away from this model as any object-oriented
>> language can be.

>> Java is clearly semantically derivative of Smalltalk and other
>> languages related to it. Most notably, NeXT's
>> Objective-C is almost uncannily similar to Java: single inheritance,
>> dynamic binding, dynamic loading, "class" objects, interfaces,
>> and now methods stored as data (a-la Java's "reflection" library),
>> all-virtual functions, you name it. It's almost weird.

> Hardly weird it was by design actually. As I remember my Java history
> Patrick Naughton the gentleman who got the ball rolling was about to
> quit Sun and join up with NeXT. He happened to be on the same
> intermural hockey team as Scott McNealy. Scott told him to hold off,
> write what he thought was wrong with Sun before he left. Patrick
> didn't leave and was one of the original Oak people. I would like
> to think his affinity for NeXTSTEP showed up in Java, with it
> having an close look and feel to that of Objective-C. (The main
> language on NeXTSTEP)
[/QUOTE]

BTW, anyone ever read this blog:
(The Missing Link: From Objective-C To Java )
http://blogs.sun.com/roller/page/toddfast/20050207

Cheers,