Lua transformice
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.


Divulge seus mini games, compartilhe seus scripts e sources
 
InícioÚltimas imagensProcurarRegistarEntrar
1

 

 Labirinto- Ache o Queijo!

Ir para baixo 
AutorMensagem
Admin
Admin
Admin


Mensagens : 13
Pontuação : 3946
Data de inscrição : 08/10/2013
Idade : 37
Localização : Blumenau - Sc

Labirinto- Ache o Queijo! Empty
MensagemAssunto: Labirinto- Ache o Queijo!   Labirinto- Ache o Queijo! EmptySex Mar 27, 2015 7:56 pm

Código:
tfm.exec.disableAutoShaman(true)
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAfkDeath(true)

place = 0

function init_matrix(wD, hG)
  local result = {}
  for y = 0, hG - 1 do
     for x = 0, wD - 1 do
        result[y * wD + x] = 1
     end
     result[y * wD + 0] = 0
     result[y * wD + wD - 1] = 0
  end
  for x = 0, wD - 1 do
     result[0 * wD + x] = 0
     result[(hG - 1) * wD + x] = 0
  end
  return result
end

function setMap(matrix, wD, hG)
place = 0
xml = '<C><P H="740" Ca="" N="" L="2200" /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" X="1201" L="2500" o="0" H="760" c="4" Y="367" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" L="2200" o="0" H="40" X="1100" N="" Y="0" T="12" /><S P="0,0,0.3,0.2,0,0,0,0" L="2240" o="0" H="40" X="1100" N="" Y="760" T="12" /><S P="0,0,0.3,0.2,90,0,0,0" L="760" o="0" H="40" X="2200" N="" Y="360" T="12" /><S m="" P="0,0,0.3,0.2,90,0,0,0" L="760" o="0" H="40" X="0" N="" Y="360" T="12" />'
xmlEnd = '</S><D><DS Y="40" X="80" /><T X="2082" Y="735" D="" /><F Y="732" X="2080" /></D><O /></Z></C>'
color = string.format("%X", math.random(0x000000, 0xFFFFFF))
invColor = string.format("%06x", 0xffffff - tonumber(color, 16))
for y = 0, hG - 1 do
     for x = 0, wD - 1 do
        if matrix[y * wD + x] == 0 then
           r = ""
        else
angle = {0}
xml = xml..string.format('<S H="40" P="0,0,3,0.2,%s,0,0,0" L="40" X="%s" Y="%s" o="%s" T="12" />',angle[math.random(#angle)], x*40,y*40,color)
        end
     end
  end
xml = xml..xmlEnd
tfm.exec.newGame(xml)
tfm.exec.setGameTime('330')
end

function eventNewPlayer(p)
tfm.exec.respawnPlayer(p)
end

function genMaze(matrix, wD, hG, x, y)
  local r = math.random(0, 3)
  matrix[y * wD + x] = 0
  for i = 0, 3 do
     local d = (i + r) % 4
     local dx = 0
     local dy = 0
     if d == 0 then
        dx = 1
     elseif d == 1 then
        dx = -1
     elseif d == 2 then
        dy = 1
     else
        dy = -1
     end
     local nx = x + dx
     local ny = y + dy
     local nx2 = nx + dx
     local ny2 = ny + dy
     if matrix[ny * wD + nx] == 1 then
        if matrix[ny2 * wD + nx2] == 1 then
           matrix[ny * wD + nx] = 0
           genMaze(matrix, wD, hG, nx2, ny2)
        end
     end
  end
end

wD = 55
hG = 20

function eventPlayerWon(p)
place = place+1
if place == 1 then
tfm.exec.setGameTime(10)
end
end

function eventLoop(t,r)
if r <= 0 then
matrix = init_matrix(wD, hG)
genMaze(matrix, wD, hG, 2, 2)
matrix[wD + 2] = 0
matrix[(hG - 2) * wD + wD - 3] = 0
setMap(matrix, wD, hG)
end
end
tfm.exec.setGameTime(1)

Labirinto- Ache o Queijo! G9fFrMY
Ir para o topo Ir para baixo
https://miceforumns.directorioforuns.com
 
Labirinto- Ache o Queijo!
Ir para o topo 
Página 1 de 1

Permissões neste sub-fórumNão podes responder a tópicos
Lua transformice :: Mini games-
Ir para: