After testing out the bitwise operator I made some improvements. Testing with a million-bit long set, performance seems really good. A million get operations takes about 17ms over the control function, and a million set operations takes about 33ms. That’s high enough that I could do a million set operations for each frame, which I probably won’t need to but it’s good to have that headroom.
Earlier tests weren’t quite so favorable, and I made a bunch of optimizations to get it where it is now, so the current code of bitset follows:
public var length(default, set):UInt;
public var contents:ByteArray;
public function new(length:Int)
contents = new ByteArray();
this.length = length;
private inline function set_length(val:UInt):UInt
contents.length = val >>> 3;
return length = val;
public inline function get(index:Int):Bool
return (((contents[index >> 3] >>> (7 – (index & 0x7))) & 0x01) == 1);
public inline function set(index:Int, val:Bool):BitSet
contents[index >> 3] ^= (val ? 1 : 0) << (7 – (index & 0x7));
Much terser now, though a bit hard to read if you’re not super familiar with bitwise operations. I think this is about as efficient as I’m going to be able to make this.
Aside from the bitset, I went ahead and added more pseudocode to the rough game project. Tomorrow I’ll see if I can get the update loop up and running: This is going to be the trickiest part, so it may take me a while and become very frustrating. We’ll see.
EverEnding-wise, the left-facing run animation continues to be a work in progress. I thought I’d finish it today but it’s still got a little ways left to go I think.