Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoNewGame()
- tfm.exec.newGame('<C><P /><Z><S><S c="4" L="3000" o="0" H="10" X="366" Y="197" T="13" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>')
- local point = {}
- point.__index = point
- local vertices = {}
- point1 = false
- id = 0
- area = 70
- local choosenPoints = {}
- function point.new(x, y, p)
- local options = {
- x = x,
- y = y,
- p = p or 13
- }
- local self = setmetatable(options, point)
- return self
- end
- function point:display()
- tfm.exec.displayParticle(self.p, self.x*area, self.y*area, 0, 0, 0, 0)
- end
- function desenhaTriangulo()
- vertices = {
- a = point.new(3, 1),
- b = point.new(7, 1),
- c = point.new(5, 4.46)
- }
- for k, pointV in pairs({"a", "b", "c"}) do
- if vertices[pointV] then
- ui.addTextArea(id, "<R>.", nil, vertices[pointV].x*area, vertices[pointV].y*area, nil, nil, 0, 0, 0, true)
- id = id+1
- else
- return
- end
- end
- end
- function sorteiaVertice()
- if not point1 then
- point1 = point.new(10, 5.46, 9)
- end
- local sort = math.random(1, 6)
- local vertice = ""
- if sort == 1 or sort == 2 then
- vertice = "a"
- elseif sort == 3 or sort == 4 then
- vertice = "b"
- else
- vertice = "c"
- end
- --stfm.exec.chatMessage(string.format("<BL>Vertice sorteada: %s", vertice:upper()))
- local point2 = vertices[vertice]
- local pointmedia = point.new((point1.x+point2.x)/2, (point1.y+point2.y)/2, 9)
- table.insert(choosenPoints, pointmedia)
- point1 = table.copy(pointmedia)
- ui.addTextArea(id, string.format("<font color='#%s'>.", string.format("%x", math.random(0x000000, 0xFFFFFF))), nil, point1.x*area, point1.y*area, nil, nil, 0, 0, 0, true)
- id = id+1
- end
- function table.copy(t)
- local t2 = {}
- for k, v in pairs(t) do
- t2[k] = v
- end
- return t2
- end
- function notifyLoop()
- local tick = 20
- s = 1000/tick
- for t = 0, 1000 - s, s do
- system.newTimer(function ()
- system.newTimer(loop, 1000, true)
- end, 1000 + t, false)
- end
- end
- function loop()
- sorteiaVertice()
- end
- desenhaTriangulo()
- notifyLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement