-
-
Save iTarum/1362250 to your computer and use it in GitHub Desktop.
5 winns
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
panz=nil | |
minx={} | |
maxx={} | |
miny={} | |
maxy={} | |
panz={} | |
pfb={} | |
stx=WIDTH/21 | |
sty=HEIGHT/21 | |
pa=0 | |
dk=100 | |
tx=0 | |
ty=0 | |
aktp=1 | |
-- Use this function to perform your initial setup | |
function setup() | |
iparameter("dk",1,500) | |
iparameter("auto",0,1) | |
machgitter() | |
number(100,200,"123",10) | |
zeichnep() | |
end | |
-- This function gets called once every frame | |
function draw() | |
noSmooth() | |
background(0, 0, 0, 255) | |
strokeWidth(3) | |
-- machgitter() | |
zeichnep() | |
if auto==1 then | |
tx=math.random(1,20) | |
ty=math.random(1,20) | |
pruefepos(tx,ty,1) | |
end | |
zeichnefinger() | |
--number(100,200,"123",10) | |
end | |
function zeichnefinger() | |
if aktp==1 then | |
stroke(255, 0, 0, 255) | |
else | |
stroke(67, 255, 0, 255) | |
end | |
line(tx*stx,ty*sty,(tx*stx)+stx,ty*sty) | |
line((tx*stx)+stx,ty*sty,(tx*stx)+stx,(ty*sty)+sty) | |
line((tx*stx)+stx,(ty*sty)+sty,tx*stx,(ty*sty)+sty) | |
line(tx*stx,(ty*sty)+sty,tx*stx,ty*sty) | |
end | |
function zeichnep() | |
x=0 | |
y=0 | |
for x=1,20 do | |
for y=1,20 do | |
zeichnerec(x,y) | |
end | |
end | |
end | |
function zeichnerec(x,y) | |
pa=0 | |
if pfb[x][y]==1 then | |
fill(251, 8, 12, 255) | |
stroke(252, 6, 6, 255) | |
elseif pfb[x][y]==2 then | |
fill(80, 251, 9, 255) | |
stroke(104, 255, 0, 255) | |
else | |
fill(255, 255, 255, 255) | |
stroke(255, 255, 255, 255) | |
end | |
number(minx[x][y]+10,maxy[x][y]-10,(panz[x][y]),stx/4) | |
for pa=1, panz[x][y] do | |
rect(math.random(minx[x][y],maxx[x][y]),math.random(miny[x][y],maxy[x][y]),panz[x][y],panz[x][y]) | |
end | |
end | |
function machgitter() | |
x=0 | |
y=0 | |
stroke(179, 255, 0, 255) | |
fill(5, 255, 0, 255) | |
minx={} | |
maxx={} | |
miny={} | |
maxy={} | |
panz={} | |
pfb={} | |
for x=1,20 do | |
minx[x]={} | |
maxx[x]={} | |
miny[x]={} | |
maxy[x]={} | |
panz[x]={} | |
pfb[x]={} | |
for y=1,20 do | |
rect(x*stx,y*sty,stx,sty) | |
minx[x][y]=x*stx | |
maxx[x][y]=(x*stx)+stx | |
miny[x][y]=y*sty | |
maxy[x][y]=(y*sty)+sty | |
panz[x][y]=math.random(1,4) | |
--panz[x][y]=1 | |
pfb[x][y]=math.random(0,2) | |
end | |
end | |
end | |
function touched() | |
tx=math.ceil(CurrentTouch.x /stx)-1 | |
ty=math.ceil(CurrentTouch.y/sty) -1 | |
if tx<1 then tx=1 end | |
if ty<1 then ty= 1 end | |
if CurrentTouch.state==ENDED then | |
pruefepos(tx,ty,1) | |
end | |
end | |
function pruefepos(xx,yy,index) | |
if pfb[xx][yy]==aktp or pfb[xx][yy]==0 then | |
pfb[xx][yy]=aktp | |
sound("jump",234) | |
panz[xx][yy] = panz[xx][yy] + 1 | |
popStyle() | |
if panz[xx][yy]>4 then | |
explosion(xx,yy) | |
end | |
if index== 1 then naechsterp() end | |
else | |
--sound("blit",123) | |
end | |
end | |
function naechsterp() | |
aktp = aktp + 1 | |
if aktp >2 then aktp =1 end | |
end | |
function explosion(ax,ay) | |
sx=0 | |
sy=0 | |
pfb[ax][ay]=aktp | |
--loeschen() | |
sound("explode",123) | |
zeichnerec(ax,ay) | |
panz[ax][ay]=1 | |
sx=ax-1 | |
if sx>0 then | |
zeichneli(ax,ay,sx,ay) | |
pfb[sx][ay] = aktp | |
pruefepos(sx,ay,0) | |
end | |
sx=ax+1 | |
if sx<=20 then | |
zeichneli(ax,ay,sx,ay) | |
pfb[sx][ay] = aktp | |
pruefepos(sx,ay,0) | |
end | |
sy=ay-1 | |
if sy>0 then | |
zeichneli(ax,ay,ax,sy) | |
pfb[ax][sy]=aktp | |
pruefepos(ax,sy,0) | |
end | |
sy=ay+1 | |
if sy<=20 then | |
zeichneli(ax,ay,ax,sy) | |
pfb[ax][sy]=aktp | |
pruefepos(ax,sy,0) | |
end | |
end | |
function loeschen() | |
noSmooth() | |
fill(0, 0, 0, 0) | |
rect(0,0,WIDTH,HEIGHT) | |
noStroke() | |
end | |
function zeichneli(xv,yv,xb,yb) | |
stroke(255, 0, 235, 255) | |
strokeWidth(10) | |
line(xv*stx,yv*sty,xb*stx,yb*sty) | |
end | |
-- this i have it from breackoutgame | |
----------------------------------- | |
-- Functions for drawing numbers -- | |
----------------------------------- | |
-- Draw a number. x, y is top left | |
function number(x, y, n, w) | |
l = string.len(n) | |
for i = 1, l do | |
drawDigit(x + ((i - 1) * (w * 1.5)), y, string.sub(n, i, i), w) | |
end | |
end | |
-- Draw a single digit | |
function drawDigit(x, y, n, w) | |
h = 2 * w | |
if string.match(n, "1") then | |
line(x + (w / 2), y, x + (w / 2), y - h) | |
elseif string.match(n, "2") then | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - (h / 2)) | |
line(x + w, y - (h / 2), x, y - (h / 2)) | |
line(x, y - (h / 2), x, y - h) | |
line(x, y - h, x + w, y - h) | |
elseif string.match(n, "3") then | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - h) | |
line(x + w, y - h, x, y - h) | |
line(x, y - (h / 2), x + w, y - (h / 2)) | |
elseif string.match(n, "4") then | |
line(x, y, x, y - (h / 2)) | |
line(x, y - (h / 2), x + w, y - (h / 2)) | |
line(x + w, y, x + w, y - h) | |
elseif string.match(n, "5") then | |
line(x + w, y, x, y) | |
line(x, y, x, y - (h / 2)) | |
line(x, y - (h / 2), x + w, y - (h / 2)) | |
line(x + w, y - (h / 2), x + w, y - h) | |
line(x + w, y - h, x, y - h) | |
elseif string.match(n, "6") then | |
line(x + w, y, x, y) | |
line(x, y, x, y - h) | |
line(x, y - h, x + w, y - h) | |
line(x + w, y - h, x + w, y - (h / 2)) | |
line(x + w, y - (h / 2), x, y - (h / 2)) | |
elseif string.match(n, "7") then | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - h) | |
elseif string.match(n, "8") then | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - h) | |
line(x + w, y - h, x, y - h) | |
line(x, y - h, x, y) | |
line(x, y - (h / 2), x + w, y - (h / 2)) | |
elseif string.match(n, "9") then | |
line(x + w, y - (h / 2), x, y - (h / 2)) | |
line(x, y - (h / 2), x, y) | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - h) | |
line(x + w, y - h, x, y - h) | |
elseif string.match(n, "0") then | |
line(x, y, x + w, y) | |
line(x + w, y, x + w, y - h) | |
line(x + w, y - h, x, y - h) | |
line(x, y - h, x, y) | |
elseif string.match(n, "x") then | |
line(x, y - (w / 3), x + w, y - (h + 1)) | |
line(x + w, y - (w / 3), x, y - (h + 1)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment