-- Minijuego de Serpiente COMPACTO para Delta Executor local Players = game:GetService("Players") local CoreGui = game:GetService("CoreGui") local UserInputService = game:GetService("UserInputService") -- Eliminar GUI previa si existe if CoreGui:FindFirstChild("SnakeGameGui") then CoreGui.SnakeGameGui:Destroy() end -- Variables del Juego (Tablero más chico) local gridSize = 12 -- Reducido de 20 a 12 local boardWidth = 14 local boardHeight = 14 local snake = {} local direction = Vector2.new(1, 0) local nextDirection = direction local foodPos = Vector2.new(5, 5) local score = 0 local gameRunning = false local moveInterval = 0.20 local lastMove = 0 -- Crear Interfaz Gráfica (GUI) Mini local sg = Instance.new("ScreenGui") sg.Name = "SnakeGameGui" sg.Parent = CoreGui local mainFrame = Instance.new("Frame") mainFrame.Size = UDim2.new(0, boardWidth * gridSize + 20, 0, boardHeight * gridSize + 115) -- Más compacto mainFrame.Position = UDim2.new(0.5, -(boardWidth * gridSize) / 2, 0.4, -(boardHeight * gridSize) / 2) mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) mainFrame.BorderSizePixel = 1 mainFrame.Active = true mainFrame.Draggable = true mainFrame.Parent = sg local title = Instance.new("TextLabel") title.Size = UDim2.new(1, -25, 0, 22) title.Text = " Snake Mini" title.TextColor3 = Color3.fromRGB(255, 255, 255) title.BackgroundColor3 = Color3.fromRGB(20, 20, 20) title.Font = Enum.Font.SourceSansBold title.TextSize = 14 title.TextXAlignment = Enum.TextXAlignment.Left title.Parent = mainFrame local scoreLabel = Instance.new("TextLabel") scoreLabel.Size = UDim2.new(1, 0, 0, 18) scoreLabel.Position = UDim2.new(0, 0, 0, 22) scoreLabel.Text = "Pts: 0" scoreLabel.TextColor3 = Color3.fromRGB(200, 200, 200) scoreLabel.BackgroundTransparency = 1 scoreLabel.Font = Enum.Font.SourceSansBold scoreLabel.TextSize = 13 scoreLabel.Parent = mainFrame local board = Instance.new("Frame") board.Size = UDim2.new(0, boardWidth * gridSize, 0, boardHeight * gridSize) board.Position = UDim2.new(0, 10, 0, 42) board.BackgroundColor3 = Color3.fromRGB(15, 15, 15) board.BorderColor3 = Color3.fromRGB(50, 50, 50) board.ClipsDescendants = true board.Parent = mainFrame -- Controles Mini para Pantallas Táctiles (Debajo del tablero) local controls = Instance.new("Frame") controls.Size = UDim2.new(0, 90, 0, 65) controls.Position = UDim2.new(0.5, -45, 1, -68) controls.BackgroundTransparency = 1 controls.Parent = mainFrame local function createArrow(text, pos, dir) local btn = Instance.new("TextButton") btn.Size = UDim2.new(0, 26, 0, 22) btn.Position = pos btn.Text = text btn.BackgroundColor3 = Color3.fromRGB(45, 45, 45) btn.TextColor3 = Color3.fromRGB(255, 255, 255) btn.Font = Enum.Font.SourceSansBold btn.TextSize = 14 btn.Parent = controls btn.MouseButton1Click:Connect(function() if (dir.X ~= -direction.X or dir.X == 0) and (dir.Y ~= -direction.Y or dir.Y == 0) then nextDirection = dir end end) end -- Distribución compacta de botones createArrow("▲", UDim2.new(0, 32, 0, 2), Vector2.new(0, -1)) createArrow("▼", UDim2.new(0, 32, 0, 42), Vector2.new(0, 1)) createArrow("◄", UDim2.new(0, 4, 0, 22), Vector2.new(-1, 0)) createArrow("►", UDim2.new(0, 60, 0, 22), Vector2.new(1, 0)) local closeBtn = Instance.new("TextButton") closeBtn.Size = UDim2.new(0, 25, 0, 22) closeBtn.Position = UDim2.new(1, -25, 0, 0) closeBtn.Text = "X" closeBtn.TextColor3 = Color3.fromRGB(255, 100, 100) closeBtn.BackgroundColor3 = Color3.fromRGB(25, 25, 25) closeBtn.BorderSizePixel = 0 closeBtn.TextSize = 14 closeBtn.Parent = mainFrame closeBtn.MouseButton1Click:Connect(function() gameRunning = false sg:Destroy() end) -- Lógica del Juego local function spawnFood() local valid = false while not valid do valid = true foodPos = Vector2.new(math.random(0, boardWidth - 1), math.random(0, boardHeight - 1)) for _, segment in ipairs(snake) do if segment == foodPos then valid = false end end end end local function draw() board:ClearAllChildren() -- Dibujar Comida Mini local foodFrame = Instance.new("Frame") foodFrame.Size = UDim2.new(0, gridSize - 1, 0, gridSize - 1) foodFrame.Position = UDim2.new(0, foodPos.X * gridSize, 0, foodPos.Y * gridSize) foodFrame.BackgroundColor3 = Color3.fromRGB(255, 60, 60) foodFrame.BorderSizePixel = 0 foodFrame.Parent = board -- Dibujar Serpiente Mini for i, segment in ipairs(snake) do local segFrame = Instance.new("Frame") segFrame.Size = UDim2.new(0, gridSize - 1, 0, gridSize - 1) segFrame.Position = UDim2.new(0, segment.X * gridSize, 0, segment.Y * gridSize) segFrame.BackgroundColor3 = (i == 1) and Color3.fromRGB(60, 255, 60) or Color3.fromRGB(50, 190, 50) segFrame.BorderSizePixel = 0 segFrame.Parent = board end end local function resetGame() snake = {Vector2.new(4, 5), Vector2.new(3, 5)} direction = Vector2.new(1, 0) nextDirection = direction score = 0 scoreLabel.Text = "Pts: " .. score spawnFood() gameRunning = true end -- Controles de Teclado (PC) UserInputService.InputBegan:Connect(function(input, processed) if processed then return end if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Up then if direction.Y == 0 then nextDirection = Vector2.new(0, -1) end elseif input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.Down then if direction.Y == 0 then nextDirection = Vector2.new(0, 1) end elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Left then if direction.X == 0 then nextDirection = Vector2.new(-1, 0) end elseif input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Right then if direction.X == 0 then nextDirection = Vector2.new(1, 0) end end end) resetGame() -- Bucle de Actualización game:GetService("RunService").Heartbeat:Connect(function() if not gameRunning then return end local now = os.clock() if now - lastMove >= moveInterval then lastMove = now direction = nextDirection local head = snake[1] local newHead = head + direction -- Colisiones de Paredes if newHead.X < 0 or newHead.X >= boardWidth or newHead.Y < 0 or newHead.Y >= boardHeight then resetGame() return end -- Colisiones del Cuerpo for i, segment in ipairs(snake) do if segment == newHead then resetGame() return end end table.insert(snake, 1, newHead) -- Comer if newHead == foodPos then score = score + 1 scoreLabel.Text = "Pts: " .. score spawnFood() else table.remove(snake) end draw() end end)