I’m trying to convert an old game from AS2 Flash to OpenFl.
So far I’ve been depending upon the SWF haxe library to import all my assets, but I quickly realised that it would really be a struggle to render at a reasonable frame rate.
Scenes in the original game were just big MovieClips with lots of layers, consisting of shapes and bitmap fills. I could make the scenes very large, over 8000x8000px, and Flash would comfortably render them (and transform them!) at 30fps.
OpenFl targeting non-flash platforms however is not so kind.
I realised my larger scenes will have to be revised to render more efficiently.
One approach I am considering (but not at all enthusiastic about) is writing a JSFL based processor to convert each scene into a tilemap, but this’ll result in huge amounts of repeated bitmap data (inflating the asset size massively)
Consider this small section of a scene:
The floor and walls are repeated bitmap textures. The floor tile texture just happens to perfectly match the game’s ‘virtual’ tile size of 40px. The floor could therefore be represented by just 9 tiles on a tilemap (1 central, 4 sides, 4 corners).
The textures that make up the walls however are arbitrary sizes. To make a long seamless stretch of wall there is no appropriate way of efficiently dividing it into tiles, without resizing the original textures to all fit to a specified grid tile size… Besides that, the only way would be to divide each and every section of wall into arbitrarily sized chunks on a tile map, inflating the game assets size massively (and unnecessarily).
What would be great though is if I could represent my scenes not as cached bitmaps that need to be re-drawn each time they transform (the way OpenFl does) but more like 3D meshes.
The floor could be triangulated and drawn in a single call. The walls could be drawn in 2 calls (upper and lower need to be rendered separately due to depth-based objects)
Perhaps the various line styles could be drawn with shaders?
Is such an implementation even feasible in OpenFl? And if so does one already exist?
Or is there a better, simpler approach that I haven’t yet considered?