index.html 2.13 KB
Newer Older
Angel Zarate committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>TAREA_JS</title>
    <link rel="stylesheet" href="alinear.css" />
    <script type="text/javascript" src="tarea.js"></script>
  </head>
  <body>
    <center><h1>jugador tire su dado</h1></center>
    <form class="boton">
      <input class="btn" type="button" value="Lanza dado" onClick="lanzar()" />
    </form>
    <div>
      <img src="" name="dado" />
      <img src="./dado (1).png" name="dado(1)" />
      <img src="./dado (2).png" name="dado(5)" />
      <img src="./dado (3).png" name="dado(3)" />
      <img src="./dado (4).png" name="dado(2)" />
      <img src="./dado (5).png" name="dado(4)" />
    </div>
  </body>
  <!-- function myfuncion(a, b, c) {
        return (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
      }
      myfuncion(4, -64, 2);   -->

  <!--  function tirardados() {
        
      }
      tirardados();
    </script>*/  -->

  <script>
    var face0 = new Image();
    face0.src = "./dado.png";
    var face1 = new Image();
    face1.src = "./dado (1).png";
    var face2 = new Image();
    face2.src = "./dado (2).png";
    var face3 = new Image();
    face3.src = "./dado (3).png";
    var face4 = new Image();
    face4.src = "./dado (4).png";
    var face5 = new Image();
    face5.src = "./dado (5).png";

    function lanzar() {
      var randomdice = Math.round(Math.random() * 5);
      var randomdos = Math.round(Math.random() * 5);
      var randomtres = Math.round(Math.random() * 5);
      var randomfour = Math.round(Math.random() * 5);
      document.images["dado"].src = eval("face" + randomdice + ".src");
      document.images["dado(1)"].src = eval("face" + randomdos + ".src");
      document.images["dado(3)"].src = eval("face" + randomtres + ".src");
      document.images["dado(4)"].src = eval("face" + randomfour + ".src");
      document.images["dado(5)"].src = eval("face" + randomdice + ".src");
      document.images["dado(2)"].src = eval("face" + randomdice + ".src");
    }
  </script>
</html>