XaiJu
malhavok
malhavok

patreon


Pain, they name is ES6

When I first started writing Queen of the Seas, after deciding on Twine and Javascript mostly on a whim, I then decided to try and make the code as broadly compatible as possible with various browsers. I'm not sure why I made this decision at the time, but the major impact of that was the eschewing of ES6 classes and using JavaScripts older prototype inheritance.

This was a very bad idea, to top all bad ideas.

There's a good reason why classes were introduced, not just because of the 'syntactical sugar' as they call it, but also because the prototype inheritance sucks nasty pirate dong in ways that I can't even begin to describe.

Anyway, obviously I relented because most engine code since around mid last year has been written in classes, or rewritten to be in classes. There are only a few main components that are not and for the most part they are relatively small or self contained. Well, except for one.

The fucking 2d rogue engine!!!

Now, to explain my dilemma you need to understand how my twisted programmer mind works. Currently there are two types of 'entities' that get drawn on the screen - the player and dig spots. I want to add a 3rd entity, namely monsters. Monsters need to have some of the attributes of both types of entities since they can move around and have a little bit of AI like the player.

Basically, what I want to do is an inheritance chain that looks sensibly like this:

Player -> (inherits) Being -> (inherits) Entity. With "Being" as the class where mobs will be created from.

It makes sense because it'll save a lot of code rework and the code that is shared between different classes will operate the same way, like say the code for knowing which visual to draw on the map is identical between all three classes. Inheritance saves times and makes your code more legible and maintainable. I knew this. I KNOW this, after all I am actually a professional software developer, even if JavaScript isn't a language I had much prior experience in.

So... the point of this dear Patrons? What am I trying to say? Basically, a lesson to other people thinking about making their own game in JS - 

FUCK OLD BROWSERS, FUCK THEM IN THEIR DIRTY ASSES. USE CLASSES IN YOUR CODE!

Ahem... cough cough. Sorry for the outburst. 

So yeah, I spent most of tonight refactoring garbage code that I shouldn't have written to be garbage in the first place because I knew better. I'm annoyed at myself. Learn from my mistakes.

I still have a bit of work to do, but hopefully sometime this weekend I'll have some screens or a gif to post showing Abamond literally coming alive. 

Cheers,

Mal


More Creators