Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local map = '<C><P L="2000" /><Z><S><S L="21" o="b0c6d1" H="399" X="11" Y="200" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="21" o="b0c6d1" X="1990" Y="200" T="12" H="399" /><S L="21" o="b0c6d1" X="1001" H="2000" Y="390" T="12" P="0,0,0.3,0.2,90,0,0,0" /></S><D /><O /></Z></C>'
- local taked = false
- local mice = {}
- local ball
- local haveTheBall
- function main()
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoTimeLeft(true)
- math.randomseed(os.time())
- tfm.exec.newGame(map)
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- ball = tfm.exec.addShamanObject(601, 1000, 100, 0, 0, 0, true)
- end
- function eventNewPlayer(name)
- local pos = {
- {1100, 300},
- {900, 300}
- }
- mice[name] = {
- haveBall = false
- }
- tfm.exec.movePlayer(name, pos[math.random(#pos)][1], pos[math.random(#pos)][2])
- for i=1,100 do
- tfm.exec.bindKeyboard(name, i, true, true)
- end
- end
- function eventKeyboard(name, key, down, mouseX, mouseY)
- if key == 32 then
- if not taked then
- if pythag(mouseX, mouseY, tfm.get.room.objectList[ball].x, tfm.get.room.objectList[ball].y, 40) and not mice[name].haveBall then
- particles(3, mouseX, mouseY)
- tfm.exec.removeObject(ball)
- haveTheBall = name
- mice[name].haveBall = true
- taked = true
- end
- else
- if name ~= haveTheBall then
- if pythag(mouseX, mouseY, tfm.get.room.playerList[haveTheBall].x, tfm.get.room.playerList[haveTheBall].y, 20) then
- mice[haveTheBall].haveBall = false
- taked = true
- mice[name].haveBall = true
- haveTheBall = name
- particles(3, mouseX, mouseY)
- end
- else
- ball = tfm.exec.addShamanObject(601, mouseX, mouseY, 5, 5, 0, true)
- mice[haveTheBall].haveBall = false
- particles(3, mouseX, mouseY)
- taked = false
- haveTheBall = nil
- end
- end
- end
- end
- function particles(id, x, y)
- for i=1,3 do
- tfm.exec.displayParticle(id, x, y, math.random(-3,3), -9, 0,math.random(8,15)/10, nil)
- end
- end
- function pythag(x1,y1,x2,y2,r)
- local x=x2-x1
- local y=y2-y1
- local r=r+r
- return x*x+y*y<r*r
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement