For those of you who are not satisfied with GravT because "it's not a game", here's a true game for you.  Objective: Find (and land on) the blue planet without crashing into any of the other planets.  Only one planet exerts gravity at a time; select this planet with your mouse.  By doing this, you can gravitationally slingshot yourself in the right direction.

Here's the code (exactly 560 chars):

b={}x=96
y=24
j=1
k=0
g=1
for i=0,61,1 do table.insert(b,{math.random(-500,500),math.random(-500,500)}) end
function d(q,w,e,r) return math.sqrt((q-e)*(q-e)+(w-r)*(w-r)) end
function TIC()cls(0)y=y+k
x=x+j
l,m=mouse()rect(118,60,2,2,15)for i,z in pairs(b) do
if d(l,m,z[1]-x+118,z[2]-y+60)<10 then g=i-1 end
if d(x,y,z[1],z[2])<10 then reset()end
if i==g+1 then circ(z[1]-x+118,z[2]-y+60,10,5)j=j+(z[1]-x)/math.pow(d(x,y,z[1],z[2]),2)k=k+(z[2]-y)/math.pow(d(x,y,z[1],z[2]),2)else circ(z[1]-x+118,z[2]-y+60,10,15*(i>1 and 1 or 0)+2*(i<2 and 1 or 0))end
end
end


Download

Download
gravgame.tic 3 MB

Leave a comment

Log in with itch.io to leave a comment.