Skip navigation

Why hasn't anyone made a game framework for AS?

346 Views 7 Replies Latest reply: Jan 27, 2013 10:29 AM by VikingOSX RSS
Boboonski Level 1 Level 1 (25 points)
Currently Being Moderated
Jan 26, 2013 10:53 PM

This probably is a really stupid question, and many of you are probably laughing at it, but, why not?  I mean, if someone modified the language to be able to import graphics and use functions, it would most definitely be favoured by most mac developers because of its easy syntax.

 

I'm thinking it would look kind of like this:

 

set window1 to display window (window.x = 600, window.y = 480) with background 'background.png' with title 'Simple Game'

set char to image "char.png"

set block1 to image "wood.png"

tell window1 to set position.x of char to 0

tell window1 to set position.y of char to 0

tell window1 to draw block1 position (position.x=-5,position.y=2)

tell window1

if key "w" is pressed then set position.y of char to position.x of char + 32

if key "s" is pressed then set position.x of char to position.x of char + 32

if key "a" is pressed then set position.x of char to position.x of char - 32

if key "d" is pressed then set position.y of char to position.x of char - 32

end tell

if char is on collision with block1 then display dialog "You Won!"

 

That would be a simple program to control 'char.png' until you touched 'wood.png', which would display a dialog saying 'You Won!'  I understand applescript is a scripting language, mostly for automating functions, I've just seen it done in other languages, so I was wondering why nobody has here.

 

Thanks in advanced, Boboonski

 

(sorry for being such a noob)

  • twtwtw Level 5 Level 5 (4,580 points)
    Currently Being Moderated
    Jan 26, 2013 11:23 PM (in response to Boboonski)

    A few reasons:

     

    • Applescript is geared towards inter-process communication rather than direct processing.  It has some processing features, but it is not really a powerful processing language.
    • Applescript is (by computational standards, even by scripting sandards) very slow.
    • Applescript has very few event monitoring features.  It can't easily read the keyboard or any attached devices (not in anything resembling real time), and it doesn't have the mechanisms to deal with interactive behaviors.

     

    AppleScript would be a wonderful language if you were writing an old-style text-based game: think Adventure, or Zork, if you have any idea what those are (ahhhh, those were the good old days...).  Anything more sophisticated would require so much cocoa that you might as well skip the applescript portions of the code.

     

    AS is good at what it does.  It is no good at all at what it doesn't do. 

  • red_menace Level 6 Level 6 (14,275 points)
    Currently Being Moderated
    Jan 26, 2013 11:32 PM (in response to Boboonski)

    AppleScript would most definitely not be "favoured by most mac developers", no matter what kind of framework you added to it, and I am sure most will get a chuckle out of the "easy syntax" bit.  As an application scripting language it has a place, but it just isn't designed for this kind of thing.

     

    AppleScriptObjC in Xcode has the ability to use the Cocoa frameworks for creating custom user interfaces, but anyone that wants to do something serious usually winds up just skipping the whole mess and going with Objective-C.  And as far as scripting goes, there is far more support (and interest) for other languages such as Python, Ruby, Javascript, etc- in addition to significantly outperforming AppleScript, since a lot of these are open source you would be more likely to find the extensions you want.

  • MrHoffman Level 6 Level 6 (11,720 points)
    Currently Being Moderated
    Jan 27, 2013 8:59 AM (in response to Boboonski)

    AppleScript is problematic for many tasks beyond GUI scripting.  Games among those.  AppleScript is slow.  It's not portable.  Its syntax is exceedingly verbose for what you can get from it.  It's missing libraries and extensions necessary for common tasks.  AppleScript has enough issues figuring out what just happened when you're "merely" scripting the GUI, and inserting delays is a far too common hack for some versions of that.

     

    Read: MrHoffman is not a fan of AppleScript, beyond its use with scripting GUI applications, and particularly for scripting applications that are not otherwise scriptable.

     

    Javascript (which is also ugly in many ways, but far more ubiquitous), Lua, Python and Java are rather more common choices for "low end" games these days.  Minecraft is written in Java, for instance.  Adobe Flash is still used, too.

     

    For a number of games, building the game using Unity 3D or Unreal or similar is a common choices.

     

    But in practice, the implementation language is less important than the game itself.  To twtwtw's comment, Colossal Cave Adventure was written in FORTRAN.  (I ported copy of the original version to gfortran on OS X, and have it posted.)  If AppleScript is interesting to you, by all means use it.  That's one way you'll learn its strengths and weaknesses, particularly when you can compare it with other implementation languages.

  • twtwtw Level 5 Level 5 (4,580 points)
    Currently Being Moderated
    Jan 27, 2013 9:12 AM (in response to MrHoffman)

    MrHoffman wrote:

     

    To twtwtw's comment, Colossal Cave Adventure was written in FORTRAN.

     

    Yes, I know it was.  But it could have been written better in AppleScript. 

     

    Read: tw *is* a fan of AppleScript, and wishes MrHoffman would be a tad more generous. 

  • VikingOSX Level 5 Level 5 (4,700 points)
    Currently Being Moderated
    Jan 27, 2013 10:29 AM (in response to Boboonski)

    There is a reason Apple did not write OS X entirely in AppleScript.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.