2016-09-10-resurrecting-zombies-part-2.md 2.7 KB


title: Resurrecting Zombies, Part 2 tags: coding, haxe, games, zombie protagonist

description: Going through a bunch of compiler errors to get the old code at least a bit closer to working.

Actor should be Void

Fourteen things "should be Void". That's lots of things. It's also, coincidentally, the count of constructor methods that end in return this;:

$ grep -c "return this;" *.hx
Actor.hx:2
KeyboardMonitor.hx:0
Screens.hx:12
ZombieProtagonist.hx:0

Amazingly, the locations (e.g. "./Actor.hx:47: characters 8-19") all map, too. Shocking. Can getting this to compile be as simple as removing those return statements? Maybe not, but it gets us further:

$ haxe -cp . -main ZombieProtagonist -swf Zombie.swf
./Actor.hx:322: lines 322-328 : Field touchedHaven should be declared with 'override' since it is inherited from superclass FollowFlee
... (a few of these)

Overriding

According to modern haxe practices, if you're overriding a parent method, you have to explicitly define the method with the override keyword.

Part of me hoped it would be this simple. The only compiler errors reported at the start were of these two varieties. There were a bunch, but just thosw two categories. Unfortunately, that was apparently just a first parsing pass.

$ haxe -cp . -main ZombieProtagonist -swf Zombie.swf
./Actor.hx:270: characters 19-25 : Local variable startx used without being initialized

Two interesting things here: 1- apparently variable declaration rules have changed, and 2- only one error was spit out. That latter thing is ominous, and suggests to me that I'm about to dive into a very long back and forth between compiler and editor[^ide].

Bug Hunt

Well, that turned out not to be as bad as feared. Turn a couple of:

        var startx;
        var starty;

... into ...

        var startx = 0;
        var starty = 0;

... which got rid of that error entirely. Then came:

./Screens.hx:44: characters 8-14 : You cannot assign some super class vars before calling super() in flash, this will reset them to default value

That meant crawling through all the places I was calling super() and moving them to before any attribute assignments. That was confined solely to constructor methods.

Once that was done? It compiled!

... and the SWF was a whitescreen.

Alright, then. Back to the drawing board. Now that it compiles, I supposed I'll have to actually figure out how it works, in order to, you know, make it work.

[^ide]: At this point, I'm tempted to start using a haxe IDE to help me along. I'm pretty solidly in the emacs camp, though, so it's going to take a little more, yet.