Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <style>
- img{
- width: 300px;
- height: 300px;
- }
- td{
- border: solid;
- width: 350px;
- }
- button{
- font-family: "Comic Sans MS";
- font-size: 20px;
- }
- p{
- font-size: 20px;
- }
- </style>
- </head>
- <script>
- var cont=5;
- var contmanzanas=0;
- var monedas=0;
- var acumulador= contmanzanas + monedas;
- var segundos=59;
- function carga(){
- alert("Tienes 1 minuto para conseguir monedas");
- setTimeout(final,60000);
- setInterval(tiempo,1000);
- document.getElementById("u5").innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
- }
- function final(){
- alert("Has conseguido "+monedas+" Monedas");
- location.reload(true);
- }
- function tiempo(){
- segundos--;
- document.getElementById("cronometro").innerHTML="Tiempo: "+segundos;
- }
- function right(){
- if(cont < 5){
- document.getElementById("u"+cont).innerHTML='';
- cont++
- document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
- }
- else{
- alert("no puedes ir mas a la derecha")
- }
- document.getElementById("camion").style.transform="scalex(1)";
- }
- function left(){
- if(contmanzanas == 0 && cont==1){
- alert("Error, no puedes vender estando en la primera casilla o sin tener manzanas")
- }
- if(cont > 1){
- document.getElementById("u"+cont).innerHTML='';
- cont=cont-1
- document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
- setTimeout(left,200)
- }
- else{
- monedas+=contmanzanas;
- contmanzanas=0;
- document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
- document.getElementById("moneda").innerHTML="Contador de monedas: "+monedas;
- }
- document.getElementById("camion").style.transform="scalex(-1)";
- }
- function manzanas(){
- if(cont == 5){
- contmanzanas++;
- document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
- }
- else{
- document.getElementById("manzanita").innerHTML="Contador de manzanas: "+contmanzanas;
- }
- }
- function mover(){
- if(cont==5){
- alert("Error, ya estas en la ultima casilla")
- }
- document.getElementById("u"+cont).innerHTML='';
- cont=5
- document.getElementById("u"+cont).innerHTML='<img src="camion.jpg" id="camion" onclick="manzanas()">';
- }
- </script>
- <body onLoad="carga()">
- <table>
- <tr>
- <td id="u1"></td>
- <td id="u2"></td>
- <td id="u3"></td>
- <td id="u4"></td>
- <td id="u5"></td>
- </tr>
- </table>
- <button id="izquierda" onclick="left()"> Vender</button>
- <button id="derecha" onclick="mover()"> Mover</button>
- <p id="manzanita"></p>
- <img src="manzana.jpg">
- <p id="moneda"></p>
- <p id="cronometro">Tiempo: 59</p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement