Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I de-obfuscated my code for Putt, in case anybody is interested. Planning to make this into a proper lil PicoPutt game, but gonna need to spend a LOT of time polishing it.

function _init()
    spawn_level()
end

function _update()
    move_player()
end

function _draw()
cls()
    draw_bg()
    collision()
    draw_player()
end

-- levelgen

function spawn_level()
    grass={}
    sand={}
 for i=1,5 do
     j=14+i*16
     k=50+rnd(35)
     q=17+rnd(10)
-- make grass and sand
     add(grass,{x=j,y=k,r=q})
     if i>1 and
                 i<5 then
         add(sand,{x=j+rnd(q)-q/2,y=k+rnd(q)-q/2,r=8})
     end
-- make player and hole
     if i==1 then
            p={x=j-q/2,y=k,a=0,xd=0,yd=4,p=1,v=0}
     elseif i==5 then
            h={x=j+q/2,y=k}
     end
 end
end

-- draw functions

function draw_bg()
    for v in all(grass) do
     circfill(v.x,v.y,v.r,11)
 end
 for v in all(sand) do
     circfill(v.x,v.y,v.r,4)
 end
-- hole
 circfill(h.x,h.y,2,0)
--    power bar
 circfill(64,8,5,7)
 print(p.p,63,6,0) end

-- player

function draw_player()
 circfill(p.x,p.y,2,7)
 circfill(p.x+p.xd,p.y+p.yd,0)
end

function move_player()
-- set angle of shot
 if btnp(5) then
     if p.a<6.28 then
         p.a+=.1 else p.a=0
     end
     p.xd=sin(p.a)*4
     p.yd=cos(p.a)*4
 end
-- set shot power
    if btnp(2) then
        if p.p<5 then
            p.p+=1 else
            p.p=1
        end
    end
-- shoot
    if btnp(4) then
        p.v=p.p
    end
-- move ball, apply deceleration
 p.x+=p.v*p.xd
 p.y+=p.v*p.yd
 p.v*=.7
end

function collision()
-- hole/border pixel collision
 if pget(p.x,p.y)==0 then
  _init()
 end
-- sand trap collision
    if pget(p.x,p.y)==4 then
        p.v/=3
    end
end