Code design for a 2D game - oop

I am in need of some resources on how to design the main components of a basic 2d game.
Let's call it an "engine". How should I design my renderer, scene manager, entity manager a.s.o. and how should they interact with each other? What about event management, resource management, ...
Maybe someone has some cool UML? Or any "tutorial"? Some general hints and tips?

I've actually also struggled some in order to get a hold of some good tutorial for a while. I found tons of mediocre sites with working game-code but lacking explanations.
What helped me the most was probably just skimming through game code I found casually looking around, and also reading the chapters of the book on this site: Killer Game Programming with Java
You can find some game-code to look through on these sites:
http://www.cokeandcode.com/info/tut2d.html
http://www.javacooperation.gmxhome.de/TutorialStartEng.html
Hope you found this helpful!

Related

Route for learning Smalltalk aka Squeak

Calling Jedi Masters of the Smalltalk universe,
I have knowledge of C++/Python/Perl and have been coding for 5+ years now.
I have to fork Scratch - MIT's Visual programming language to add support for a robotic kit. Scratch is created using Squeak, which is an implementation of Smalltalk.
I am planning to read A Little Smalltalk - By Timothy budd followed by Sqeak By Examples - By Oscar Nierstrasz [http://squeakbyexample.org/]
Do you think this is a good idea ?. What would you suggest ?. Are there free video tutorials I can watch.
End objective is to be able to make sense of scratch codebase. I want to get hang of smalltalk once before I can make sense of the (as of now) weird looking Squeak development environment and its ways.
Luke Smallwalker
Actually, I work with the core developers of Scratch for Arduino! It may be a good start for you to take a look at its code.
I think A Little Smalltalk goes a bit too deep for what you'll need. Squeak by example is, IMO, much better suited as an entry point to the language.
Also, you may want to take a look at Prof Stef for Amber, which is not an intro to Squeak but to Amber Smalltalk. Anyway the syntax is pretty much the same and it will get you a first good idea of what Smalltalk feels like.
HIH, good luck!
[edit] Yesterday I stumbled upon this great article explaining how to read Smalltalk code for Java/C++ developers.
check out my youtube tutorial series Squeak from the very start
http://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=viewall
I have read through "Squeak By Example" and I would say it is very good. I haven't seen "A Little Smalltalk" I think it might be a little outdated because it is from 1987.
after reading "Squeak By Example" I came across BotsInc it might be useful to go BotsInc even though it might seem a bit childish at first. Squeak By Example would be better to understand Smalltalk more fully.
this is a small squeak tutorial that might help too http://scratch.mit.edu/forums/viewtopic.php?id=39196
Stephan B Wessels has a Laser game project that was really useful for me when learning Smalltalk (in Squeak). You can follow and code along here: http://squeak.preeminent.org/tut2007/html/index.html
On to Smalltalk by Patrick Henry Winston is a succinct introductory book that you can get pretty cheaply used at http://www.amazon.com/On-Smalltalk-Patrick-Henry-Winston/dp/0201498278/ref=cm_cr-mr-title

Learning Cocoa. Should I delve into Apple's documentation?

I have built some basic apps for iPhone and Mac with a general understanding of Cocoa, but haven't had a detailed understanding. Now I want to go deeper.
I have just finished the Objective-C documentation at MacDevCenter. It was great to get in-depth look but took far too much time, specially because a lot of it is conceptual, and it's hard to build detailed examples to make use of the concepts.
Now I am on to Cocoa, but feel like it would be too much work to go through 250 page documents for Cocoa itself, then KVC, Cocoa Bindings, and Core Data.
Would I be better off at this stage picking up a good book on Cocoa (Hillegass' is too sparse I think) or should I just bite the bullet and go through the docs?
Apple's documentation is generally excellent. The API reference in the very least is some of the best I've read (right up there with Java's API reference), and is a very valuable asset.
I'd suggest reading the overview pages for topics you're interested in to get a general "feel" for how they work and a starting point, and then just start writing code. You can refer to the documentation to fill in blanks that you encounter while writing code.
Writing a small project to exercise your use of APIs you'd like to learn is a great way to get started.
I've found Hillegass's book to be far from sparse. In fact, I've found it to be one of the most dense books on programming I've read. I've re-read most of the chapters at least 4 times, and each time understood more. By re-reading, I've understood the reason he included a certain paragraph and how it fits with the bigger picture. He spells everything out very clearly and doesn't waste words. I'm amazed at the amount that's contained in that book.
You mentioned that you want to learn by doing, instead of by reading. The Hillegass book has a section at the end of each chapter where you put what you've learned to the test, by building an application.
Of the three things you talked about, KVC, Cocoa Bindings and Core Data, the first two are covered very well. I did find the Core Data chapters to be a lot more sparse. That's the only part of the book that I haven't been able to understand without other documentation. The Pragmatic Programmers book covers it much better.
Anyway, the answer to your question is: it depends. If you've managed to work your way through the Mac Dev Center documentation, it may be that you're the kind of person who learns easily from that style of resource. If you like learning from books, the best one is Hillegass.
I'd recommend an excellent book released some time ago: ‘Cocoa Design Patterns’ by Erik M. Buck and Donald A. Yacktman.
Of course you can dive into Apple's documentation, but to me, I found Hillegass' book is a good start for learning Cocoa. The value of the book, I think, is the introduction of the conventions and idioms of Cocoa.
Is it really clear for a new Cocoa developer to find out information on issues like when and when not to send message autorelease to an object? You can argue that a single Googling will do, but how do you know there are these kind of issues in the first place?
Go get a good book, look through it and take notes. It could save your time. For me, on Cocoa, the book is Hillegass'.
Hillegass' book will drive you to the free documentation every time he fails to make sense in order to be "funny" (i.e. every other paragraph) anyway, so unless you just want to give him $40, you will be much better off sticking to what Apple gives you au gratis. At the very least you won't pick up any of his horrible UI design habits.
You don't really need to go through ALL the bindings and Core Data docs page by page--half of it is stuff you'll likely never use. Knowing where to look for more information is far more valuable a skill than memorizing APIs.
The reference is great and invaluable, but might not be the easiest way to start coding (as people have mentioned).
I started looking at the stanford lectures on iphone development, then coded as I went along. I've actually used them as reference once or twice as well... They are available on itunes for free.
It depends on what other programming experience you have and how you learn best. If you're fairly new to programming in general, I'd recommend Hillegass to start. If you're fairly competent at OOP but don't know Objective-C, you can go for Apple's "Introduction to The Objective-C Programming Language" to learn ObjC's language features. If you've programmed using paradigms other than OOP, you could look for general OOP book recommendations here on SO (e.g. "Best Referece to learn OOP independent of languages?"). I also second Jonatan's recommendation to check out what programming videos iTunes University offers. They are recordings of lectures from top-tier universities and generally of good scholastic quality (I only qualify this with "generally" because I haven't seen them all; the ones I have seen invariably were of quality). No matter where you go to learn ObjC and Cocoa, you'll still yourself using Apple's docs as reference.
As you learn, you might also find CocoaDev a useful ancillary source.
Aaron Hillegass's book is the text for his one-week cocoa development seminar, and it has been revised over several years of teaching Cocoa to beginners. Aaron's course is where Apple sends their own employees, now that they don't do the Cocoa course in-house anymore.
Apple's documentation is an excellent reference, but I agree that it's a huge resource to try to learn Cocoa from in the first place. Besides, you probably don't need to know the whole API up front -- just learn each part as you need it.
When I started learning, I just picked a project, sat down and started trying to code. When I ran into something I didn't know, I just googled it, which led to a tutorial and/or the relevant page of Apple's documentation.
In my experience, the best way to learn something like this is, well, experience.
Apple's documentation generally contains excellent API references, but (in my opinion) lacks equivalent topical guides. This makes it a bit hard to follow for beginners (Jacob Kaplan-Moss in the link I just gave makes the point that Python's documentation is like this, but I think Apple's is much more).
My recommendation would be to pick up Hillegass's book, alongside a project. The first few chapters explain fundamentals, so make sure to read those (and do the exercises!), or you won't be able to get far. Then try and implement your project idea; when you reach a wall, look through the Table of Contents and the glossary of the book and see if there's something that covers it. If you find something, use this as an excuse to read it fully and understand it. When you're finished, you'll have both a greater understanding and a project to show for it. Furthermore, you'll know what to search for in Apple's API references next time you try to implement something. This helped motivate me to finish the book, maybe it'll be helpful for you.[1]
[1]: (disclaimer: I have an odd learning style)

I need an accurate, comprehensive and idiot-proof OOD tutorial to help me avoid Global variables in C#

Can anyone point me in the direction of a very good online OO Design (and Programming) tutorial or resource ?
I appear to have badly designed a small AP in C# and now want to sort it out before I go any further and frustrate myself even more.
I did try to do it quickly and only went over a small and insignificant (now I realise) tutorial on OODP and C# and classes etc and not given it the importance, and time, its obviously needs.
Actually, a good C# tutorial would be helpful too - I only read the C# Programming guide (Public Beta Release), a very old book - 2000/1.
More haste less speed etc. doh
Thanks, George.
I have pointed people to both of these resources before, they are a little basic but they over some good high level overviews:
Learning C# and OOP
C# an Object Oriented Introduction
A lot depends on your skill level and how you design programs in general (your background etc).
It will come with experience. One of my favorite ways to learn is to have a senior coder with 20+ years of experience to tear my code apart. No pain - no gain. The book knowledge goes into one eye and comes out of the other ... Post some code here, damn it!

Open source Objective-C projects with high quality code?

I think one of the best ways to learn a new programming language is to dive into source code and see how experienced coders write. I've found this kind of question asked here on Stack Overflow for other languages, but none targeted at Objective-C. The closest I've found is this question about good-looking Cocoa user interfaces, but I'm thinking in terms of general code quality, such as good use of idioms and design patterns, and usable documentation. Another good characteristic would be a code-base that is large enough to require real organizational discipline, but small enough that a beginner can fit his/her head around.
What do you think is a high-quality open source project that meets these criteria?
There's a decent list of open source Mac projects on CocoaDev: http://cocoadev.com/CocoaOpen
Not all of the projects are still active, but a decent number of them are. I particularly recommend:
BWToolkit - http://bitbucket.org/bwalkin/bwtoolkit/
BGHUDAppKit - http://www.binarymethod.com/bghudappkit/
CHDataStructures - http://cocoaheads.byu.edu/code/CHDataStructures
MGTwitterEngine - http://mattgemmell.com/source
Sparkle - http://code.google.com/p/sparkleplus/
Colloquy - http://colloquy.info/project/wiki/Source%20Code
CocoaRest - http://github.com/sdegutis/CocoaREST
CorePlot - http://code.google.com/p/core-plot/
I've found Adium to be a well-designed and written Objective-C project. It has a huge codebase, too.
I don't think there's any one place to learn all the Objective-C idioms and best practices, but you can pick them up here and there over time and practice. Cocoa mailing lists and blogs are good resources for this. (There are several SO questions relating to that.)
I haven't dived into the source myself, but the Omni frameworks are well-respected in the Mac community.
I work on a framework of my own that's still rough around the edges, but I strive for quality documentation in addition to understandable, well-structured code.
Google Quick Search Box [ qsb-mac - Google Code ]
I think The Google Quick Search Box (QSB) is worth a look. IMHO it's pretty much a cleaner googley rewrite of Quicksilver (Note: N. Jitkoff, the QS programmer, is also involved in the Google QSB).
Apple has tons of downloadable examples on their developer website. You get to see the source, and the license is BSDish from what I recall (use it for whatever, but don't repost original code without the license).
http://developer.apple.com/samplecode/Cocoa/index-date.html
Check Out lots off open source project here.
http://code4app.net
http://code4app.com
https://www.cocoacontrols.com
Here's a test app I wrote earlier today. Download links under “get source” in the top-right.
It's small, but it demonstrates good organizational discipline (separate controller object, instead of everything crammed into AppDelegate), a simple model layer with one model class (Header), and correct use of Cocoa Bindings.
I used to work on the GNUstep sources, they've got a good consistent coding style and the code is well-organised. Of course the project is hardly small, but given that you know what most of the classes do as you've used them in your Cocoa projects it's easy to zoom in on a piece that interests you. Some of the GNUstep Applications Project or Étoilé apps may also be a good place to start.
Check out PSTreeGraph, a view control for iPad applications.
iMedia Browser
, shows support of 10.4 - 10.7 strategies, is neatly and purposefully organized, and deeply commented. inherent problems using ImageKit have been boldly approached and solved.
i aspire to this level of thought mixed with practicality.

Examples of Cocoa/Objective-C and Distributed Objects?

I am learning Cocoa and Objective-C (well, and C) to make a few Mac apps I've had floating around. I need to use Distributed Objects, but am having trouble finding simple, concise examples. Does anybody know of any?
A google search came up with plenty of hits. The Apple docs are also good. Late Night Cocoa also has an episode on it.
I maintain the comp.lang.objective-c FAQ, and there's an example in there: How can I forward messages between remote objects? It's very short but should give you the basic idea, on which you can then hang the Apple and GNUstep docs to which it links.
It's a fairly old article but this is probably a good starting point for distributed objects. I personally found it easier to start with the older tutorials and work my way up to the more recent ones which use new technologies such as Core Data.
http://cocoadevcentral.com/articles/000062.php
I discovered this project at SourceForge which is a fairly large Cocoa project. It uses bonjour and distributed objects, and other then that I've found it to be a good resource and example. Just thought I'd put that out there in case anybody comes across this question.