Converting SWF scenes into something more OpenFl friendly

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?

1 Like

Another possibility is to use openFL Starling

I participated in a game jam quite a few years ago, I was still using as3, we ended up using Flash as a “level editor”. Pretty sure I still have my code somewhere, I’ll dig it out if there is an interest for it. It was nothing complicated since we only had 48 hours but it worked great.

Starling will let you have repeating texture like your walls… It’s pretty much a flat 3D engine with meshes, textures, shaders etc
I don’t know about the linestyles though, never tried something like that. Starling has a drawing API but I never played with it.
You can also write custom shaders, but be warned AGAL is not the funniest language around for that purpose :slight_smile: (on that subject I’ve been looking at Heaps lately, and noticed there seems to be some tools to convert heaps shaders to AGAL… maybe there is something here but I haven’t tried anything yet)

2 Likes

I’ve had some time to further think this over.
My project is now prepared so most objects are pre-rendered as bitmaps, however, to prevent unnecessary asset bulk, I want to take a different approach with the floors and most walls.
As I referred to in the original post (and Matse in reference to Starling), I want to render some objects as a 2D mesh.
So I assumed I can do this within the context of OpenFL and make a new type of DisplayObject for my floors and walls with a custom renderer to handle this.
I’ve had a look at OpenFL however and it looks like there’s no way to ‘plug-in’ or register a custom display object renderer without modifiying OpenGLRenderer.hx’s __renderDrawable method…
Or am I mistaken?

EDIT:
Never mind, I just found out about RenderEvent.RENDER_OPENGL!