Hacker News new | past | comments | ask | show | jobs | submit login
[Ask YC] Flash vs Shockwave vs Flex for games
19 points by arjunlall on May 29, 2008 | hide | past | favorite | 22 comments
Does anyone have any recommendations for a platform to use for creating an online 2D arcade game?

I have read that Shockwave has the fastest rendering engine but there is very little documentation for it.

I have used Flex before and am good with Actionscript, but would probably prefer using Shockwave's Javascript. Also, price isn't too much of an issue, I would rather spend a bit more now than regret it later.

Thoughts?




For a basic 2D arcade game, Flash with Actionscript is probably the best option at the moment for gaming and animation. Shockwave is a very old technology that was seemingly abandoned by Macromedia/Adobe in favor of Flash. Actionscript has seen all of the innovation and creative energy in the past 10 years and was the reason Adobe bought Macromedia. Flex seems geared more towards forms-based applications. It would likely be more difficult to build a game in Flex/MXML than using the standard timeline approach in Flash.


Actually, if he knows how to code, and he's doing anything more complex than Space Invaders, I think Flex is definitely the right choice. You don't have to use MXML with Flex - your entire project can be in Actionscript.

I just finished up Robokill (http://www.rocksolidarcade.com/games/robokill), and doing that in the Flash IDE would have been a nightmare.

Incidentally, Flash development tools are very poor. Full of subtle bugs (both compiler and runtime), things get broken all the time randomly in the frequent flash player releases, and there have been multiple year long petitions to get Adobe to fix simple bugs. But if you're going where the customers are, it's a necessary evil.


Wow, I think Robokill might have sold me on how smooth graphics with Flex can actually be.

I posted earlier about how I made one ball bounce around the screen in Flash and it wasnt silky smooth, but the polish on Robokill looks fantastic.

Any tips/tricks for Flex game development? Are there any game frameworks? My previous Flex work was a RIA and it seemed that Flex took care of all the frame drawing for me, do you handle things any differently when making games (ie something like bitblt)?


Thanks! We spent a lot of time to make this one as good as possible.

One gotcha with Flash is the default frame rate is 24 - if you turned that to 60, and bounced a ball around the screen, it should have been reasonably smooth. The smoothing property of an object turns on antialising which helps as you get subpixel movement, which helps too. Also, something about final graphics makes you just not notice as much - alpha blended edges definitely help.

I don't do anything really special. I wrote my own set of libraries, and they're just simple boilerplate that you'd expect. Rendering as in bitblt inside Actionscript would be way too slow, and the Flash render is actually reasonably good at throwing up untransformed images.

Some tips for speed:

* Composite the hell out of everything. Our background is just one 800x600 image, but it looks like there's a lot of variation because it is composited out of different layers (background scenery, large lighting sprite, tiles, decals on top of tiles, free rotated static lights and the walls sprite). You could do all of those as free sprites if you had a 3D renderer (Robokill would chew through maybe 1/40th the juice of my 8800 GTS), but it would absolutely kill the performance of the Flash renderer (and reasonably so - a single x86 core simply does not have the throughput).

* Untransformed images are very, very fast compared to transformed. If you must rotate and scale something, try to make that transform a constant and use the cacheAsBitmap property, which will mean Flash will render it to a cache bitmap making it a simple blit.

A concrete example of this is all of our particles are animated images, which blit untransformed to the game. It works out to about 10x faster than what would be possible if we did rotation/transform on them in real time.

* You can use additive to make stuff look cool with little overhead (the additive formula for pixel blending should be faster than the alpha formula, but who knows with Flash). That's the blend mode that gives you the fire and plasma glow look.

* ActionScript is slow, too, but there are almost always game specific hacks to get the desired performance out of it. Use lazy computation where possible. My enemies use real time pathfinding, because all I do is trace outwards from the player each frame, then reset that when the player changes square. Doing a per enemy pathfind, even using an optimised system such as A star (damn markup), would have been pretty much out of the question.

* Don't forget that you get more of your budget back when the action goes away. You may have noticed the additive lights and idle animations that fade in when the action dies down in a room. It doesn't matter that they're expesnive to render, because they're only there when the enemies (which are more so) are not, but I think they really help the look of the game. Also, our intro just goes over the top using lights like this, since they're the only thing being rendered.


Sweet, thanks! Where did you learn all this? Any books/websites? or was it just trial and error experience?


Basically, Adobe Livedocs, and trial and error. Although from a rendering perspective just knowing the theory behind it (write code to just rotate an image without concern for quality and it's instantly clear that it'll always be slow) gives you pretty much everything you need to know - it's just connect the dots from there.

Also, Flex Builder is a bit of a dud, but its profiler is very good. If you can afford it, it will give you very good insight into your code bottlenecks, if the $$ is worth it just for that. I use FlashDevelop to edit in still.

P.S. Sorry if I'm hating on Flash a bit too much throughout my posts. There were a few trivial bugs with serious implications that directly delayed our release, so I'm still quite annoyed. I'm back into Flash for the next project, though, because customers are more important than development comfort!


Thanks for the great information. One quick question... when you say you're "back to Flash" for your next project, are you talking about moving back to Flash (as opposed to Flex) as your dev tool/programming paradigm or did you stray from the Flash engine entirely?


Oops, I should have said Flex. I meant it in the 'oh well, back to the grind' sense. :)

All of our titles have been Flex so far and it will stay that way for a long time yet, I imagine. We started Stunt Pilot in the Flash IDE but it quickly became apparent that it was a really ineffective development environment for what we were doing. Flex has its problems, but at least the core model is more appropriate (i.e. entirely source code, command line compiler).


UPDATE: So I discovered the reason why the bouncing ball didn't seem to smooth, yet people insisted that it should be.

It seems that Flash for Mac is much slower at rendering than Flash for PC. The same file with a target fps of 100 runs at around 60fps on my dual core 2.16ghz mac, but runs at 98fps on a 1.7ghz single core PC.

I guess it makes sense that Adobe spent all their time optimizing the PC version.


I suppose this is why Steve Jobs has it in for them.


++Karma level for Robokill. I just spent the last hour thrashing my wrists on your game. Good job. It was a blast.


wow... robokill is pretty good.


Definitely not Shockwave, it's dead. I code ActionScript in a simple text editor, compile to Flash with MTASC http://mtasc.org (open source).

The best Flash games don't stray from the sweet spot, defined by 2D graphics and high responsiveness. The best Flash platformer is N http://www.addictinggames.com/ngame.html , the best 2D shooter is Ownage Burst http://thestylemachine.com/ownage , the best Flash game overall is Samorost2 http://amanita-design.net/samorost-2/ .


I had mentioned this earlier. Flex is amazing for this. Coming from a pure C++ background I had no difficulty learning it for implementing some custom remote monitoring UI for our games. The documentation is quite comprehensive and the learning curve is not too steep either. If you know javascript or have some knowledge of functional programming it makes it a lot more easier.


So my only issue with Flash/Flex is performance. They are both amazingly easy to use, but even just making a simple ball that bounces around the screen pong style isnt silky smooth. (The framerate is set at 60) Im worried that if just one ball isnt silky smooth, 100 objects moving at the same time would look bad.

Based on the nature of the game I am developing timing needs to be very precise, Im also very picky about choppy graphics.


I'd go for a combination of Flash and Flex myself, but I already own both. You can use Flash to export an asset library and then build the game as an ActionScript project, which you can compile using the free Flex compiler. If your assets don't need any timeline based animation, then just go down the Flex SDK route as you'll be able to embed those assets into your project with pure ActionScript.

I wouldn't recommend going down the Flex framework route so don't code it in MXML. You don't need the extra weight of the framework for something like this, an ActionScript project will do just fine. Also note that the next Flash Player has support for hardware acceleration and you can already download a version of the Flex compiler to target this new version. I guess that choice would also depend on how CPU intensive your game is going to be, when it would be released and what group of people you'd be targeting.


Our current project is a multiplayer 3d flash/as3 game: http://www.ultrakillz.com/play/

Unless you're looking to do something pretty powerful you'll be fine with flash rather than shockwave, especially if you already know some ActionScript. (AS3 is somewhere between Javascript and Java for complexity depending on how you choose to use it)

Flash has better penetration and far more documentation/community support than Shockwave.

In terms of the dev environment, the above game was coded using eclipse to edit AS files and compiled through the Flash IDE, although you could use Flex to compile instead...

Roll on flash 10 - UDP support!


Flash.

I really want to say JavaScript just to be different, but JavaScript has timing/performance issues that can be a pain to work around. And you can forget about embeddability: security considerations prevent most social sites from letting you embed JavaScript code in their pages. It gives you mad geek cred if you do a good game in it, though.


I looked for books on Director 11, but couldn't find any. One advantage of Flex would be the ample documentation and blog posts around the web, which I didn't see for shockwave. It does seem, though, that (documentation availability aside) Shockwave would be better for the purpose.


FYI: In the new Adobe Director, they created a really sweet 3D racing game. http://blogs.adobe.com/shockwaves/2008/02/


Another vote for Flash. FlashIDE and Flex aren't the only options too, haXe (http://haxe.org) is quite viable as well and has a lot of features and flexibility that make it my first choice. With swfmill the graphics can be made as svgs.


Does anyone know any good resources for game development in Flex, then? A good book, website/blog etc.?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: