aboutsummaryrefslogtreecommitdiff
path: root/waves.lua
blob: 7be473534737abb337f6498890622d782ae72c14 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
wave = {} --store wave functions here
currentwave = 1 --THIS IS THE CURRENT WAVE
currentwavetime = 0
delaytimer = 0

wave[1] = {
    delay = 2,
    start = function()
        addbasicenemy(130, 60, rnd(basicenemysprites), 1, 0.15)
    end,
    ending = function()
    end,
    everysecond = function()
    end,
    conditions = function()
        if #enemies < 1 then
            return true
        else
            return false
        end
    end
}

wave[2] = {
    delay = 2,
    start = function()
        addbasicenemy(128, 30, rnd(basicenemysprites), 1, 0.4)
        addbasicenemy(128, 60, rnd(basicenemysprites), 1, 0.8)
        addbasicenemy(128, 90, rnd(basicenemysprites), 1, 0.4)
    end,
    ending = function()
    end,
    everysecond = function()
    end,
    conditions = function()
        if #enemies < 1 then
            return true
        else
            return false
        end
    end
}

wave[3] = {
    delay = 2,
    start = function()
        for i = 1, 7, 1 do
            addbasicenemy(128, i*16, rnd(basicenemysprites), 1, 0.5 + 0.075*i)
            addbasicenemy(170, i*16, rnd(basicenemysprites), 1, 1.05 - 0.075*i)
        end
    end,
    ending = function()
    end,
    everysecond = function()
    end,
    conditions = function()
        if #enemies < 1 then
            return true
        else
            return false
        end
    end
}

wave[currentwave].start()

function updatewaves()
    currentwavetime += 1/60
    if wave[currentwave].conditions() then
        delaytimer += 1/60
        if delaytimer > wave[currentwave].delay then
            wave[currentwave].ending()
            currentwave += 1
            currentwavetime = 0
            delaytimer = 0
            currentwave = (currentwave - 1) % #wave+1 --temporarily looping the waves
            wave[currentwave].start()
        end
    end
end