Last active
January 17, 2017 21:20
-
-
Save davisdude/9ccaeba99e88cf7760b2308c3cbcb969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l,m=love,math g,f,s,b,x,o,no,p=l.graphics,m.floor,20,' ',0,0,0,{'^ppp','^...ppp','ppp$','p..p..p','p...p...p','^..p.p.p'}P,z=g.print,{b,b,b,b,b,b,b,b,b}l.window.setMode(800,600,{resizable=1})function e(c)for i=1,6 do i=p[i]:gsub('p',c)if v:find(i)then return c end end return not v:find' 'and'no'end function l.draw()w,h=g.getDimensions()d,v=m.min(w/80,h/80),''g.setFontNewFont(12*d)for i=1,9 do P(z[i],((i-1)%3*s+6)*d,((m.ceil(i/3)-1)*s+5)*d)v=v..z[i]end O=e'x'or e'o'if O then _G[O]=_G[O]+(not c and 1 or 0)P(O..' won x:'..x..' o:'..o,0,60*d)c=true end P(not t and'x'or'o',70*d,0)g.scale(d)g.line(0,s,3*s,s)g.line(0,2*s,3*s,2*s)g.line(s,0,s,3*s)g.line(2*s,0,2*s,3*s)end function l.mousepressed(x,y)if not O then x,y=f(x/d/s),f(y/d/s)if x<3 and y<3 then i=y*3+x+1 if z[i]==' 'then z[i],t=not t and'x'or'o',not t end end else z,t,c={b,b,b,b,b,b,b,b,b}end end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l,m=love,math | |
g,f,s,b,x,o,no,p=l.graphics,m.floor,20,' ',0,0,0,{'^ppp', '^...ppp', 'ppp$','p..p..p','p...p...p','^..p.p.p'} | |
P,z=g.print,{b,b,b,b,b,b,b,b,b} | |
l.window.setMode(800,600,{resizable=1}) | |
function e(c) for i=1,6 do i=p[i]:gsub('p',c)if v:find(i)then return c end end return not v:find' 'and'no'end | |
function l.draw() | |
w,h=g.getDimensions() | |
d,v=m.min(w/80,h/80),'' | |
g.setNewFont(12*d) | |
for i=1,9 do P(z[i],((i-1)%3*s+6)*d,((m.ceil(i/3)-1)*s+5)*d) v=v..z[i]end | |
O=e'x'or e'o' | |
if O then _G[O]=_G[O]+(not c and 1 or 0) P(O..' won x:'..x..' o:'..o,0,60*d)c=true end | |
P(not t and'x'or'o',70*d,0) | |
g.scale(d) | |
g.line(0,s,3*s,s) | |
g.line(0,2*s,3*s,2*s) | |
g.line(s,0,s,3*s) | |
g.line(2*s,0,2*s,3*s) | |
end | |
function l.mousepressed(x,y) | |
if not O then | |
x,y=f(x/d/s),f(y/d/s) | |
if x<3 and y<3 then | |
i=y*3+x+1 | |
if z[i]==' 'then | |
z[i],t=not t and'x'or'o',not t | |
end | |
end | |
else z,t,c={b,b,b,b,b,b,b,b,b}end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment