Skip to content

Instantly share code, notes, and snippets.

@iTarum
Created November 17, 2011 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iTarum/1374504 to your computer and use it in GitHub Desktop.
Save iTarum/1374504 to your computer and use it in GitHub Desktop.
Eat me
fx=0
fy=0
cx=WIDTH/2
cy=HEIGHT/2
cg=20
cdx=0
cdy=0
stx=.0
sty=.0
fst=.5
lev=1
eat=0
-- Use this function to perform your initial setup
function setup()
    print("Eat me")
    iwatch("eat")
    level(1)
end
-- This function gets called once every frame
function draw()
noSmooth()
    
    background(10,10,20)
    fill(0, 0, 0, 255)
    stroke(218, 27, 27, 255)
    strokeWidth(1)
if CurrentTouch.state==BEGAN or CurrentTouch.state==MOVING then
    fx=CurrentTouch.x
    fy=CurrentTouch.y
    if fx<cx then cdx = cdx + fst end
    if fx>cx then cdx = cdx - fst end
    if fy<cy then cdy = cdy + fst end
    if fy>cy then cdy = cdy - fst end
end
if cdx>0 then cdx = cdx - stx end
if cdx<0 then cdx = cdx + stx end
if cdy>0 then cdy = cdy - sty end
if cdy<0 then cdy = cdy + sty end
cx = cx + cdx
cy = cy + cdy
if cx+(cg/2)> WIDTH then
    cx=WIDTH-(cg/2)
    cdx=-cdx
end
if cx-(cg/2)<0 then
    cx=(cg/2)
    cdx=math.abs(cdx)
end
if cy+(cg/2)>WIDTH then
    cy=HEIGHT-(cg/2)
    cdy=-cdy
end
if cy-(cg/2)<0 then
    cy=(cg/2)
    cdy=math.abs(cdy)
end
strokeWidth(5)
    stroke(83, 255, 0, 255)
    ellipse(cx,cy,cg,cg)
if cdx<0 then
    tx=0
    for tx=0,(math.abs(cdx)*5) do
        ty=(math.abs(cdx)*5 )- tx
        if ty>cg/2 then ty=cg/2 end
        stroke(255, math.random(50,250),0,255)
        rect(cx+(cg/2)+(tx),cy+math.random(-ty,ty),2,2)
    end
end
if cdx>0 then
    tx=0
    for tx=0,cdx*5 do
        ty=(math.abs(cdx)*5 )- tx
        if ty>cg/2 then ty=cg/2 end
        stroke(255, math.random(50,250),0,255)
        rect(cx-(cg/2)-(tx),cy+math.random(-ty,ty),2,2)
    end
end
if cdy>0 then
    ty=0
    for tx=0,cdy*5 do
        ty=(math.abs(cdy)*5 )- tx
        if ty>cg/2 then ty=cg/2 end
        stroke(255, math.random(50,250),0,255)
        rect(cx+math.random(-ty,ty),cy-(cg/2)-(tx),2,2)
    end
end
if cdy<0 then
    ty=0
    for tx=0,(math.abs(cdy)*5) do
        ty=(math.abs(cdy)*5 )- tx
        if ty>cg/2 then ty=cg/2 end
        stroke(255, math.random(50,250),0,255)
        rect(cx+math.random(-ty,ty),cy+(cg/2)+(tx),2,2)
    end
end
strokeWidth(2)
    stroke(255, 0, 191, 255)
    ellipse(vx,vy,cg/2,cg/2)
    
    if cx-(cg/2)<vx and cx+(cg/2)>vx then
        if cy-(cg/2)<vy and cy+(cg/2)> vy then
            lev = lev + 1
            level(lev)
            cg = cg + 2
            eat = eat + 1
            cdx=0
            cdy=0
            sound("jump",100+lev)
        end
    end
end
function level(wert)
    
    vx=math.random(100,WIDTH-100)
    vy=math.random(100,HEIGHT-100)
    
    
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment