Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. img{
  8. width: 300px;
  9. height: 300px;
  10.  
  11. }
  12. td{
  13. border: solid;
  14. width: 350px;
  15. }
  16. button{
  17. font-family: "Comic Sans MS";
  18. font-size: 20px;
  19. }
  20. p{
  21. font-size: 20px;
  22. }
  23. </style>
  24. </head>
  25. <script>
  26. var cont=5;
  27. var contmanzanas=0;
  28. var monedas=0;
  29. var acumulador= contmanzanas + monedas;
  30. var segundos=59;
  31. function carga(){
  32. alert("Tienes 1 minuto para conseguir monedas");
  33. setTimeout(final,60000);
  34. setInterval(tiempo,1000);
  35. document.getElementById("u5").innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
  36. }
  37. function final(){
  38. alert("Has conseguido "+monedas+" Monedas");
  39. location.reload(true);
  40. }
  41. function tiempo(){
  42. segundos--;
  43. document.getElementById("cronometro").innerHTML="Tiempo: "+segundos;
  44. }
  45. function right(){
  46. if(cont < 5){
  47. document.getElementById("u"+cont).innerHTML='';
  48. cont++
  49. document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
  50. }
  51. else{
  52. alert("no puedes ir mas a la derecha")
  53. }
  54. document.getElementById("camion").style.transform="scalex(1)";
  55. }
  56. function left(){
  57. if(contmanzanas == 0 && cont==1){
  58. alert("Error, no puedes vender estando en la primera casilla o sin tener manzanas")
  59. }
  60. if(cont > 1){
  61. document.getElementById("u"+cont).innerHTML='';
  62. cont=cont-1
  63. document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
  64. setTimeout(left,200)
  65. }
  66. else{
  67. monedas+=contmanzanas;
  68. contmanzanas=0;
  69. document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
  70. document.getElementById("moneda").innerHTML="Contador de monedas: "+monedas;
  71. }
  72.  
  73. document.getElementById("camion").style.transform="scalex(-1)";
  74. }
  75. function manzanas(){
  76. if(cont == 5){
  77. contmanzanas++;
  78. document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
  79. }
  80. else{
  81. document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
  82. }
  83. }
  84. function mover(){
  85. if(cont==5){
  86. alert("Error, ya estas en la ultima casilla")
  87. }
  88. document.getElementById("u"+cont).innerHTML='';
  89. cont=5
  90. document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
  91. }
  92. </script>
  93. <body onLoad="carga()">
  94. <table>
  95. <tr>
  96. <td id="u1"></td>
  97. <td id="u2"></td>
  98. <td id="u3"></td>
  99. <td id="u4"></td>
  100. <td id="u5"></td>
  101. </tr>
  102. </table>
  103. <button id="izquierda" onclick="left()"> Vender</button>
  104. <button id="derecha" onclick="mover()"> Mover</button>
  105.  
  106. <p id="manzanita"></p>
  107. <img src="manzana.jpg">
  108. <p id="moneda"></p>
  109. <p id="cronometro">Tiempo: 59</p>
  110. </body>
  111. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement