aboutsummaryrefslogtreecommitdiff
path: root/ui.lua
blob: 3a683b9600e46c7662792e65d6eab60b886d1e42 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
--adds zeros to score to look cooler
function scorewithzeros(string,length)
    if #string == length then return string end
    return "0"..scorewithzeros(string, length-1)
end

function printdropshadow(text,x,y,colorMain,colorShadow)
    print(text,x,y+1,colorShadow)
    print(text,x,y,colorMain)
end

function invaderslogotext(x,y)
    --default values
    -- x = 12
    -- y = 20

    --font
    local text = "I N V A D E R S"
    for i = 1, 12, 1 do
        print(text, x+i%3-1, y+i%4-1, 3)
    end
    print(text,x,y,14)
    clip(x, y, 63, 3)
    print(text,x,y,11)
    clip()

end

function drawlogo(x,y)
    --default values
    -- x = 24
    -- y = 26

    --this is a horrible way to draw the logo, but I'm doing it anyways. x3
    -- muahahahahahahaha!!!!!!
    sspr(88,88,16,8,x-3,y+2,32,16) --to shadow
    sspr(88,88,16,8,x-3,y,32,16) --to
    sspr(120,88,8,8,x+55,y+2,16,16) --ic shadow
    sspr(120,88,8,8,x+55,y,16,16) --ic
    --X
    sspr(104,88,8,8,x+26,y-9,16,16)
    sspr(104,88,8,8,x+42,y-9,16,16,true)
    sspr(112,88,8,8,x+26,y+7,16,16,true)
    sspr(112,88,8,8,x+42,y+7,16,16)
    --invaders
    invaderslogotext(x+11,y+20)
end

function mainmenutext(x,y)
    -- default values
    -- x = 24
    -- y = 62
    x -= 1

    spr(5,x+2,y+7+(sin(t()*0.7)*2),1,3) --ships
    printdropshadow("(\142) - lone wolf\n\n(\151) - companion",x+15,y+7,6,5)
end

function titlehighscores(x,y)
    -- default values
    -- 52
    -- 110
    
    printdropshadow(scorewithzeros(tostring(highscore0),4),x-10,y,12,15) --1P high score
    spr(48,x+8,y)
    printdropshadow(scorewithzeros(tostring(highscore1),4),x+18,y,9,2) --2P high score
end

function playerscore()
    if #players > 1 then
        printdropshadow(scorewithzeros(tostring(currentscore),4),2,121,9,4) --2P current score
    else
        printdropshadow(scorewithzeros(tostring(currentscore),4),2,2,12,15) --1P current score
    end
end

--shown on edge of screen (blue for solo - orange for coop)
function runningscore(currentscore,isflashing)
    if isflashing or gt < 2 then
        if flashtime == 1 then
            playerscore()
        end
    else
        playerscore()
    end
end

function credits(x,y)
    -- default vaues
    -- x = 10
    -- y = 100
    local sintime = sin(t())*2
    local timemod = (t()%2<1)

    palt(2,true)
    palt(0,false)
    spr(186,x-4,y+6+sintime,1,1,timemod) --duck
    spr(184,x+104,y+6+-sintime,1,1,timemod) --bot
    palt()
    printdropshadow("1029chris\nLUA TUNES",x+10,y+5,9,2)
    printdropshadow("ribboncable\nART  SOUNDS",x+56,y+5,12,15)
    -- printdropshadow("CODE TUNES",x+8,y+12,11,3)
    -- printdropshadow("ART SOUNDS",x+58,y+12,11,3)
end

--Ending screen
function finalscorescreen(x,y)
    local playercolour0 = 12
    local playercolour1 = 15

    printdropshadow("fINAL sCORE", x+41,y+22,6,5)
    if #players > 1 then
        playercolour0 = 9
        playercolour1 = 2
    end

    -- if #players > 1 and currentscore > highscore1 or #players == 1 and currentscore > highscore0 then
        if flashtime == 1 then
            printdropshadow("! new high score !", x+27,y+32,11,3)
            -- if babymode then
            --     printdropshadow("! BABYMODE !", x+40,y+70,9,2)
            -- end
        -- end
    end
    
    poke(0x5f58, 0x0 | 0x9 | 0x4) --makes score BIG
    printdropshadow(scorewithzeros(tostring(currentscore),4),x+48+circletimex,y+50+circletimey,playercolour0,playercolour1) --2P high score
    poke(0x5f58, 0)

    printdropshadow("  THANKS FOR PLAYING\nPRESS ❎ ⁙ πŸ…ΎοΈ TO RETRY", x+19,y+80,11,3)
    -- printdropshadow("PRESS ❎ ⁙ πŸ…ΎοΈ TO RETRY", x+18,y+88,11,3)

    printdropshadow("MADE WITH β™₯ IN VANCOUVER\n       β—† 2022 β—†", x+14,y+113,9,2)
    -- printdropshadow("β—† 2022 β—†", x+42,y+118,11,3)
end

--intro/ending acid effect
function acidtransition()
    if acidcounter < 3 then
        for i = 1, 128, 1 do
            line(i-1,128,i-1,sin((i+0.22-acidcounter*20)/24.357)*2+acidcounter*80-5,11) --cool wavy transition effect!!!!
            line(i-1,128,i-1,sin((i+acidcounter*60)/44.357)*5+acidcounter*80,3)
        end
        addcircle(rnd(128), acidcounter*80+5, 0,rnd(1),rnd(12)+2,1.5,14)
    end
end

--sfx for the intro transition
sfx(0,3,3)

--this creates menu items that allow players to turn off screenshake, or always fire the ships gun.
doshake = true
menuitem(1, "(\129) screenshake", function() doshake = not doshake end)
menuitem(2, "(\144) autofire", function() alwaysfire = not alwaysfire end)
-- menuitem(3, "(\137) BABYMODE", function() babymode = true end)