nickavv

the daikon games guy

I'm an indie game developer, software engineer, and friendly fella. Always trying to learn/grow and be a good person.

--
click this thing for my games acct
Daikon Games


nickavv
@nickavv

I wrote this little library in March-ish, for some unreleased/unfinished stuff I was working on. It adds a simple entity component system to GameMaker!

It makes GameMaker coding just that little bit more Unity-y, so I figured I'd clean it up and release it to the public finally in light of the recent debacle.

It's not as fully vetted as my other libraries, as I'm not using it heavily, but if you use it and find issues let me know and we can work through them! Open source style!


nickavv
@nickavv

Finally dug up an example of something I had been doing with it. Here is an Atom you could register to any object which would handle pixel-perfect movement with fractional speed adjustments

function Transform() : Atom() constructor {
    xspeed = 0;
    yspeed = 0;
    xAdjustment = 0;
    yAdjustment = 0;
    
    function trunc(number) {
        if (number < 0) {
            return ceil(number);
        } else {
            return floor(number);
        }
    }
    
    function on_step() {
        var _totalXspeed = xspeed + xAdjustment;
        var _totalYspeed = yspeed + yAdjustment;
        var _truncXspeed = trunc(_totalXspeed );
        var _truncYspeed = trunc(_totalYspeed );
        xAdjustment = _totalXspeed- _truncXspeed ;
        yAdjustment = _totalYspeed - _truncYspeed ;
        instance.x += _truncXspeed ;
        instance.y += _truncYspeed ;
    }
}

Then in your objects, which inherited from obj_molecule, you could do the following in their Create event:

transform = add_atom(new Transform());

And then rather than setting the object's hspeed and vspeed, you can instead set its transform.xspeed and transform.yspeed and it will just magically work.

So then you can essentially slap this behavior onto any object you want, and get pixel perfect smooth movement with minimal code re-use.


You must log in to comment.