aboutsummaryrefslogtreecommitdiff
path: root/viewer.lua
blob: 890979a8105a8e96beda4071929a150cb638445e (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
function drawDocuments()
  drawDownBox(8, 31, win[10].w-17, win[10].h-40, 4)
  love.graphics.setColor(256,256,256)
  love.graphics.rectangle("fill", 8, 31, win[10].w-17, win[10].h-40)
  love.graphics.setFont(pixeloperators)
  love.graphics.setColor(colors.font.dark)
  love.graphics.printf(doc.doc, 8+30, 31+30, win[10].w-17-60, "left")
  love.graphics.setFont(pressstart)
end
function drawPicture()
  drawDownBox(8, 31, win[7].w-17, win[7].h-40, 4)
  if picture.img ~= 0 then
    love.graphics.draw(picture.img, 8, 31)
  end
end
function drawVideo()
  drawDownBox(8, 31, win[8].w-16, win[8].h-82, 4)
  love.graphics.setColor(20,20,20)
  love.graphics.rectangle("fill",8,31,win[8].w-16,win[8].h-82)
  drawControls(8+38,win[8].h-34-8,8)
  if vplay.v ~= 0 then
    love.graphics.draw(vplay.v,8,31)
  end
  drawDownBox(10+38+38+38+150,win[8].h-34+5,118,5,2)
  drawUpBox(vplay.volx,vplay.voly,10,25,2)
end
function drawMusic()
  drawDownBox(8,31,win[9].w-17,win[9].h-82,4)
  love.graphics.setColor(20,20,20)
  love.graphics.rectangle("fill",8,31,win[9].w-17,win[9].h-82)
  drawControls(8+38,win[9].h-34-8,9)
  drawDownBox(10+38+38+38,win[9].h-34+5,118,5,2)
  drawUpBox(mplay.volx,mplay.voly,10,25,2)
  love.graphics.setColor(0,256,0)
  love.graphics.setFont(pixeloperators)
  love.graphics.print(mplay.title, 10,82)
  if mplay.p == true then
    for i=1,10 do
      if mplay.bar[i] == nil then
        mplay.bar[i] = {}
        mplay.bar[i].h = 20
        mplay.bar[i].ht = 20
      else
        if mplay.bar[i].h > mplay.bar[i].ht then
          if mplay.bar[i].h - (1*sys.s) < mplay.bar[i].ht then
            mplay.bar[i].h = mplay.bar[i].ht
          else
            mplay.bar[i].h = mplay.bar[i].h - (1*sys.s)
          end
        elseif mplay.bar[i].h < mplay.bar[i].ht then
          if mplay.bar[i].h + (1*sys.s) > mplay.bar[i].ht then
            mplay.bar[i].h = mplay.bar[i].ht
          else
            mplay.bar[i].h = mplay.bar[i].h + (1*sys.s)
          end
        elseif math.floor(mplay.bar[i].h) == mplay.bar[i].ht then
          mplay.bar[i].ht = math.random(0,40)
        end
        love.graphics.rectangle("fill",(23*i)-13,33,21,mplay.bar[i].h)
      end
    end
  end
  love.graphics.setFont(pressstart)
end
function drawControls(x,y,id)
  love.graphics.setColor(256,256,256)
  drawUpBox(x,y,32,32,2)
  if id == 9 then
    love.graphics.draw(but.but,x,y)
  elseif id == 8 and vplay.p == true then
    love.graphics.draw(but.pause,x,y)
  elseif id == 8 and vplay.p == false then
    love.graphics.draw(but.play,x,y)
  end
  drawUpBox(x+38,y,32,32,2)
  love.graphics.draw(but.stop, x+38, y)
  drawUpBox(x-38,y,32,32,2)
  love.graphics.draw(but.back, x-38, y)
end
function updateVideo()
  if vplay.p == true and vplay.v ~= 0 then
    vplay.v:play()
    win[8].update = true
  end
  if win[8].ex == true and vplay.v ~= 0 then
    vplay.v:seek(0)
    vplay.v:pause()
    vplay.v = 0
  end
  if mouseClick(win[8].x+8+38,win[8].y+win[8].h-34-8,32,32) == true and vplay.v ~= 0 and vplay.pr == false then
    if vplay.p == true then
      vplay.v:pause()
      vplay.p = false
      win[8].update = true
    elseif vplay.p == false then
      vplay.p = true
      win[8].update = true
      vplay.v:play()
    end
    vplay.pr = true
  elseif mouseClick(win[8].x+8+38-38,win[8].y+win[8].h-34-8,32,32) == true and vplay.v ~= 0 and vplay.pr == false then
    vplay.v:rewind()
    vplay.p = true
    win[8].update = true
    vplay.pr = true
  elseif mouseClick(win[8].x+8+38+38,win[8].y+win[8].h-34-8,32,32) == true and vplay.v ~= 0 and vplay.pr == false then
    vplay.v:seek(0)
    vplay.v:pause()
    vplay.p = false
    win[8].update = true
    vplay.pr = true
  end
  if mouseClick(win[8].x+vplay.volx,win[8].y+vplay.voly,10,25) == true and layer[1] == 8 then
    vplay.drag = true
  end
  if vplay.v ~= 0 then
    local d = vplay.volx - vplay.volxmin
    local v = 0.00806451612903226 * d
    vplay.v:getSource():setVolume(v)
  end
  if vplay.drag == true then
    if vplay.volpx + (sys.mouse.x - sys.mouse.p.x) <= vplay.volxmax
    and vplay.volpx + (sys.mouse.x - sys.mouse.p.x) >= vplay.volxmin then
      vplay.volx = vplay.volpx + (sys.mouse.x - sys.mouse.p.x)
    elseif vplay.volpx + (sys.mouse.x - sys.mouse.p.x) > vplay.volxmax then
      vplay.volx = vplay.volxmax
    elseif mplay.volpx + (sys.mouse.x - sys.mouse.p.x) < vplay.volxmin then
      vplay.volx = vplay.volxmin
    end
    win[8].update = true
  else
    vplay.volpx = vplay.volx
  end
end
function updateMusic()
  if mouseClick(win[9].x+8+38,win[9].y+win[9].h-34-8,32,32) == true and mplay.m ~= 0 and mplay.pr == false then
    if but.but == but.pause then
      mplay.m:pause()
      mplay.p = false
      but.but = but.play
      win[9].update = true
    elseif but.but == but.play then
      mplay.p = true
      but.but = but.pause
      win[9].update = true
    end
    mplay.pr = true
  elseif mouseClick(win[9].x+8+38-38,win[9].y+win[9].h-34-8,32,32) == true and mplay.m ~= 0 and mplay.pr == false then
    mplay.m:rewind()
    mplay.p = true
    but.but = but.pause
    win[9].update = true
    mplay.pr = true
  elseif mouseClick(win[9].x+8+38+38,win[9].y+win[9].h-34-8,32,32) == true and mplay.m ~= 0 and mplay.pr == false then
    mplay.m:stop()
    mplay.p = false
    but.but = but.play
    win[9].update = true
    mplay.pr = true
  end
  if mplay.p == true and mplay.m ~= 0 then
    win[9].update = true
    mplay.m:play()
  end
  if win[9].ex == true and mplay.m ~= 0 then
    mplay.m:stop()
    mplay.m = 0
  end
  if mplay.m ~= 0 then
    local d = mplay.volx - mplay.volxmin
    local v = 0.00806451612903226 * d
    mplay.m:setVolume(v)
  end
  if mouseClick(win[9].x+mplay.volx,win[9].y+mplay.voly,10,25) == true and layer[1] == 9 then
    mplay.drag = true
  end
  if mplay.drag == true then
    if mplay.volpx + (sys.mouse.x - sys.mouse.p.x) <= mplay.volxmax
    and mplay.volpx + (sys.mouse.x - sys.mouse.p.x) >= mplay.volxmin then
      mplay.volx = mplay.volpx + (sys.mouse.x - sys.mouse.p.x)
    elseif mplay.volpx + (sys.mouse.x - sys.mouse.p.x) > mplay.volxmax then
      mplay.volx = mplay.volxmax
    elseif mplay.volpx + (sys.mouse.x - sys.mouse.p.x) < mplay.volxmin then
      mplay.volx = mplay.volxmin
    end
    win[9].update = true
  else
    mplay.volpx = mplay.volx
  end
end
function loadDocuments()
  doc.help = "This game functions like a parody of the Windows 98 operating system, with " ..
  "similarly styled programs and such. Using your antivirus, you fend off " ..
  "different computer viruses whose sole purpose is to destroy your computer. If you can't beat them in time, you lose! " ..
  "To control the antivirus, you drag it around " ..
  "like you would a window on your computer, and press the fire button to shoot " ..
  "your enemies! The health bar on the bottom indicates the viruses health, and the timer " ..
  "displays how much time is left. A difficulty setting is present in the settings menu, " ..
  "if you are finding it too challenging/easy. To activate the fight, follow the instructions from " ..
  "your best friend, in the chat window. Good luck, and have fun!"
  doc.credits = [[Created By
  Chris B.

  Created With
  Love2D, Blender, GIMP, Audacity, and Atom

  Music
  ‘Thrills And Spills’ By Jay Man - OurMusicBox
  ‘Storm Chasers’ By Silent Partner

  Sound Effects
  Freesound.org and the Youtube Audio Library]]
end