|
Post by leon26leon26 on Dec 2, 2016 23:42:48 GMT
Make a game As Fast As Possible.
Rules: -Only simple games, like Snake, Pong, etc. -Include your time in your post.
Please, put your scripts in spoilers.
|
|
|
Post by leon26leon26 on Dec 2, 2016 23:43:55 GMT
My game: Snake Time: 50 minutes --[[ Snake
made in 50 minutes by leon26leon26 ]] --Settings: dispsize={x=10,y=15} --size of the field in pixels pos={x=1,y=1} --starting position in pixels speed=150 --delay between frames -------------------------------- function drawPixel(x,y,color) draw.fillrect(xdim/size.x*x,ydim/size.y*y,xdim/size.x*(x+1),ydim/size.y*(y+1),color) end
function init() draw.setscreen(2) draw.showtitle(false) xdim,ydim=draw.getport() if xdim<ydim then size={x=dispsize.x,y=dispsize.y} else size={x=dispsize.y,y=dispsize.x} end history={} length=1 vel={x=1,y=0} food={x=math.random(size.x-1),y=math.random(size.y-1)} function draw.touchbegan(t) tbeg={x=t[1].x,y=t[1].y} end function draw.touchended(t) tend={x=t[1].x,y=t[1].y} local tdiff={x=tbeg.x-tend.x,y=tbeg.y-tend.y} if math.abs(tdiff.x)>math.abs(tdiff.y) then vel=tdiff.x > 0 and {x=-1,y=0} or {x=1,y=0} else vel=tdiff.y > 0 and {x=0,y=-1} or {x=0,y=1} end end end
function drawAll() draw.beginframe() draw.clear(draw.black) for i=1,length do drawPixel(history[i].x, history[i].y,draw.gray) end drawPixel(pos.x,pos.y,draw.white) drawPixel(food.x,food.y,draw.red) draw.endframe() end
function moveAll() table.insert(history,1,{x=pos.x,y=pos.y}) pos.x=pos.x+vel.x pos.y=pos.y+vel.y if pos.x<1 then gameover=true end if pos.x>size.x-1 then gameover=true end if pos.y<1 then gameover=true end if pos.y>size.y-1 then gameover=true end if pos.x==food.x and pos.y==food.y then length=length+1 food={x=math.random(size.x-1),y=math.random(size.y-1)} end for i=1, length do if pos.x==history[i].x and pos.y==history[i].y then gameover=true end end end
init() while not gameover do moveAll() drawAll() sleep(speed) draw.doevents() end
sys.clear() sys.cprintln("You died!",draw.red) sys.cprintln("Final Score: "..length,draw.black)[/spoiler]
|
|
|
Post by warspyking on Dec 3, 2016 1:24:29 GMT
Why simple? What if I want to make an MMORPG in 5 minutes XD
|
|
|
Post by leon26leon26 on Dec 3, 2016 8:01:11 GMT
Why simple? What if I want to make an MMORPG in 5 minutes XD because I want to see crazy quick times. (Not that you're not capable of doing that MMORPG in 5mins.(timetravel is cheating btw.))
|
|