HTML5 Huggernaut – cute platformer with grappling hooks

Nallebeorn

Member

In Huggernaut, you can't jump. But that's no big deal. Not when you've got a grappling hook! A grappling hook you'll make good use of as you try to hug all your friends~!
Huggernaut is a cute, colorful and challenging platformer which has you swing around with your hook in 23 levels.

Are you fast enough to get a star on every level? Well, if you are there's always the speedrun mode which let's you play through the entire game in one go with a timer. And if you're not... Then remember all that matters is that you enjoyed the attempt! ^^
If you follow the GMC jams, you might recognize this game from GMC Jam #6 (it was the winning entry), though it was called "HUGS" then. This version is greatly improved, with more than twice the level count, simplified controls, a speedrun mode, visual effects and other polish.
 

K12gamer

Member
Really good...currently on level 8...

What code did you use to keep the aiming cursor inside your screen...
On most browser games...the cursor (mouse pointer) will wander off the edges...making the onscreen character lose function.
 

Nallebeorn

Member
Really good...currently on level 8...

What code did you use to keep the aiming cursor inside your screen...
On most browser games...the cursor (mouse pointer) will wander off the edges...making the onscreen character lose function.
I made a simple JavaScript extension that uses the Pointer Lock API. I should probably upload this as an asset somewhere, but this is the full source code, < 50 lines of JS:
Code:
var enabled = false;

var canvas = document.getElementById("canvas");
canvas.requestPointerLock = canvas.requestPointerLock || canvas.mozRequestPointerLock || canvas.webkitRequestPointerLock;
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;

function lockChange()
{

}

canvas.addEventListener("click", function ()
{
    if (enabled)
        canvas.requestPointerLock();
});

if ("onpointerlockchange" in document)
{
    document.addEventListener("onpointerlockchange", lockChange);
}
else if ("mozonpointerlockchange" in document)
{
    document.addEventListener("mozonpointerlockchange", lockChange);
}
else if ("webkitonpointerlockchange" in document)
{
    document.addEventListener("webkitonpointerlockchange", lockChange);
}

document.addEventListener("mousemove", function (e)
{
    gml_Script_gmcallback_mousemove(null, null, e.movementX, e.movementY);
})

function pointerlock_is_locked()
{
    return document.pointerLockElement === canvas || document.mozPointerLockElement === canvas || document.webkitPointerLockElement === canvas;
}

function pointerlock_enable(enable)
{
    enabled = enable;
    if (!enable && pointerlock_is_locked())
    {
        document.exitPointerLock();
    }
}
Apart from this all you need is an extension that exposes pointerlock_is_locked() and pointerlock_enable(bool) to GM.
 

K12gamer

Member
I made a simple JavaScript extension that uses the Pointer Lock API. I should probably upload this as an asset somewhere, but this is the full source code, < 50 lines of JS:
Code:
var enabled = false;

var canvas = document.getElementById("canvas");
canvas.requestPointerLock = canvas.requestPointerLock || canvas.mozRequestPointerLock || canvas.webkitRequestPointerLock;
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;

function lockChange()
{

}

canvas.addEventListener("click", function ()
{
    if (enabled)
        canvas.requestPointerLock();
});

if ("onpointerlockchange" in document)
{
    document.addEventListener("onpointerlockchange", lockChange);
}
else if ("mozonpointerlockchange" in document)
{
    document.addEventListener("mozonpointerlockchange", lockChange);
}
else if ("webkitonpointerlockchange" in document)
{
    document.addEventListener("webkitonpointerlockchange", lockChange);
}

document.addEventListener("mousemove", function (e)
{
    gml_Script_gmcallback_mousemove(null, null, e.movementX, e.movementY);
})

function pointerlock_is_locked()
{
    return document.pointerLockElement === canvas || document.mozPointerLockElement === canvas || document.webkitPointerLockElement === canvas;
}

function pointerlock_enable(enable)
{
    enabled = enable;
    if (!enable && pointerlock_is_locked())
    {
        document.exitPointerLock();
    }
}
Apart from this all you need is an extension that exposes pointerlock_is_locked() and pointerlock_enable(bool) to GM.
Thanks...That's a lot of complicated stuff...I really need to go back to school and learn coding. :(
Or...GameMaker can give us a drag and drop icon for that function :)
Oh...and you should upload it as an asset...because I've never seen it in any online game.
 
Top