aboutsummaryrefslogtreecommitdiff
path: root/musicplayer/objects_music.lua
blob: ea3705bffb4656eb6a6aa37affc7d4094a89bebb (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
obj = {}
gt = 0 -- game time
ft = 1/60 --frametime
scrollspeed = 0
menushipscroll = 0
acidcounter = 0
hideui = false
autoplay = false
autoplaytimer = 90
tracknumber = 0
currentsong = -1
fadeouttimer = 1
tracktitleposition = -200
newtracktitleposition = 0
cartdata("toxicinvaderssoundtrack_by1029chris")

function playsong(song, fade)
    fade = fade or 0
    if song ~= currentsong then
        music(song, fade)
        currentsong = song
    end
end

function fadeoutsong()
    fadeouttimer = 1
    playsong(-1,1000) --fades out currentsong
end

function selectmusic()
    if tracknumber == -1 then
        tracknumber = 0
    elseif tracknumber == 0 then
        playsong(-1,0)
    elseif tracknumber == 1 then
        playsong(0)
    elseif tracknumber == 2 then
        playsong(8)
    elseif tracknumber == 3 then
        playsong(17)
    elseif tracknumber == 4 then
        playsong(-1,0)
    end
end

function updatetracktitlepos()
    if tracknumber == 0 then
        newtracktitleposition = -16
    elseif tracknumber == 1 then
        newtracktitleposition = 145
    elseif tracknumber == 2 then
        newtracktitleposition = 313
    elseif tracknumber == 3 then
        newtracktitleposition = 493
    elseif tracknumber == 4 then
        newtracktitleposition = 685
    end
end

function updateobjs()
    foreach(obj, function(obj) obj:update() end)
end

function drawobjs()
    foreach(obj, function(obj) obj:draw() end)
end

function lerp(start, destination, amount)
    return start + amount * (destination - start);
end