Learning Cocoa game development - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Learning Cocoa game development (/thread-7930.html)
Pages: 1 2
Learning Cocoa game development - Miglu - Aug 1, 2010 08:21 AM
I know the basics of Cocoa and I have learned much OpenGL from OpenGL Programming Guide, but I still do not have skills to make Cocoa games. A tutorial about making a game would be very helpful, but I have not found any good tutorials. Either the code is not explained well, like in http://zerobyzero.ca/~ktatters/seasi...als/index.html, Core Animation is used instead of OpenGL (e.g. http://cocoawithlove.com/2009/02/ast...animation.html), or it is old (http://www.amazon.com/Game-Programmi...0486135&sr=1-1). What tutorial or book should I use? Or could someone in this forum make one, or just give the source code of a simple game, like Asteroids, that is made with Cocoa and OpenGL.
How did you learn Cocoa game development?
RE: Looking for Cocoa game tutorials or books - mikey - Aug 2, 2010 12:35 PM
I'm not so sure about books, I had difficulty finding any on OpenGL game programming alone, let alone mac games! And those that I did find were out of date.
I think your best bet is to look online. I'm sorry I can't help you anymore.
RE: Oh yeah! - AnotherJake - Aug 8, 2010 11:25 AM
As requested in your other thread, I shall answer your question here presently.
I learned how to program C many many years ago. Then I learned a little about OpenGL. Then OS X came around. Then later I learned how to do some Cocoa programming.
(Aug 1, 2010 08:21 AM)Miglu Wrote: What tutorial or book should I use? Or could someone in this forum make one, or just give the source code of a simple game, like Asteroids, that is made with Cocoa and OpenGL.
That's a tall request! I can't make any promises, but if I get some spare time in the next week or two, I'll see if I can whip something together for you.
 I changed the title of this thread to something a little more descriptive [/edit]
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 12:21 PM
Could someone explain why this way of doing a constant aspect ratio does not work.
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 12:26 PM
Try this instead, in awakeFromNib:
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 12:28 PM
But could you show how to make any aspect ratio constant.
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 12:30 PM
It should be apparent that all you need to do is change the values in
I noticed in your other thread that you didn't set your projection matrix, which might be why you're having difficulty getting the results you want.
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 12:37 PM
Thanks. It works without a projection matrix.
I use this to accelerate the circle:
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 12:46 PM
You can do it however you want, as long as it works for you. The post you linked to is just the way I like to do it.
You are going to need to take delta time into account at some point though, so
... just isn't good enough. You'll need to do this instead, if you want any consistency:
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 12:50 PM
If I use my method, what should I write in place of a, w, s and d if I want to use the arrow keys?
Thanks for answering my questions.
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 12:55 PM
Not sure how you would do it with your technique, but if you look in my processKeys method I am equating the character to NSLeftArrowFunctionKey, NSRightArrowFunctionKey, NSUpArrowFunctionKey, or NSDownArrowFunctionKey, which works for me.
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 01:28 PM
viewWidth was undeclared in your aspect ratio code, so I defined it.
There are two problems with this code. One is that whatever the values in NSMakeSize(1.0f, 1.0f) are, the window starts as a square and when it is resized, it instantly turns into a rectangle that has the ratio of those numbers. The second is that the view is not resized. Could you correct this?
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 01:48 PM
Here, try this instead.
To get the view to resize automatically, you need to go into the nib and select the view. Then in the inspector, click on the little ruler tab. There you will see Size & Position, and below that will be Autosizing. In the autosizing section there is a little box on the left. Click in the center of the little box until you have red arrows pointing both up and down and left and right. That will set the view to follow the size of the window.
RE: Learning Cocoa game development - Miglu - Aug 8, 2010 01:54 PM
The first problem was solved. However, although I have all of the red lines on, the view does not resize, which I can see from the fact that the circle does not resize when I resize the window.
RE: Learning Cocoa game development - AnotherJake - Aug 8, 2010 02:02 PM
Are you sure that the red arrows are in the center of the small box in the middle? Red lines on the *outside* of that little box set which sides the view is anchored to, but do not resize the view.