{"id":3034,"date":"2026-02-02T11:10:18","date_gmt":"2026-02-02T10:10:18","guid":{"rendered":"https:\/\/labodemaths.fr\/WordPress3\/?p=3034"},"modified":"2026-02-03T07:42:47","modified_gmt":"2026-02-03T06:42:47","slug":"nsi-js-jeu-de-cible","status":"publish","type":"post","link":"https:\/\/labodemaths.fr\/WordPress3\/nsi-js-jeu-de-cible\/","title":{"rendered":"NSI, JS, jeu de cible"},"content":{"rendered":"\n<div class=\"wp-block-file\"><a href=\"https:\/\/labodemaths.fr\/WordPress3\/wp-content\/uploads\/2026\/02\/cible.png\">cible<\/a><a href=\"https:\/\/labodemaths.fr\/WordPress3\/wp-content\/uploads\/2026\/02\/cible.png\" class=\"wp-block-file__button\" download>T\u00e9l\u00e9charger<\/a><\/div>\n\n\n\n<p>le html<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"fr\"&gt;\n    &lt;head&gt;\n        &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n  &lt;link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\"&gt;\n&lt;link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin&gt;\n&lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Bowlby+One&amp;display=swap\" rel=\"stylesheet\"&gt;\n  &lt;title&gt;cible&lt;\/title&gt;\n  &lt;\/head&gt;\n&lt;body&gt;\n&lt;div id=\"plateau\"&gt;\n&lt;img id=\"cible1\" src=\"images\/cible.png\"&gt;\n&lt;\/div&gt;\n    &lt;\/body&gt;\n\t&lt;script src=\"script.js\"&gt;&lt;\/script&gt;\n\t&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>le css<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#cible1 {\n\tposition: absolute;\n\ttop: 500px;\n\tleft: 1200px;\n\t\n\t\n}\n\nimg {\n\t\n\twidth: 5%;\n\t\n}<\/code><\/pre>\n\n\n\n<p>le js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ tirer un nombre al\u00e9atoir entre 0 et 1200\nvar x1=Math.floor(Math.random()*1200);\n\/\/ tirer un nombre al\u00e9atoir entre 0 et 400\nvar y1=Math.floor(Math.random()*600);\n\/\/ recuperer l'image1 dans le html\nvar image1=document.getElementById(\"cible1\");\n\/\/ on positionne notre image1\nimage1.style.top=y1+\"px\";\nimage1.style.left=x1+\"px\";\nimage1.addEventListener(\"mousedown\",clique,false);\nvar points=0;\nsetInterval(bouge_cible, 1000)\n\nfunction clique(evt){\n\tpoints+=1;\n\tthis.style.top=Math.floor(Math.random()*600)+\"px\";\n\tthis.style.left=Math.floor(Math.random()*1200)+\"px\";\n\tdocument.getElementById(\"score\").textContent=points+\" points\";\n\t\n}\nfunction bouge_cible(){\n\t\n\t document.getElementById(\"cible1\").style.top=Math.floor(Math.random()*600)+\"px\";\n\t document.getElementById(\"cible1\").style.left=Math.floor(Math.random()*1200)+\"px\";\n\t\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>le html le css le js<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57],"tags":[],"_links":{"self":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3034"}],"collection":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/comments?post=3034"}],"version-history":[{"count":3,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3034\/revisions"}],"predecessor-version":[{"id":3038,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3034\/revisions\/3038"}],"wp:attachment":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media?parent=3034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/categories?post=3034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/tags?post=3034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}