-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
55 lines (49 loc) · 1.11 KB
/
main.lua
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
-- Bad Apple!! (128x96, 10fps, 2192f, compressed with zlib)
-- Video file by Leo
local X,Y,K
function love.resize(w,h)
local W,H=w,h
if H/W>=96/128 then
K=W/128
X,Y=0,(H-W*96/128)*.5
else
K=H/96
X,Y=(W-H*128/96)*.5,0
end
end
function love.run()
local gc=love.graphics
local floor=math.floor
local bAnd,bRshift=bit.band,bit.rshift
local video=love.data.decompress("string","zlib",love.filesystem.read("badapple.dat"))
local f=0
love.resize(gc.getWidth(),gc.getHeight())
return function()
local now=love.timer.getTime()
love.event.pump()
for N,w,h in love.event.poll()do
if N=="quit"then
return true
elseif N=="resize"then
love.resize(w,h)
end
end
f=(f+1)%13146
if not love.window.isMinimized()then
gc.origin()gc.clear()gc.translate(X,Y)gc.scale(K)
local t1=1536*floor(f/6)+1
for i=0,1535 do
local B=video:byte(t1+i)
for j=7,0,-1 do
local p=8*i+j
if bAnd(B,1)==0 then
gc.rectangle("fill",p%128,floor(p/128),1,1)
end
B=bRshift(B,1)
end
end
gc.present()gc.discard()
end
love.timer.sleep(1/60-(love.timer.getTime()-now))
end
end