Advertisement
Fooksie

#solidity

May 26th, 2014
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. id=100
  2. def={}
  3. def[0]={width=1, height=1}
  4. def[1]={width=30, height=30}
  5. def[2]={width=60, height=60}
  6. def[3]={width=100, height=10}
  7. def[4]={width=200, height=10}
  8. def[6]={type=13, width=15, height=15}
  9. function eventLoop(time, remaining)
  10.     if remaining<500 then
  11.         local sx, sy=math.random(50, 1150), math.random(100, 400)
  12.         local fx, fy=math.fmod(sx+math.random(600, 800), 1200), math.random(100, 400)
  13.         tfm.exec.newGame(
  14.             "<C><P L='1200'/><Z><S><S L='100' H='10' X='"..sx.."' Y='"..sy.."'/></S>"..
  15.             "<D><T X='"..sx.."' Y='"..(sy-5).."'/><F X='"..fx.."' Y='"..fy.."'/></D><O/></Z></C>"
  16.             )
  17.         end
  18.     end
  19. function eventNewGame()
  20.     players=0
  21.     for name, player in pairs(tfm.get.room.playerList) do
  22.         players=players+1
  23.         end
  24.     end
  25. function eventPlayerLeft()
  26.     players=players-1
  27.     if players<=0 then
  28.         eventLoop(0, 0)
  29.         end
  30.     end
  31. eventPlayerWon=eventPlayerLeft
  32. eventPlayerDied=eventPlayerLeft
  33. function eventSummoningEnd(name, type, x, y, angle, xs, ys, data, other)
  34.     if def[type] then
  35.         id=id+2
  36.         local p=def[type]
  37.         tfm.exec.removeObject(data.id)
  38.         tfm.exec.addPhysicObject(id, x, y, {
  39.             type=p.type or 0,
  40.             width=p.width,
  41.             height=p.height,
  42.             foreground=not data.ghost,
  43.             friction=0.2,
  44.             restitution=0.1,
  45.             angle=angle,
  46.             color=0xffcc44,
  47.             miceCollision=not data.ghost,
  48.             groundCollision=true,
  49.             dynamic=false
  50.             })
  51.         if data.ghost then
  52.             angle=angle/180*math.pi
  53.             local d=p.width/2-p.height/2
  54.             local p1, p2=math.cos(angle)*d, math.sin(angle)*d
  55.             if p1==p2 then p2=p2+1 end
  56.             tfm.exec.addJoint(id+1, id, id, {
  57.                 type=0,
  58.                 point1=math.floor(x+p1)..","..math.floor(y+p2),
  59.                 point2=math.floor(x-p1)..","..math.floor(y-p2),
  60.                 line=p.height*(p.type==13 and 2 or 1),
  61.                 color=0x6A7495,
  62.                 alpha=0.6,
  63.                 foreground=true
  64.                 })
  65.             end
  66.         end
  67.     end
  68. tfm.exec.disableAutoNewGame(true)
  69. eventLoop(0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement