Dynamic language
Nick Sabalausky
a at a.a
Thu Mar 15 19:28:29 PDT 2012
"James Miller" <james at aatch.net> wrote in message
news:mailman.733.1331853568.4860.digitalmars-d at puremagic.com...
>
> I hate the fact that Flash games are created the way they are. For
> one, it's impenetrable to try and learn properly, I had so much
> trouble figuring out how to do things properly, you can attach scripts
> to almost any object, but sometimes it might be shared over all of the
> same objects, and other times only on that instance, depending on how
> you've placed them on the canvas.
>
> I probably wrote some terrible code when I started making Flash games,
> and now Actionscript is so foreign to me that i can barely understand
> where to start.
>
Yea, Flash is just plain insane from start to finish. Even the
vector/scene-editing GUI is awful. Christ, this is the company that's known
for Illustrator: That's the one part of Flash they *should* have been able
to get right! (I dunno, maybe the Flash IDE was just drowning in too much
MacroMedia legacy?)
One thing I learned though, is that if you're going to make something in
Flash, your best bet is to use as *little* of what Adobe provides as
possible:
- Cover any APIs that suck with wrappers that paper over the suck (to the
extent possible).
- Don't use Flash's "frames" system: Just put your whole program in one
"frame", and handle scenes manually by toggling the "_visible" attribute on
entire groups of MovieClips. Do animation/tweening by using the timer APIs,
a simple "lerp" formula[1], etc, stuff like that.
- *Every* piece of ActionScript code embedded into your .fla should be *one*
line: #include "realCodeHere.hx"; Store the real code in that *REAL* text
file, under proper version control, and edit in a *real* text/code editor.
Hell, even if nothing else, at least this make it possible to fucking *diff
the files*! (*grumble*Adobe doesn't understand software
developement*grumble*)
- Abandon ActionScript entirely. Use Haxe instead, and use swfmill to embed
assets. Now you don't need to have the Flash IDE even *installed*. Hooray!
Every single one of those changes made an order of magnitude improvement for
me. Even with the overhead of actually making the switches, it was well
worth it: the initial overheads easily paid for themselves in both tangible
and intangible ways.
[1] A lerp function in Haxe, copied directly from my own production code
(consider it "Do what the fuck you want" license), formula derived by just
remembering basic high school algebra:
class Util
{
[...]
// Convert a value between two scales, using a linear interpolation.
// To use as a traditional lerp: Util.lerp(normalizedValue, 0, 1, min,
max)
// To convert from farenhight to celcius: Util.lerp(degreesF, 32, 212,
0, 100)
public static function lerp(fromVal:Float,
fromA:Float, fromB:Float,
toA:Float, toB:Float):Float
{
return toA + (fromVal - fromA) * ((toB-toA) / (fromB-fromA));
}
[...]
}
More information about the Digitalmars-d
mailing list