Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- gameOver = false
- username = "Eshkation" -- Mude para seu nick
- snakeUI = {type = 12, height = 10, width = 10, color = 0x02F700}
- foodUI = {type = 12, height = 10, width = 10, color = 0xF95555}
- ID = 1
- main = {X=100,Y = 200, lenght = 2}
- colors = {[0] = 0}
- snakeTail = {[1] = {X = 9999, Y= 9999}}
- food = {X = 999, Y = 999}
- pX = main.X
- pY = main.Y
- dirY = 0
- dirX = 0
- function colorCell(pX,pY)
- ID = ID+1
- tfm.exec.addPhysicObject(ID, pX, pY, snakeUI)
- snakeTail[ID] = {X = pX, Y= pY}
- if ID >= main.lenght then
- ID = 1
- end
- end
- function addFood()
- food.X = math.floor(math.random()*77)*10
- food.Y = math.floor(math.random()*33)*10
- tfm.exec.addPhysicObject(-1, food.X, food.Y, foodUI)
- end
- function eventLoop()
- if gameOver == false then
- pY = pY+dirY
- pX = pX+dirX
- tfm.exec.addPhysicObject(0, pX, pY, snakeUI)
- colorCell(pX,pY)
- if pX >= 790 then pX = 10
- elseif pX <= 10 then pX = 790
- elseif pY >= 390 then pY = 10
- elseif pY <= 10 then pY = 390
- end
- if pX == food.X and pY == food.Y then
- main.lenght = main.lenght+1
- addFood()
- end
- end
- end
- function eventKeyboard(player,keyCode,down,posX,posY)
- dirX = 0
- dirY = 0
- if keyCode == 76 then
- dirX = 10
- elseif keyCode == 74 then
- dirX = -10
- elseif keyCode == 73 then
- dirY = -10
- elseif keyCode == 75 then
- dirY = 10
- end
- end
- tfm.exec.bindKeyboard(username,73,true,true)
- tfm.exec.bindKeyboard(username,74,true,true)
- tfm.exec.bindKeyboard(username,75,true,true)
- tfm.exec.bindKeyboard(username,76,true,true)
- tfm.exec.newGame("@5099136")
- addFood()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement