Skip navigation

Going live in a few minutes with Indie Sports Game Night 2! Tonight we are playing Eucloid, Robotag, Sportsball, and maybe others.

http://www.twitch.tv/gunonion

Come hang out!

http://www.twitch.tv/bitq/

GameCube_Analog_Stick[1]Here are a couple functions I wrote recently to improve my player movement. These are applicable to most 2d games.

The first is a wrapper around Polycode’s getJoystickAxisValue() function, which implements a gradient deadzone for analog sticks. This scales the speed of player movement by how far the analog stick is being tilted. It allows for more precise control and a better feeling for movement overall. TheĀ important bits are lines 11-13. This method is adapted from a Gamasutra post by Josh Sutphin.

function getScaledJoystickAxis(controllerIndex, stick)
        if Services.Core:getInput():getNumJoysticks() > controllerIndex then
                local retVal = Vector2(0, 0)
                if stick == JOY_LEFTSTICK then
                        retVal.x = Services.Core:getInput():getJoystickAxisValue(controllerIndex, JOY_LEFTSTICK_X)
                        retVal.y = Services.Core:getInput():getJoystickAxisValue(controllerIndex, JOY_LEFTSTICK_Y)
                elseif stick == JOY_RIGHTSTICK then
                        retVal.x = Services.Core:getInput():getJoystickAxisValue(controllerIndex, JOY_RIGHTSTICK_X)
                        retVal.y = Services.Core:getInput():getJoystickAxisValue(controllerIndex, JOY_RIGHTSTICK_Y)
                end
                if vMagnitude(retVal) > 0.23 then
                        return vNormalize(retVal, (vMagnitude(retVal) - 0.23) / 0.77)
                end
        end
        return Vector2(0, 0)
end

The second function modifies the player’s movement vector so that they cannot leave the boundaries of the arena, and is performed individually to each axis of movement. If their current velocity would move them past a boundary, they are instead moved the remaining distance to the boundary. This improves on the method most beginners use, in which movement is prevented altogether if it would result in a player being out of bounds.

function Player:clampMovementToArena(moveVect, pos, radius)
        local newMoveVect = Vector2(0,0)
 
        local leftWallDisp = arenaLeft - (pos.x - radius)
        local rightWallDisp = arenaRight - (pos.x + radius)
        local topWallDisp = arenaTop - (pos.y - radius)
        local bottomWallDisp = arenaBottom - (pos.y + radius)
 
        newMoveVect.x = math.max(moveVect.x, leftWallDisp)
        newMoveVect.x = math.min(newMoveVect.x, rightWallDisp)
        newMoveVect.y = math.max(moveVect.y, topWallDisp)
        newMoveVect.y = math.min(newMoveVect.y, bottomWallDisp)
 
        return newMoveVect
end

This is simple stuff, but it’s not always obvious to programmers new to game development. Feel free to adapt this for your own use, or, if you are using Polycode, copy it directly. I am trying to keep all code that is non-specific to Eucloid separate, and I’ll probably post it later on for other Polycode users to enjoy.

Coming Soon….

Image

Image

I made this wordpress account ages ago and never really used it. Now the time has come! I will be posting regular dev log updates here for Eucloid, Football II, and any other games I am making. I’ll also post the occasional scholarly article about competitive multiplayer game design and theory. I might also do some analyses of fighting game matches I find interesting, specifically Ultimate Marvel vs. Capcom 3. I will try to keep the random thoughts to a minimum so this blog doesn’t read like a Twitter feed (I have one of those already twitter.com/bitq_).

Also, here is a cute animal I found on my hard drive:

Image

See you all soon!

After finding my MvC3 case empty (the disc is in my xbox at home), I popped in Halo instead. I now rejoice in the fact that I am without Marvel. The input lag on the TV here makes Halo unplayable, and I’m sure Marvel would be worse. I played one game of Team Arena, and, as often is the case, all my teammates quit. I stuck around in fear of the supposedly drastic penalty for leaving arena games. My rating at the end of the game: 450. I got two kills. Yes, the other team was spawn-trapping me, but they sucked besides that. My downfall was the ~50ms lag between what was happening in the game and what the screen displayed. Guh… Am I spoiled, or are video games painful on anything but an EVO monitor?

Alan Wake review
Black Swan review
Drillbot hook
Textbook DRM rant
Yomi review
Halo: Reach multiplayer design analysis
???

Follow

Get every new post delivered to your Inbox.