Back

Ludum Dare 25

The entry for my first Ludum Dare game jam.


This is the first game I made for the 25th Ludum Dare game jam. It is a very basic space shooter with a top-down view and a little story.

Additionally I recorded a timelapse during the weekend which is available here. There is also a post mortem post available on my blog.

What is Ludum Dare?

Ludum Dare is a regular accelerated game development Event. Participants develop games from scratch in a weekend, based on a theme suggested by the community.

Code snippets

function Shot:update()
    local moveX = math.cos(self.rotation + initialShipRotation) * speed * dt
    local moveY = math.sin(self.rotation + initialShipRotation) * speed * dt
    if self:isInBounds() then
        self.x = self.x + moveX
        self.y = self.y + moveY
    end
end

function Shot:isInBounds()
    local moveX = math.cos(self.rotation + initialShipRotation) * speed * dt
    local moveY = math.sin(self.rotation + initialShipRotation) * speed * dt
    return (self.x + moveX > 0) and (self.y + moveY > 0) and (self.x + moveX < width) and (self.y + moveY < height)
end

function Shot:checkCollision(freighter)
    local shot_x2 = self.x + imgWidth
    local shot_y2 = self.y + imgHeight
    local f_x2 = freighter.x + freighter.imgWidth
    local f_y2 = freighter.y + freighter.imgHeight

    return self.x < f_x2 and shot_x2 > freighter.x and
        self.y < f_y2 and shot_y2 > freighter.y
end

Projectile movement, bounds checking and collision detection for projectiles <-> enemies.


function Player:update(dt)
    --update rotation
    if love.keyboard.isDown('right', 'd') then
        rotation = rotation + math.pi * rotationSpeed
        rotation = self:lowRotation(rotation)
    end
    if love.keyboard.isDown('left', 'a') then
        rotation = rotation - math.pi * rotationSpeed
        rotation = self:lowRotation(rotation)
    end
    -- forward movement
    if love.keyboard.isDown('up', 'w') and self.slowdown then
        speed = 300
        --self:updateLocation(dt)
    end
    if love.keyboard.isDown('down', 's') then
        speed = -50

    end

    --update all shots
    for i,shot in ipairs(self.Shots) do
        shot:update()

        if not shot:isInBounds() then
            self:removeShot(i)
        end
    end

    shotTimer:update(dt)
    self:updateLocation(dt)
    self:slowdown(dt)
end

Player movement and projectile movement calls.

Download

No download available.

Ludum Dare 25 on GitHub/GitLab

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