Commit 67fc7eaa by Angel Zarate

Tarea js

parents
img {
width: 50px ;
height: 50px;;
}
div {
text-align: center;
background-color: wheat;
margin: 30px;
border: 10px;
}
.btn {
color:black;
text-align: center;
background-color: whitesmoke;
}
h1{
font-family: Georgia, 'Times New Roman', Times, serif;
}
form{
text-align: center;
}
body{
background-color: crimson;
}
<!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>
function imagenes(){
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"
}
imagenes();
function lanzar()
{
var randomdice=Math.round(Math.random()*5);
document.images["dado"].src=eval("face"+randomdice+".src");
document.images["dado(1)"].src=eval("face"+randomdice+".src");
document.images["dado(2)"].src=eval("face"+randomdice+".src");
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment