aboutsummaryrefslogtreecommitdiff
path: root/bullets.lua
blob: b7b113d208236c012b970bad3a081b3164f25aea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
bullets = {}

function addbullet(x, y, velx, vely, evil)
    local bullet = {}

    bullet.type = "bullet"
    bullet.x = x
    bullet.y = y
    bullet.velx = velx
    bullet.vely = vely

    function bullet.draw(bullet)
        spr(6, bullet.x, bullet.y)
    end

    function bullet.update(bullet)
        bullet.x += bullet.velx
        bullet.y += bullet.vely
        if bullet.y > 128 or bullet.y < -8 or bullet.x > 128 or bullet.x < -8 then
            del(obj, bullet)
        end
    end

    add(obj, bullet)
    add(bullet, #obj)
end