• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: World Builder Type Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: World Builder Type Application


  • Subject: Re: World Builder Type Application
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 9 May 2007 22:37:00 +0200

On 09.05.2007, at 15:40, Mike Burns wrote:
Nostalgia hit yesterday and I dusted off my old Mac II. Browsing through my old hard drive I stumbled upon World Builder -- an adventure game creation tool from 1986 that I used to play with in my younger days.

By Bill Appleton, the original creator of SuperCard :-) (SuperCard is still alive and well at http://www.supercard.us, by the way).


How does that process work? How could I write a program with XCode/ Cocoa that could let a user put all those elements together and then save it as an mac os x application? I'm sure this is a fairly complex topic, but any push in the right direction would be much appreciated.

Well, you'd have to pre-fabricate some of the elements. I.e. you'd probably start out with a regular NSDocument-based application, and represent everything specific to a particular game with a hierarchy of Cocoa objects. Those objects would support the NSKeyedCoding protocol so you can write and load a game using NSKeyedArchiver and NSKeyedUnarchiver. You could use CoreData, but CoreData is really advanced technology, and hard to get right if you haven't done manual object hierarchies yet, so I'd suggest doing it manually.


If you want to just build regular games made up of pictures, you'd probably just have a huge custom view in your document's window and draw all the images yourself, on top of each other (although it almost works, Cocoa doesn't yet support overlapping views that stay layered correctly). You'd also have to do "picking", i.e. looping over all visible objects in the scene and finding out which one lies at the mouse location for a click or mouse-over.

To build a standalone application from that, someone else already suggested the correct approach: Just build a "player" version of your game engine (you can use #ifdef from the C preprocessor to exclude "Builder-only" code and thus use the same source code for both versions and just define a preprocessor constant in the "Builder" target of your project that turns the code on that it adds on top of the player). That player version would then look for a game document in its bundle and open that at startup.

Just put a zipped version of that player into your builder (zipped so Finder doesn't get ideas and run it), and when a user saves as a standalone, unzip a copy and copy the document into the right place.

If you use the same source base for both Builder and Player, be sure to give them different bundle identifiers and have the player not advertise it can open documents, or Finder will open documents with a standalone instead of the builder... you wouldn't want that. The PList compiler that's available could be used to run the preprocessor over that file, too.

For your script language, a neat thing you could do with Cocoa would be to use NSScanner to break it up into lines and those into words. Define a very simple and strict syntax for now, something like:

<object> <action> <param>

Each object would get a name (one word), and then you'd just search the current scene for an object of that name, and use NSSelectorFromString() to turn the action into a SEL, and then use performSelector: on the object you looked up to call a method of that name and with that param, after checking whether the SEL is Nil or the object doesn't respondsToSelector:.

If you want a finished programming language, Lua might also be worth looking into, I think there's a Cocoa wrapper around that somewhere on the web. It's not a very pretty language, but easy to integrate into other applications. Well, IMNSHO it's an ugly language, but YMMV...

Cheers,
-- M. Uli Kusterer
http://www.zathras.de



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: World Builder Type Application
      • From: Sherm Pendley <email@hidden>
References: 
 >World Builder Type Application (From: Mike Burns <email@hidden>)

  • Prev by Date: Re: Newbie memory question
  • Next by Date: Object Scope
  • Previous by thread: Re: World Builder Type Application
  • Next by thread: Re: World Builder Type Application
  • Index(es):
    • Date
    • Thread