{"id":2717,"date":"2026-04-28T21:52:42","date_gmt":"2026-04-28T21:52:42","guid":{"rendered":"https:\/\/www.nmp.unirc.it\/?page_id=2717"},"modified":"2026-04-28T21:56:02","modified_gmt":"2026-04-28T21:56:02","slug":"snake","status":"publish","type":"page","link":"https:\/\/www.nmp.unirc.it\/?page_id=2717","title":{"rendered":"SNAKE"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"it\">\n<head>\n  <meta charset=\"UTF-8\" \/>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/>\n  <title>Snake NMP 2026<\/title>\n\n  <style>\n    * {\n      box-sizing: border-box;\n      margin: 0;\n      padding: 0;\n    }\n\n    body {\n      min-height: 100vh;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      font-family: Arial, sans-serif;\n      background: #f4f4f4;\n      color: #222;\n      padding: 20px;\n    }\n\n    .game-wrapper {\n      width: 100%;\n      max-width: 520px;\n      text-align: center;\n      background: white;\n      border: 3px solid #222;\n      border-radius: 18px;\n      padding: 22px;\n      box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);\n    }\n\n    h1 {\n      font-size: 28px;\n      margin-bottom: 10px;\n    }\n\n    .game-info {\n      display: flex;\n      justify-content: space-between;\n      margin-bottom: 14px;\n      font-size: 18px;\n      font-weight: bold;\n    }\n\n    .game-area {\n      position: relative;\n      width: 100%;\n      max-width: 420px;\n      aspect-ratio: 1 \/ 1;\n      margin: 0 auto;\n      border: 3px solid #222;\n      border-radius: 16px;\n      overflow: hidden;\n      background: #e9f5ff;\n    }\n\n    canvas {\n      width: 100%;\n      height: 100%;\n      display: block;\n      background: linear-gradient(135deg, #ffffff, #e9f5ff);\n    }\n\n    #message {\n      position: absolute;\n      inset: 0;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      flex-direction: column;\n      gap: 8px;\n      background: rgba(255, 255, 255, 0.78);\n      font-weight: bold;\n      font-size: 22px;\n      text-align: center;\n      padding: 20px;\n    }\n\n    #message small {\n      font-size: 14px;\n      font-weight: normal;\n      color: #444;\n    }\n\n    .hidden {\n      display: none !important;\n    }\n\n    .controls {\n      display: grid;\n      grid-template-columns: repeat(3, 58px);\n      gap: 8px;\n      justify-content: center;\n      margin-top: 16px;\n    }\n\n    .controls button,\n    .start-btn {\n      border: none;\n      border-radius: 12px;\n      background: #2f78b7;\n      color: white;\n      font-weight: bold;\n      cursor: pointer;\n      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);\n    }\n\n    .controls button {\n      height: 48px;\n      font-size: 22px;\n    }\n\n    .controls .empty {\n      visibility: hidden;\n    }\n\n    .start-btn {\n      margin-top: 14px;\n      padding: 11px 18px;\n      font-size: 15px;\n      border-radius: 999px;\n    }\n\n    .hint {\n      margin-top: 12px;\n      font-size: 14px;\n      color: #555;\n    }\n  <\/style>\n<\/head>\n\n<body>\n  <div class=\"game-wrapper\">\n    <h1>Snake NMP 2026<\/h1>\n\n    <div class=\"game-info\">\n      <div>Punteggio: <span id=\"score\">0<\/span><\/div>\n      <div>Record: <span id=\"bestScore\">0<\/span><\/div>\n    <\/div>\n\n    <div class=\"game-area\">\n      <canvas id=\"game\" width=\"420\" height=\"420\"><\/canvas>\n\n      <div id=\"message\">\n        Premi Start o una freccia\n        <small>Mangia i badge NMP e non toccare i bordi<\/small>\n      <\/div>\n    <\/div>\n\n    <button class=\"start-btn\" id=\"startBtn\">Start \/ Riavvia<\/button>\n\n    <div class=\"controls\" aria-label=\"Comandi mobile\">\n      <button class=\"empty\"><\/button>\n      <button data-dir=\"up\">\u2191<\/button>\n      <button class=\"empty\"><\/button>\n      <button data-dir=\"left\">\u2190<\/button>\n      <button data-dir=\"down\">\u2193<\/button>\n      <button data-dir=\"right\">\u2192<\/button>\n    <\/div>\n\n    <p class=\"hint\">Desktop: usa le frecce. Mobile: usa i pulsanti.<\/p>\n  <\/div>\n\n  <script>\n    const canvas = document.getElementById(\"game\");\n    const ctx = canvas.getContext(\"2d\");\n    const scoreEl = document.getElementById(\"score\");\n    const bestScoreEl = document.getElementById(\"bestScore\");\n    const message = document.getElementById(\"message\");\n    const startBtn = document.getElementById(\"startBtn\");\n    const controlButtons = document.querySelectorAll(\".controls button[data-dir]\");\n\n    const tileCount = 15;\n    const tileSize = canvas.width \/ tileCount;\n\n    let snake;\n    let food;\n    let direction;\n    let nextDirection;\n    let score;\n    let bestScore = Number(localStorage.getItem(\"snakeNmpBestScore\")) || 0;\n    let gameInterval;\n    let isPlaying = false;\n    let speed = 300;\n\n    bestScoreEl.textContent = bestScore;\n\n    function resetGame() {\n      snake = [\n        { x: 7, y: 7 },\n        { x: 6, y: 7 },\n        { x: 5, y: 7 }\n      ];\n\n      direction = { x: 1, y: 0 };\n      nextDirection = { x: 1, y: 0 };\n      score = 0;\n      speed = 150;\n      scoreEl.textContent = score;\n      food = createFood();\n\n      message.classList.add(\"hidden\");\n      isPlaying = true;\n\n      clearInterval(gameInterval);\n      gameInterval = setInterval(gameLoop, speed);\n      drawGame();\n    }\n\n    function createFood() {\n      let newFood;\n\n      do {\n        newFood = {\n          x: Math.floor(Math.random() * tileCount),\n          y: Math.floor(Math.random() * tileCount)\n        };\n      } while (snake.some(part => part.x === newFood.x && part.y === newFood.y));\n\n      return newFood;\n    }\n\n    function changeDirection(newDir) {\n      if (!isPlaying) {\n        resetGame();\n        return;\n      }\n\n      if (newDir === \"up\" && direction.y !== 1) {\n        nextDirection = { x: 0, y: -1 };\n      } else if (newDir === \"down\" && direction.y !== -1) {\n        nextDirection = { x: 0, y: 1 };\n      } else if (newDir === \"left\" && direction.x !== 1) {\n        nextDirection = { x: -1, y: 0 };\n      } else if (newDir === \"right\" && direction.x !== -1) {\n        nextDirection = { x: 1, y: 0 };\n      }\n    }\n\n    function gameLoop() {\n      direction = nextDirection;\n\n      const head = {\n        x: snake[0].x + direction.x,\n        y: snake[0].y + direction.y\n      };\n\n      const hitWall =\n        head.x < 0 ||\n        head.x >= tileCount ||\n        head.y < 0 ||\n        head.y >= tileCount;\n\n      const hitSelf = snake.some(part => part.x === head.x && part.y === head.y);\n\n      if (hitWall || hitSelf) {\n        endGame();\n        return;\n      }\n\n      snake.unshift(head);\n\n      if (head.x === food.x && head.y === food.y) {\n        score++;\n        scoreEl.textContent = score;\n        food = createFood();\n\n        const newSpeed = Math.max(180, 300 - score * 2);\n        if (newSpeed !== speed) {\n          speed = newSpeed;\n          clearInterval(gameInterval);\n          gameInterval = setInterval(gameLoop, speed);\n        }\n      } else {\n        snake.pop();\n      }\n\n      drawGame();\n    }\n\n    function drawGame() {\n      ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n      drawGrid();\n      drawFood();\n      drawSnake();\n    }\n\n    function drawGrid() {\n      ctx.strokeStyle = \"rgba(0, 0, 0, 0.06)\";\n      ctx.lineWidth = 1;\n\n      for (let i = 0; i <= tileCount; i++) {\n        ctx.beginPath();\n        ctx.moveTo(i * tileSize, 0);\n        ctx.lineTo(i * tileSize, canvas.height);\n        ctx.stroke();\n\n        ctx.beginPath();\n        ctx.moveTo(0, i * tileSize);\n        ctx.lineTo(canvas.width, i * tileSize);\n        ctx.stroke();\n      }\n    }\n\n    function drawSnake() {\n      snake.forEach((part, index) => {\n        const x = part.x * tileSize + 3;\n        const y = part.y * tileSize + 3;\n        const size = tileSize - 6;\n\n        ctx.fillStyle = index === 0 ? \"#2f78b7\" : \"#173b6c\";\n        roundRect(x, y, size, size, 7);\n        ctx.fill();\n\n        if (index === 0) {\n          ctx.fillStyle = \"white\";\n          ctx.font = \"bold 10px Arial\";\n          ctx.textAlign = \"center\";\n          ctx.textBaseline = \"middle\";\n          ctx.fillText(\"NMP\", x + size \/ 2, y + size \/ 2 - 3);\n          ctx.font = \"bold 6px Arial\";\n          ctx.fillText(\"2026\", x + size \/ 2, y + size \/ 2 + 6);\n        }\n      });\n    }\n\n    function drawFood() {\n      const x = food.x * tileSize + 5;\n      const y = food.y * tileSize + 5;\n      const size = tileSize - 10;\n\n      ctx.fillStyle = \"#238636\";\n      roundRect(x, y, size, size, 7);\n      ctx.fill();\n\n      ctx.fillStyle = \"white\";\n      ctx.font = \"bold 9px Arial\";\n      ctx.textAlign = \"center\";\n      ctx.textBaseline = \"middle\";\n      ctx.fillText(\"+\", x + size \/ 2, y + size \/ 2);\n    }\n\n    function roundRect(x, y, width, height, radius) {\n      ctx.beginPath();\n      ctx.moveTo(x + radius, y);\n      ctx.lineTo(x + width - radius, y);\n      ctx.quadraticCurveTo(x + width, y, x + width, y + radius);\n      ctx.lineTo(x + width, y + height - radius);\n      ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);\n      ctx.lineTo(x + radius, y + height);\n      ctx.quadraticCurveTo(x, y + height, x, y + height - radius);\n      ctx.lineTo(x, y + radius);\n      ctx.quadraticCurveTo(x, y, x + radius, y);\n      ctx.closePath();\n    }\n\n    function endGame() {\n      isPlaying = false;\n      clearInterval(gameInterval);\n\n      if (score > bestScore) {\n        bestScore = score;\n        localStorage.setItem(\"snakeNmpBestScore\", bestScore);\n        bestScoreEl.textContent = bestScore;\n      }\n\n      message.innerHTML = `\n        Game Over\n        <small>Punteggio: ${score} \u2014 premi Start o una freccia per riprovare<\/small>\n      `;\n      message.classList.remove(\"hidden\");\n    }\n\n    document.addEventListener(\"keydown\", function(event) {\n      if ([\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \"Space\"].includes(event.code)) {\n        event.preventDefault();\n      }\n\n      if (event.code === \"ArrowUp\") changeDirection(\"up\");\n      if (event.code === \"ArrowDown\") changeDirection(\"down\");\n      if (event.code === \"ArrowLeft\") changeDirection(\"left\");\n      if (event.code === \"ArrowRight\") changeDirection(\"right\");\n      if (event.code === \"Space\") resetGame();\n    });\n\n    controlButtons.forEach(button => {\n      button.addEventListener(\"click\", () => {\n        changeDirection(button.dataset.dir);\n      });\n    });\n\n    startBtn.addEventListener(\"click\", resetGame);\n\n    \/\/ Disegno iniziale\n    snake = [\n      { x: 7, y: 7 },\n      { x: 6, y: 7 },\n      { x: 5, y: 7 }\n    ];\n    food = { x: 10, y: 7 };\n    drawGame();\n  <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>Snake NMP 2026 Snake NMP 2026 Punteggio: 0 Record: 0 Premi Start o una freccia Mangia i badge NMP e non toccare i bordi Start \/ Riavvia \u2191 \u2190 \u2193 \u2192 Desktop: usa le frecce. Mobile: usa i pulsanti.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2717","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SNAKE - NMP2026<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.nmp.unirc.it\/?page_id=2717\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SNAKE - NMP2026\" \/>\n<meta property=\"og:description\" content=\"Snake NMP 2026 Snake NMP 2026 Punteggio: 0 Record: 0 Premi Start o una freccia Mangia i badge NMP e non toccare i bordi Start \/ Riavvia \u2191 \u2190 \u2193 \u2192 Desktop: usa le frecce. Mobile: usa i pulsanti.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.nmp.unirc.it\/?page_id=2717\" \/>\n<meta property=\"og:site_name\" content=\"NMP2026\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-28T21:56:02+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/?page_id=2717\",\"url\":\"https:\\\/\\\/www.nmp.unirc.it\\\/?page_id=2717\",\"name\":\"SNAKE - NMP2026\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#website\"},\"datePublished\":\"2026-04-28T21:52:42+00:00\",\"dateModified\":\"2026-04-28T21:56:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/?page_id=2717#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.nmp.unirc.it\\\/?page_id=2717\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/?page_id=2717#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.nmp.unirc.it\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SNAKE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#website\",\"url\":\"https:\\\/\\\/www.nmp.unirc.it\\\/\",\"name\":\"NMP2026\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.nmp.unirc.it\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#organization\",\"name\":\"NMP2026\",\"url\":\"https:\\\/\\\/www.nmp.unirc.it\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.nmp.unirc.it\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/cropped-cropped-Immagine1-removebg-preview.png\",\"contentUrl\":\"https:\\\/\\\/www.nmp.unirc.it\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/cropped-cropped-Immagine1-removebg-preview.png\",\"width\":570,\"height\":438,\"caption\":\"NMP2026\"},\"image\":{\"@id\":\"https:\\\/\\\/www.nmp.unirc.it\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SNAKE - NMP2026","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.nmp.unirc.it\/?page_id=2717","og_locale":"en_US","og_type":"article","og_title":"SNAKE - NMP2026","og_description":"Snake NMP 2026 Snake NMP 2026 Punteggio: 0 Record: 0 Premi Start o una freccia Mangia i badge NMP e non toccare i bordi Start \/ Riavvia \u2191 \u2190 \u2193 \u2192 Desktop: usa le frecce. Mobile: usa i pulsanti.","og_url":"https:\/\/www.nmp.unirc.it\/?page_id=2717","og_site_name":"NMP2026","article_modified_time":"2026-04-28T21:56:02+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.nmp.unirc.it\/?page_id=2717","url":"https:\/\/www.nmp.unirc.it\/?page_id=2717","name":"SNAKE - NMP2026","isPartOf":{"@id":"https:\/\/www.nmp.unirc.it\/#website"},"datePublished":"2026-04-28T21:52:42+00:00","dateModified":"2026-04-28T21:56:02+00:00","breadcrumb":{"@id":"https:\/\/www.nmp.unirc.it\/?page_id=2717#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.nmp.unirc.it\/?page_id=2717"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.nmp.unirc.it\/?page_id=2717#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.nmp.unirc.it\/"},{"@type":"ListItem","position":2,"name":"SNAKE"}]},{"@type":"WebSite","@id":"https:\/\/www.nmp.unirc.it\/#website","url":"https:\/\/www.nmp.unirc.it\/","name":"NMP2026","description":"","publisher":{"@id":"https:\/\/www.nmp.unirc.it\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.nmp.unirc.it\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.nmp.unirc.it\/#organization","name":"NMP2026","url":"https:\/\/www.nmp.unirc.it\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.nmp.unirc.it\/#\/schema\/logo\/image\/","url":"https:\/\/www.nmp.unirc.it\/wp-content\/uploads\/2023\/10\/cropped-cropped-Immagine1-removebg-preview.png","contentUrl":"https:\/\/www.nmp.unirc.it\/wp-content\/uploads\/2023\/10\/cropped-cropped-Immagine1-removebg-preview.png","width":570,"height":438,"caption":"NMP2026"},"image":{"@id":"https:\/\/www.nmp.unirc.it\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/pages\/2717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2717"}],"version-history":[{"count":3,"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/pages\/2717\/revisions"}],"predecessor-version":[{"id":2720,"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=\/wp\/v2\/pages\/2717\/revisions\/2720"}],"wp:attachment":[{"href":"https:\/\/www.nmp.unirc.it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}