Back

PiDefender

My January entry for One Game A Month 2013.


Your solar system is under attack!

Your scout ship is directing your people’s only defense: A giant defensive cannon that can obliberate dozens of ships at once.

Try not to get hit by enemy fire while killing as many as possible.

Code snippets

function Cannon:update(dt, circleradius)
    self.circleRadius = circleradius

    -- Only update cannon direction when mouse is outside of circle and player is enabled

    if(mousePos:dist(winCenter) > self.circleRadius + Cannon.radius) and Player.enabled then
        self.angle = math.atan2(winCenter.y-mousePos.y, winCenter.x-mousePos.x) + math.pi - Cannon.circ/2
        --Also only allow shooting when mouse is outside of Circle

        Cannon.allowFire = true
    else
        Cannon.allowFire = false
    end

    for i,shot in ipairs(Cannon.cannonShots) do
        shot:update(dt)

        -- remove shot when out of bounds

        if not shot:isInBounds() then
            table.remove(Cannon.cannonShots, i)
        end
    end

    if Cannon.aoe ~= nil and Cannon.aoe.emitted then
        Cannon.aoe:update(dt)
        if not Cannon.aoe:isInBounds() then
            Cannon.aoe = nil
        end
    end

    if Cannon.aoeTimer == 0 then
        Cannon.aoeAllowed = true
        Cannon.aoeTimer = 30
    end

end

Cannon movement and Aoe handling.

Download

The fastest way to get the game running is to download the compiled .exe file below.

Download .exe

Other files

.love file for Windows, Mac OSX and Linux platforms

If you don't have Love2D installed, download it here and install it first. To run the game:

  • On Linux, use love /path/to/.love to run the game.
  • On Windows use love C:\path\to\.love or drag the .love file onto love.exe
  • On Mac use open -n -a love "/home/path/to/" or drag the .love file onto the Love.app application bundle

PiDefender on GitHub/GitLab

Download the latest source or clone/fork the project from source control.