Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURAÇÕES INICIAIS
- largura = 17
- altura = 17
- nivel = 1
- pontuacao = 0
- vidas = 100
- gameOver = false
- -- VARIÁVEIS DE PERSONALIZAÇÃO (padrão)
- playerTankIcon = "🟩" -- Cor do tanque do jogador (pode ser alterada)
- baseWallIcon = "🧱" -- Ícone das paredes da base (fixo)
- baseCenterIcon = "🌟" -- Ícone central da base (pode ser alterado)
- dificuldade = 3 -- Dificuldade ( 3 tanques inimigos base)
- -- Posição da bandeira para avanço de nível (no centro da parte superior)
- flagPos = { x = math.ceil(largura/2), y = 2 }
- -- TABELAS GLOBAIS: obstáculos (paredes fixas) e base
- obstacles = {} -- paredes fixas
- -- Gera o mapa fixo conforme o modelo (exemplo: linhas 6, 7, 11 e 12)
- function gerarMapaFixo()
- obstacles = {}
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 6})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 7})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 8})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 9})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 10})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 11})
- end
- for x = 1, largura do
- table.insert(obstacles, {x = x, y = 12})
- end
- end
- gerarMapaFixo()
- -- DEFINIÇÃO DA BASE PROTETORA
- -- A base é uma matriz 3x3; as células laterais (paredes) usam baseWallIcon
- -- e a célula central (item) usa baseCenterIcon.
- baseCenter = { x = math.floor(largura/2) + 1, y = math.floor(altura/2) + 1 }
- baseCells = {
- {x = baseCenter.x - 1, y = baseCenter.y - 1},
- {x = baseCenter.x, y = baseCenter.y - 1},
- {x = baseCenter.x + 1, y = baseCenter.y - 1},
- {x = baseCenter.x - 1, y = baseCenter.y },
- {x = baseCenter.x, y = baseCenter.y },
- {x = baseCenter.x + 1, y = baseCenter.y },
- {x = baseCenter.x - 1, y = baseCenter.y + 1},
- {x = baseCenter.x, y = baseCenter.y + 1},
- {x = baseCenter.x + 1, y = baseCenter.y + 1}
- }
- -- FUNÇÕES AUXILIARES DE VALIDAÇÃO
- function posLivre(x, y)
- if x < 1 or x > largura or y < 1 or y > altura then return false end
- for _, obs in ipairs(obstacles) do
- if obs.x == x and obs.y == y then return false end
- end
- for _, cell in ipairs(baseCells) do
- if cell.x == x and cell.y == y then return false end
- end
- return true
- end
- function baseContains(x, y)
- for _, cell in ipairs(baseCells) do
- if cell.x == x and cell.y == y then return true end
- end
- return false
- end
- function tankPosLivre(x, y, currentTank)
- if currentTank ~= tanque then
- for _, parte in ipairs(tanque.partes) do
- if parte.x == x and parte.y == y then return false end
- end
- end
- for _, inimigo in ipairs(tanqueinimigos) do
- if inimigo ~= currentTank then
- for _, parte in ipairs(inimigo.partes) do
- if parte.x == x and parte.y == y then return false end
- end
- end
- end
- return true
- end
- -- DEFINIÇÃO DAS FORMAS DO TANQUE (6 quadrados)
- -- O quadrado de índice 2 é o canhão.
- formas = {
- Cima = {
- {dx = -1, dy = 0},
- {dx = 0, dy = -1},
- {dx = 1, dy = 0},
- {dx = -1, dy = 1},
- {dx = 0, dy = 0},
- {dx = 1, dy = 1}
- },
- Baixo = {
- {dx = 1, dy = 0},
- {dx = 0, dy = 1},
- {dx = -1, dy = 0},
- {dx = 1, dy = -1},
- {dx = 0, dy = 0},
- {dx = -1, dy = -1}
- },
- Direita = {
- {dx = 0, dy = -1},
- {dx = 1, dy = 0},
- {dx = 0, dy = 1},
- {dx = -1, dy = -1},
- {dx = 0, dy = 0},
- {dx = -1, dy = 1}
- },
- Esquerda = {
- {dx = 0, dy = 1},
- {dx = -1, dy = 0},
- {dx = 0, dy = -1},
- {dx = 1, dy = 1},
- {dx = 0, dy = 0},
- {dx = 1, dy = -1}
- }
- }
- -- TANQUE DO JOGADOR
- -- Posicionado inicialmente nas linhas inferiores.
- tanque = {
- pos = {x = math.floor(largura/2)+1, y = altura - 1},
- direcao = "Cima",
- partes = {}
- }
- function atualizarTanque(obj)
- local t = obj or tanque
- t.partes = {}
- local offsets = formas[t.direcao]
- for i, off in ipairs(offsets) do
- table.insert(t.partes, {x = t.pos.x + off.dx, y = t.pos.y + off.dy})
- end
- end
- atualizarTanque()
- tanqueinimigos = {}
- function spawnInimigos(qtd, nivel)
- tanqueinimigos = {}
- local attempts = 0
- while #tanqueinimigos < qtd and attempts < 1000 do
- attempts = attempts + 1
- local ex = math.random(2, largura-1)
- local ey = math.random(1, 1) -- área superior
- if posLivre(ex, ey) and tankPosLivre(ex, ey, nil) then
- local novo = criarTanqueInimigo(ex, ey, nivel) -- Usa o nível atual para definir a vida
- local valid = true
- for _, parte in ipairs(novo.partes) do
- if not posLivre(parte.x, parte.y) then
- valid = false
- break
- end
- end
- if valid then
- table.insert(tanqueinimigos, novo)
- end
- end
- end
- end
- -- TANQUES INIMIGOS
- function criarTanqueInimigo(x, y, nivel)
- nivel = nivel or 1
- return {
- pos = {x = x, y = y}, -- Adiciona a posição corretamente
- vida = nivel + 1, -- Aumenta a vida conforme o nível
- partes = {
- {x = x, y = y},
- {x = x+1, y = y},
- {x = x, y = y+1},
- {x = x+1, y = y+1}
- }
- }
- end
- function aplicarDanoInimigo(tanqueIndex)
- if tanqueinimigos[tanqueIndex] then
- tanqueinimigos[tanqueIndex].vida = tanqueinimigos[tanqueIndex].vida - 1
- if tanqueinimigos[tanqueIndex].vida <= 0 then
- table.remove(tanqueinimigos, tanqueIndex) -- Remove o inimigo se a vida chegar a 0
- end
- end
- end
- ----------------------------------------------------------------
- -- DESENHO DO TABULEIRO
- -- Exibe o cabeçalho (vidas, pontuação e nível) acima do tabuleiro.
- -- Na área da base, as células laterais usam baseWallIcon e o centro usa baseCenterIcon.
- -- Se não houver inimigos, exibe a bandeira (🏁) na posição flagPos.
- function desenharTabuleiro()
- local header = "🛡️Escudo: " .. tostring(vidas) .. " | ✨Pontuação: " .. tostring(pontuacao) .. " | 📶Level: " .. tostring(nivel) .. "\n\n"
- local board = ""
- for y = 1, altura do
- for x = 1, largura do
- local celula = "⬛" -- fundo padrão
- if #tanqueinimigos == 0 and x == flagPos.x and y == flagPos.y then
- celula = "🏁"
- else
- local isBase = false
- for _, cell in ipairs(baseCells) do
- if cell.x == x and cell.y == y then
- if cell.x == baseCenter.x and cell.y == baseCenter.y then
- celula = baseCenterIcon
- else
- celula = baseWallIcon
- end
- isBase = true
- break
- end
- end
- if not isBase then
- for _, obs in ipairs(obstacles) do
- if obs.x == x and obs.y == y then
- celula = "🧱"
- break
- end
- end
- end
- for _, inimigo in ipairs(tanqueinimigos) do
- for _, parte in ipairs(inimigo.partes) do
- if parte.x == x and parte.y == y then
- celula = "🟥"
- break
- end
- end
- end
- for _, parte in ipairs(tanque.partes) do
- if parte.x == x and parte.y == y then
- celula = playerTankIcon
- break
- end
- end
- end
- board = board .. celula
- end
- board = board .. "\n"
- end
- return header .. board
- end
- -- FUNÇÃO scanShot: varredura do tiro
- function scanShot(sx, sy, dx, dy, shooterType)
- local x = sx
- local y = sy
- while x >= 1 and x <= largura and y >= 1 and y <= altura do
- for i, obs in ipairs(obstacles) do
- if obs.x == x and obs.y == y then
- return "obstacle", i
- end
- end
- local isBaseCell = false
- local baseIndex = nil
- for j, cell in ipairs(baseCells) do
- if cell.x == x and cell.y == y then
- isBaseCell = true
- baseIndex = j
- break
- end
- end
- if isBaseCell then
- local protecaoRestante = false
- for j, cell in ipairs(baseCells) do
- if not (cell.x == baseCenter.x and cell.y == baseCenter.y) then
- protecaoRestante = true
- break
- end
- end
- if protecaoRestante then
- return "base_protect", nil
- else
- return "base", baseIndex
- end
- end
- if shooterType == "player" then
- for i, inimigo in ipairs(tanqueinimigos) do
- for j, parte in ipairs(inimigo.partes) do
- if parte.x == x and parte.y == y then
- return "enemy", i
- end
- end
- end
- elseif shooterType == "enemy" then
- for j, parte in ipairs(tanque.partes) do
- if parte.x == x and parte.y == y then
- return "player", nil
- end
- end
- end
- x = x + dx
- y = y + dy
- end
- return "none", nil
- end
- -- DISPARO DO JOGADOR
- function dispararJogador()
- local canhao = tanque.partes[2]
- local dx, dy = 0, 0
- if tanque.direcao == "Cima" then dx, dy = 0, -1
- elseif tanque.direcao == "Baixo" then dx, dy = 0, 1
- elseif tanque.direcao == "Direita" then dx, dy = 1, 0
- elseif tanque.direcao == "Esquerda" then dx, dy = -1, 0
- end
- local target, index = scanShot(canhao.x, canhao.y, dx, dy, "player")
- if target == "obstacle" then
- table.remove(obstacles, index)
- pontuacao = pontuacao + 50
- elseif target == "enemy" then
- pontuacao = pontuacao + 500
- aplicarDanoInimigo(index)
- elseif target == "base_protect" then
- if index then
- table.remove(baseCells, index)
- else
- for j, cell in ipairs(baseCells) do
- if not (cell.x == baseCenter.x and cell.y == baseCenter.y) then
- table.remove(baseCells, j)
- break
- end
- end
- end
- pontuacao = pontuacao + 50
- elseif target == "base" then
- while true do
- local opcao = gg.alert("Você destruiu a base! Game Over.\nPontuação: " .. tostring(pontuacao),"OK")
- if opcao == 1 then
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- end
- end
- -- DISPARO DOS INIMIGOS
- function dispararInimigos()
- for _, inimigo in ipairs(tanqueinimigos) do
- local canhaoI = inimigo.partes[2]
- local dx, dy = 0, 0
- if inimigo.direcao == "Cima" then dx, dy = 0, -1
- elseif inimigo.direcao == "Baixo" then dx, dy = 0, 1
- elseif inimigo.direcao == "Direita" then dx, dy = 1, 0
- elseif inimigo.direcao == "Esquerda" then dx, dy = -1, 0
- end
- local target, index = scanShot(canhaoI.x, canhaoI.y, dx, dy, "enemy")
- if target == "obstacle" then
- table.remove(obstacles, index)
- elseif target == "base_protect" then
- if index then
- table.remove(baseCells, index)
- else
- for j, cell in ipairs(baseCells) do
- if not (cell.x == baseCenter.x and cell.y == baseCenter.y) then
- table.remove(baseCells, j)
- break
- end
- end
- end
- elseif target == "base" then
- while true do
- local opcao = gg.alert("A base protetora foi destruída! Game Over.\nPontuação: " .. tostring(pontuacao), "OK")
- if opcao == 1 then
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- elseif target == "player" then
- vidas = vidas - 1
- if vidas <= 0 then
- while true do
- local opcao = gg.alert("Você perdeu todas as vidas! Game Over.\nPontuação: " .. tostring(pontuacao), "OK")
- if opcao == 1 then
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- end
- end
- end
- end
- -- MOVIMENTAÇÃO DO JOGADOR
- function moverJogador(dx, dy)
- local newPos = { x = tanque.pos.x + dx, y = tanque.pos.y + dy }
- local offsets = formas[tanque.direcao]
- local newParts = {}
- for _, off in ipairs(offsets) do
- local nx = newPos.x + off.dx
- local ny = newPos.y + off.dy
- if nx < 1 or nx > largura or ny < 1 or ny > altura or (not posLivre(nx, ny)) or (not tankPosLivre(nx, ny, tanque)) then
- return
- end
- table.insert(newParts, {x = nx, y = ny})
- end
- tanque.pos = newPos
- atualizarTanque()
- end
- -- MOVIMENTAÇÃO DOS INIMIGOS
- function moverInimigos()
- local opcoes = {"Cima", "Baixo", "Direita", "Esquerda"}
- for _, inimigo in ipairs(tanqueinimigos) do
- local dir = opcoes[math.random(1, #opcoes)]
- inimigo.direcao = dir
- local dx, dy = 0, 0
- if dir == "Cima" then dy = -1
- elseif dir == "Baixo" then dy = 1
- elseif dir == "Direita" then dx = 1
- elseif dir == "Esquerda" then dx = -1
- end
- local newPos = { x = inimigo.pos.x + dx, y = inimigo.pos.y + dy }
- local canMove = true
- local newParts = {}
- for _, off in ipairs(formas[inimigo.direcao]) do
- local nx = newPos.x + off.dx
- local ny = newPos.y + off.dy
- if nx < 1 or nx > largura or ny < 1 or ny > altura or (not posLivre(nx, ny)) or (not tankPosLivre(nx, ny, inimigo)) then
- canMove = false
- break
- end
- table.insert(newParts, {x = nx, y = ny})
- end
- if canMove then
- inimigo.pos = newPos
- atualizarTanque(inimigo)
- end
- end
- end
- -- CHECA COLISÃO: Se alguma parte do jogador colide com um inimigo
- function checarColisoes()
- for _, parteJ in ipairs(tanque.partes) do
- for _, inimigo in ipairs(tanqueinimigos) do
- for _, parteI in ipairs(inimigo.partes) do
- if parteJ.x == parteI.x and parteJ.y == parteI.y then
- return true
- end
- end
- end
- end
- return false
- end
- -- MENU DE AÇÕES DURANTE O JOGO
- function menuAcoes()
- local opcoes = {
- string.rep(" ", 30).."⬆️ Cima",
- string.rep(" ", 10).."⬅️ Esquerda",
- string.rep(" ", 50).."➡️ Direita",
- string.rep(" ", 30).."⬇️ Baixo",
- string.rep(" ", 60).."💥 Dispare",
- "️↩️Menu Principa️l🛠️",
- "❌ Desistir!😪"
- }
- local texto = desenharTabuleiro() .. "\n🔰Proteja sua Base ".. baseCenterIcon .." Elimine Tanks inimigos 🚨"
- local escolha = gg.choice(opcoes, nil, texto)
- if escolha == nil then
- gg.setVisible(false)
- return nil
- end
- return escolha
- end
- -- MENU PRINCIPAL E PERSONALIZAÇÃO
- function selecionarCorTanque()
- local cores = {"🟨", "🟩", "🟪", "🟧", "🟦", "🟫", "⬜", "🔳"}
- local escolha = gg.choice(cores, nil, "Selecione a cor do Tanque:")
- if escolha then
- playerTankIcon = cores[escolha]
- end
- end
- function selecionarTipoBase()
- local bases = {"🪙", "🔮", "🎁", "🏮", "💠", "🆘", "🔆"}
- local escolha = gg.choice(bases, nil, "Selecione o ícone central da Base:")
- if escolha then
- baseCenterIcon = bases[escolha]
- end
- end
- function selecionarDificuldade()
- local niveis = {
- "1 - Recruta 🚜",
- "2 - Soldado 🪖",
- "3 - Cabo 🔰",
- "4 - Sargento 🎖️",
- "5 - Comandante 🏅",
- "6 - Estratégico 🧭",
- "7 - Tático ⚔️",
- "8 - Elite 🔥",
- "9 - Imbatível 💀",
- "10 - General Supremo ⭐",
- "11 - Mestre da Guerra 🛡️",
- "12 - Legado de Aço 🏰",
- "13 - Resistência Brutal ⚒️",
- "14 - Inferno de Aço 🔥⚙️",
- "15 - Inimigos Sombrios ☠️",
- "16 - Tempestade de Fogo 🌩️",
- "17 - Campo Minado 💣",
- "18 - Cerco Final 🏰⚔️",
- "19 - O Último Desafio 🚀",
- "20 - Lenda dos Tanques 👑"
- }
- local escolha = gg.choice(niveis, nil, "🔱 Selecione a dificuldade (tanques inimigos base):")
- if escolha then
- -- Extrai o número da dificuldade a partir do texto selecionado
- dificuldade = tonumber(niveis[escolha]:match("^(%d+)"))
- end
- -- Aqui você pode definir o número fixo de inimigos
- vida = dificuldade
- nivel = dificuldade
- dificuldade = 3
- end
- function sobreOJogo()
- local texto = "🚀 Jogo de Tanques - Versão Game Guardian 🚀\n\n" ..
- "🎯 Missão: Você é o comandante de um poderoso tanque de batalha! Sua missão é proteger sua base 🏰 a todo custo e eliminar todos os tanques inimigos 🚨 que tentam invadi-la. Apenas ao derrotá-los e capturar a bandeira 🏁 no topo do mapa, você poderá avançar para o próximo nível!\n\n" ..
- "🕹️ Controles: Utilize as opções do menu para movimentar seu tanque, disparar e evitar colisões. Planeje cada ação com cuidado, pois os inimigos não terão piedade!\n\n" ..
- "🛡️ Proteção: Fique atento ao seu escudo ⚡! Se ele acabar, seu tanque ficará vulnerável e poderá ser destruído. Use táticas defensivas para proteger sua base e a si mesmo!\n\n" ..
- "🎨 Personalização: Torne seu tanque único! Escolha a cor, o motorista e o ícone da base para criar uma experiência de jogo personalizada.\n\n" ..
- "🔥 Desafio: São 20 níveis de batalhas cada vez mais difíceis! A cada fase, os inimigos ficam mais agressivos e resistentes, exigindo mais estratégia e precisão para derrotá-los.\n\n" ..
- "💡 Dicas: Use os obstáculos como escudo, ataque no momento certo e fique sempre de olho no seu escudo e na sua base! Proteger sua base é essencial para garantir a vitória!\n\n" ..
- "🏆 Mostre que você é um verdadeiro comandante de elite! Supere todos os desafios, proteja sua base e conquiste a glória no campo de batalha!"
- gg.alert(texto)
- end
- function contato()
- gg.alert([[
- 🔔 **Script made for the Channel**
- 📽 **Master Cheats⚜** - Created by: **Edrwuan👑**
- ➡️ **Subscribe to the Channel** for more Cheats and Game News 🎮
- 🔗 **Telegram Contact**: [Click here to join](https://t.me/joinchat/IarWN9hjkgcunWEN)
- 📧 **Email**: edrwuan@live.com
- 📱 **Official Telegram**: @MastercheatsAnonymous
- 🔔 **Script produzido para o Canal**
- 📽 **Master Cheats⚜** - Criado por: **Edrwuan👑**
- ➡️ **Inscreva-se no Canal** para mais Cheats e Novidades sobre Jogos 🎮
- 🔗 **Contato Telegram**: [Clique aqui para entrar](https://t.me/joinchat/IarWN9hjkgcunWEN)
- 📧 **E-mail**: edrwuan@live.com
- 📱 **Telegram Oficial**: @MastercheatsAnonymous
- ]])
- return
- end
- function menuPrincipal()
- while true do
- local opcoes = {
- "🕹️ Iniciar Jogo",
- "🎨 Selecionar Cor do Tanque",
- "🏰 Selecionar Ícone Central da Base",
- "💥 Alterar Dificuldade",
- "📖 Sobre o Jogo e Dicas",
- "🌐 Contate-Me",
- "❌ Desistir!😪"
- }
- local escolha = gg.choice(opcoes, nil, "🕹️Mini Tanque de Batalha Clássico: Desafio Blindado\n"..string.rep(" ", 30).."Made for Edrwuan \n"..string.rep(" ", 10).."🎞️YouTube 👑Master Cheats Channel🎥\n\n"..string.rep(" ", 25).."🗂️ Menu Principal ️️🛠️\n\n" ..
- "🎨 ️Cor Tanque Selecionado: " .. playerTankIcon .. "\n" ..
- "🏰 Base Icone Selecionada: " .. baseCenterIcon .. "\n" ..
- "🚨 Dificuldade Selecionada: " .. nivel .. "\n")
- if escolha == 1 then
- break -- Inicia o jogo
- elseif escolha == 2 then
- selecionarCorTanque()
- elseif escolha == 3 then
- selecionarTipoBase()
- elseif escolha == 4 then
- selecionarDificuldade()
- elseif escolha == 5 then
- sobreOJogo()
- elseif escolha == 6 then
- contato()
- elseif escolha == 7 then
- gg.alert("⚠️ Missão Abortada! ⚠️\n\n" ..
- "Você optou por abandonar a batalha... 🏳️\n\n" ..
- "Seu progresso será perdido e sua jornada como comandante de tanques chega ao fim por agora.\n\n" ..
- "🔥 Pontuação Final: " .. tostring(pontuacao) .. " 🔥\n\n" ..
- "Obrigado por jogar! Volte sempre para mais desafios! 🚀")
- os.exit()
- end
- end
- end
- -- LOOP PRINCIPAL DO JOGO
- function iniciarJogo()
- nivel = nivel or 1 -- Garante que o nível tenha um valor válido
- -- Se não houver inimigos (no início do jogo), gera os inimigos do nível 1.
- if #tanqueinimigos == 0 then
- spawnInimigos(dificuldade, nivel)
- end
- while not gameOver do
- -- Se não houver inimigos, verifica se o jogador tocou a bandeira para avançar de nível.
- if #tanqueinimigos == 0 then
- for _, parte in ipairs(tanque.partes) do
- if parte.x == flagPos.x and parte.y == flagPos.y then
- while true do
- local opcao = gg.alert("🏁 Bandeira Conquistada! 🏁\n\n" ..
- "Parabéns, comandante! 🎖️ Você dominou o campo de batalha e avançou para o próximo nível! 🚀\n\n" ..
- "⚠️ Prepare-se! A guerra fica mais intensa! Os inimigos estão mais resistentes e ágeis. Use estratégia e proteja sua base " .. baseCenterIcon .. " a todo custo! 🏰\n\n" ..
- "Boa sorte na próxima missão! 💥", "OK")
- if opcao == 1 then break end
- end
- nivel = nivel + 1
- if nivel > 20 then
- while true do
- local opcao = gg.alert("🎉✨ UAU, VOCÊ COMPLETOU TODOS OS 20 NÍVEIS! ✨🎉\n\nSua pontuação final foi: " .. tostring(pontuacao) .. "\n\nVocê é um verdadeiro mestre dos tanques!\nContinue arrasando no campo de batalha e conquistando vitórias épicas! 🚀🔥", "OK")
- if opcao == 1 then
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- end
- -- Limpa os inimigos antes de gerar novos
- tanqueinimigos = {}
- spawnInimigos(dificuldade, nivel)
- gerarMapaFixo()
- -- Restaura a base completa
- baseCells = {
- {x = baseCenter.x - 1, y = baseCenter.y - 1},
- {x = baseCenter.x, y = baseCenter.y - 1},
- {x = baseCenter.x + 1, y = baseCenter.y - 1},
- {x = baseCenter.x - 1, y = baseCenter.y},
- {x = baseCenter.x, y = baseCenter.y},
- {x = baseCenter.x + 1, y = baseCenter.y},
- {x = baseCenter.x - 1, y = baseCenter.y + 1},
- {x = baseCenter.x, y = baseCenter.y + 1},
- {x = baseCenter.x + 1, y = baseCenter.y + 1}
- }
- tanque.pos = { x = math.floor(largura/2), y = altura - 1 }
- atualizarTanque()
- break
- end
- end
- end
- local acao = menuAcoes()
- if acao == nil then break end
- if acao == 1 then
- tanque.direcao = "Cima"
- moverJogador(0, -1)
- elseif acao == 2 then
- tanque.direcao = "Esquerda"
- moverJogador(-1, 0)
- elseif acao == 3 then
- tanque.direcao = "Direita"
- moverJogador(1, 0)
- elseif acao == 4 then
- tanque.direcao = "Baixo"
- moverJogador(0, 1)
- elseif acao == 5 then
- dispararJogador()
- elseif acao == 6 then
- voltar()
- elseif acao == 7 then
- while true do
- local opcao = gg.alert("⚠️ Missão Abortada! ⚠️\n\n" ..
- "Você optou por abandonar a batalha... 🏳️\n\n" ..
- "Seu progresso será perdido e sua jornada como comandante de tanques chega ao fim por agora.\n\n" ..
- "🔥 Pontuação Final: " .. tostring(pontuacao) .. " 🔥\n\n" ..
- "Obrigado por jogar! Volte sempre para mais desafios! 🚀", "OK")
- if opcao == 1 then
- os.exit()
- end
- end
- end
- moverInimigos()
- dispararInimigos()
- if checarColisoes() then
- while true do
- local opcao = gg.alert("🚨💥 Oh não! Você foi atingido e sua armadura não resistiu à colisão!\n\nGame Over!\nPontuação Final: " .. tostring(pontuacao) .. "\n\n😔 Lembre-se: cada derrota é um aprendizado. Levante-se, ajuste sua estratégia e volte à batalha mais forte!", "OK")
- if opcao == 1 then
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- end
- gg.sleep(1)
- end
- end
- function voltar()
- local opcao = gg.alert("⚠️ Atenção, Comandante! ⚠️\n\n" ..
- "Se você voltar ao menu principal agora, TODO o seu progresso nesta batalha será perdido! 🏳️\n\n" ..
- "🚀 Sua missão será reiniciada, e você terá que começar desde o início, enfrentando os inimigos novamente desde o nível 1.\n\n" ..
- "Tem certeza de que deseja abandonar esta campanha e retornar ao menu principal? 🤔\n\n", "❌ Cancelar", "🔄 Voltar ao Menu")
- if opcao == 1 then
- return
- else
- -- Código para voltar ao menu principal
- resetarJogo()
- menuPrincipal()
- iniciarJogo()
- end
- end
- function resetarJogo()
- -- Resetando variáveis principais
- nivel = 1
- pontuacao = 0
- vidas = 100
- gameOver = false
- -- Resetando o tanque do jogador
- tanque.pos = {x = math.floor(largura/2)+1, y = altura - 1}
- tanque.direcao = "Cima"
- atualizarTanque()
- -- Resetando os inimigos
- tanqueinimigos = {}
- -- Gerando o mapa fixo novamente
- gerarMapaFixo()
- -- Resetando a base
- baseCells = {
- {x = baseCenter.x - 1, y = baseCenter.y - 1},
- {x = baseCenter.x, y = baseCenter.y - 1},
- {x = baseCenter.x + 1, y = baseCenter.y - 1},
- {x = baseCenter.x - 1, y = baseCenter.y },
- {x = baseCenter.x, y = baseCenter.y },
- {x = baseCenter.x + 1, y = baseCenter.y },
- {x = baseCenter.x - 1, y = baseCenter.y + 1},
- {x = baseCenter.x, y = baseCenter.y + 1},
- {x = baseCenter.x + 1, y = baseCenter.y + 1}
- }
- -- Exibindo uma mensagem de reinício
- gg.toast("Jogo reiniciado!\nPrepare-se para mais desafios.")
- end
- -- INÍCIO DO SCRIPT: MENU PRINCIPAL E EXECUÇÃO DO JOGO
- menuPrincipal()
- iniciarJogo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement