January 22nd, 2016Moving Forward

And not just that! Forward, backward, sideways; there’s just no limit to the ways you can go! (within the limits of 2D space)

So, two small improvements to make that work: sprite values can be accessed and modified from script (which is actually just a matter of binding und returning values the script can understand), and the addition of an input handler, which currently only collects and checks mouse states and offers the possibility to bind callback functions to mouse events, like a click for example. Everything else can then be taken care of by script:

local target = {};

function init()
{
    // ...
    input.SetOnClick("onClick");
    // ...
}

function update()
{
    // ...
    val <- sprites.player.GetPosition();
    
    if (val.x < target.x)
        sprites.player.MoveX(1);
    else if (val.x > target.x)
        sprites.player.MoveX(-1);
        
    if (val.y < target.y)
        sprites.player.MoveY(1);
    else if (val.y > target.y)
        sprites.player.MoveY(-1);
    // ...
}

function onClick(x, y)
{
    target.x <- x;
    target.y <- y;
}

And just like that we have movement that only required some care during recording in oder to not make it look as awful as that code allows!

CORE2D-moving
As for the rest of last week’s goals, I’m going to pretend I never said anything about instancing because it seems boring and I’m lazy. I made three Fridays in a row though! That’s something right there!

Still, I doubt that the next developments will be at all interesting to talk about (let’s face it, this is pushing it already), so perhaps I’ll cool it until it’s ready to build a game. Or something really exciting comes up. Or something moderately exciting comes up. Or I’m getting started on Core3D. Or I’m doing something else entirely. You just never know. I know I don’t.

Crabman out.