I do not know what it is, so I'll leave

  • electronic_steve
    5th Aug 2014 Member 0 Permalink

    local screen = {} screen.width = 600 screen.height = 300 nodeList = {} nodeRadius = 2 numNodes = 50 dt=0.03 for i=1, numNodes do local node = {} node.x = math.random(screen.width) node.y = math.random(screen.height) local v = math.random(200) local th = math.random(2*math.pi) node.vx = v*math.cos(th) node.vy = v*math.sin(th) nodeList[i] = node end phyClock = {} phyClock.curTime = 0 springConstant = 75 maxDist = 120 curTime = 0 function newprintpixel(x,y,r,g,b) if x>0 and x0 and y< 184 then tpt.drawpixel( x,y) end end function update() curTime = curTime + dt while phyClock.curTime < dt do phyClock.curTime = phyClock.curTime + 0.01 for i=1, numNodes do local A = nodeList[i] for j=i+1, numNodes do local B = nodeList[j] local dx = (A.x-B.x) local dy = (A.y-B.y) local dist = dx^2 + dy^2 if dist < maxDist*maxDist then local ang = math.atan2(dy, dx) local falloff = 1-dist/(maxDist*maxDist) local F = springConstant*falloff A.vx = A.vx - F*math.cos(ang)*0.01 A.vy = A.vy - F*math.sin(ang)*0.01 B.vx = B.vx + F*math.cos(ang)*0.01 B.vy = B.vy + F*math.sin(ang)*0.01 end end end for i=1, numNodes do local node = nodeList[i] node.x = node.x + node.vx*0.01 node.y = node.y + node.vy*0.01 if node.x+nodeRadius < 0 then node.x = screen.width + nodeRadius elseif node.x-nodeRadius > screen.width then node.x = -nodeRadius end if node.y+nodeRadius < 0 then node.y = screen.height + nodeRadius elseif node.y-nodeRadius > screen.height then node.y = -nodeRadius end end end phyClock.curTime = phyClock.curTime - dt end function HSL(h, s, l, a) if s<=0 then return l,l,l,a end h, s, l = h/256*6, s/255, l/255 local c = (1-math.abs(2*l-1))*s local x = (1-math.abs(h%2-1))*c local m,r,g,b = (l-.5*c), 0,0,0 if h < 1 then r,g,b = c,x,0 elseif h < 2 then r,g,b = x,c,0 elseif h < 3 then r,g,b = 0,c,x elseif h < 4 then r,g,b = 0,x,c elseif h < 5 then r,g,b = x,0,c else r,g,b = c,0,x end return (r+m)*255,(g+m)*255,(b+m)*255,a end function draw() for i=1, numNodes do local node = nodeList[i] newprintpixel( node.x, node.y,0, 255, 255) for j=i+1, numNodes do local b = nodeList[j] local dist = (node.x-b.x)^2 + (node.y-b.y)^2 local falloff = math.max((1-dist/(maxDist*maxDist)), 0) if falloff > 0 then tpt.drawline (node.x, node.y, b.x, b.y,HSL((falloff*255+curTime*32)%255, 255, 128, falloff*255)) end end end end tpt.register_step(update) tpt.register_step(draw)

     

    buggy notepad++

     

     

    made substitute541

    Edited 4 times by electronic_steve. Last: 6th Aug 2014
  • fireball5000
    5th Aug 2014 Member 0 Permalink

    Wow, that is really cool!

    Edited once by fireball5000. Last: 5th Aug 2014
  • jacksonmj
    5th Aug 2014 Developer 6 Permalink

    Because I'm a suspicious person and therefore like to be able to read random scripts posted on the Powder Toy forum to check that they're not malicious, here's an indented version of it: http://pastebin.com/WFX5NWLj

     

    Also, this looks like it might be a version of https://love2d.org/forums/viewtopic.php?t=77616&p=165887#p165921 adapted to work in TPT (if something is based on someone else's work, it's nice to acknowledge the original author :P).

    Edited once by jacksonmj. Last: 5th Aug 2014
  • Sylvi
    5th Aug 2014 Moderator 1 Permalink

    @jacksonmj (View Post)

     TL;DR

    jacksonmj verified


    Looks neat! I'll try it out sometime.

  • QuentinADay
    6th Aug 2014 Member 0 Permalink

    Omg this is awesome!!! XD

  • electronic_steve
    6th Aug 2014 Member 0 Permalink

    @jacksonmj (View Post)

     I threw a link to the author. I would have thrown off an even sharper script. but I need someone who could adequately write a description. (Google translator can not handle  :c)

     porting scripts from Love 2d I still like it :D 

     

    I read that I gave Google and realized that I know English better than he is.

    Edited 2 times by electronic_steve. Last: 6th Aug 2014