noobinhu 38 Postado Abril 12, 2009 Share Postado Abril 12, 2009 Estava meio sem o que fazer, fiz um joguinho, com JS/HTML/CSS: <html><head> <title>Jogo Simples em JS</title> </head> <style type="text/css"> body { background-color: black; margin-left: 20px; margin-top: 20px; color: white; } div#jogo { border: 1px solid white; width:400px; height:300px; } .botao { width:21px; height:21px; background-color: white; position:relative; } </style> <script language="javascript"> var started = 0; var pontos = 0; var segundos = 0; function bemvindo() { alert("Bem vindo!\nPara começar um jogo, clique em Iniciar."); } function rand( min, max ) { // http://kevin.vanzonneveld.net // + original by: Leslie Hoare // + bugfixed by: Onno Marsman // * example 1: rand(1, 1); // * returns 1: 1 var argc = arguments.length; if (argc == 0) { min = 0; max = 2147483647; } else if (argc == 1) { throw new Error('Warning: rand() expects exactly 2 parameters, 1 given'); } return Math.floor(Math.random() * (max - min + 1)) + min; } function randomBotao() { if (started == 1) { var botao = document.getElementById("mainbutton"); var rand_width = rand(25,375); var rand_height = rand(25,275); botao.style.top = rand_height+"px"; botao.style.left = rand_width+"px"; setTimeout("randomBotao();",2000); } } function pontuar() { if (started == 1) { var botao = document.getElementById("mainbutton"); var rand_width = rand(25,375); var rand_height = rand(25,275); botao.style.top = rand_height+"px"; botao.style.left = rand_width+"px"; pontos++; document.getElementById("pontuacao").innerHTML = pontos; } } function iniciarjogo() { if (confirm("Você deseja começar um novo jogo?") == true) { alert("Jogo iniciado.\nPara jogar, basta clicar o máximo de vezes no quadrado que aparecerá na tela."); pontos = 0; started = 1; document.getElementById("mainbutton").style.display = "block"; randomBotao(); segundos = 60; document.getElementById("tempo_restante").innerHTML = segundos; iniciarTimer(); document.getElementById("pontuacao").innerHTML = 0; } else { alert("Jogo não iniciado."); } } function iniciarTimer() { if (segundos > 1) { segundos = segundos - 1; document.getElementById("tempo_restante").innerHTML = segundos; setTimeout("iniciarTimer();",1000); } else { segundos = 0; document.getElementById("tempo_restante").innerHTML = segundos; alert("Jogo terminado!\nPontos feitos: "+pontos+""); pontos = 0; started = 0; document.getElementById("pontuacao").innerHTML = 0; document.getElementById("mainbutton").style.display = "none"; } } </script> <body onload="bemvindo();"> <input type="button" value="Iniciar" onclick="iniciarjogo();" /> <br><br> <div id="jogo"><input type="button" value=" " onClick="pontuar();" id="mainbutton" class="botao" style="display:none;"/></div><br> <div style="margin-left:30px;"><b>Pontos:</b> <span id="pontuacao">0</span> <b>Segundos Restantes:</b> <span id="tempo_restante">0</span> </div> </body> </html> Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/ Compartilhar em outros sites More sharing options...
Darkanso 1 Postado Maio 13, 2009 Share Postado Maio 13, 2009 (editado) Nusss joguinho viciante, kkk achei bem legalzinho, max de pontos que consegui foi 80, so muito lento, o quadradinho é esperto ele se move as vezes do nada. Mas ta de parabéns, jogo bem elaborado e bem inteligente, é um bom jogo pra raciosinio, pelo menos eu não faria melhor. Atensiosamente, Darkanso. Editado Maio 13, 2009 por Darkanso Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-738430 Compartilhar em outros sites More sharing options...
Pisico 0 Postado Junho 15, 2009 Share Postado Junho 15, 2009 ta i como eu faço pra joga? Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-749811 Compartilhar em outros sites More sharing options...
joaohd 200 Postado Junho 19, 2009 Share Postado Junho 19, 2009 Manero. ta de parabéns. só tem 1 coisinha... ninguem me vence "Jogo terminado! Pontos feitos: 624" <font size="5">è só segurar enter q vai</font> Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-750908 Compartilhar em outros sites More sharing options...
-Fark- 4 Postado Junho 20, 2009 Share Postado Junho 20, 2009 Desculpa a pegunta retardada maiss... Como se joga isso ? O_o Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-751006 Compartilhar em outros sites More sharing options...
Vilden 137 Postado Junho 25, 2009 Share Postado Junho 25, 2009 tbm quero saber como joga isso fiquei curioso :x Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-752859 Compartilhar em outros sites More sharing options...
guilhermes26 26 Postado Junho 25, 2009 Share Postado Junho 25, 2009 Simples, copiem isso e salvem como .htm Depois é só abrir. Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-752863 Compartilhar em outros sites More sharing options...
Vilden 137 Postado Junho 25, 2009 Share Postado Junho 25, 2009 Daniel ainda nao entendi.. tipo copia isso e usa oq pra salva so burrin assim mesmo :X Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-752867 Compartilhar em outros sites More sharing options...
-Fark- 4 Postado Junho 28, 2009 Share Postado Junho 28, 2009 eu ja saquei... tipo assim: abre um bloco de notas, copia o texto que esta logo ali ^ e cole no bloco de notos... clique em : salvar como... ai vc salva assim: Qualquer nome.html e salva e depois abre.... intendeu ? Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-753968 Compartilhar em outros sites More sharing options...
satan666 12 Postado Junho 29, 2009 Share Postado Junho 29, 2009 uashuahsuahsuahsa parece o tibia quando surgiu.... igualzinho ate os graficos Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-754721 Compartilhar em outros sites More sharing options...
skynagerloas 1 Postado Julho 28, 2009 Share Postado Julho 28, 2009 (editado) Bom, peguei o Código e dei uma Modificada e incrementei algumas coisinhas. <html><head> <title>Jogo Simples em JS</title> </head> <style type="text/css"> body { background-color: black; margin-left: 20px; margin-top: 20px; color: white; } div#jogo { border: 1px solid white; width: 400px; height: 300px; } .botao { width: 21px; height: 21px; background-color: white; position: relative; } </style> <script language="javascript"> var started = 0; var pontos = 0; var segundos = 0; var record = 0; var velocidade = 20; function bemvindo() { alert("Bem vindo!\nPara começar um jogo, clique em Iniciar."); } function rand( min, max ) { // http://kevin.vanzonneveld.net // + original by: Leslie Hoare // + bugfixed by: Onno Marsman // * example 1: rand(1, 1); // * returns 1: 1 var argc = arguments.length; if (argc == 0) { min = 0; max = 2147483647; } else if (argc == 1) { throw new Error('Warning: rand() expects exactly 2 parameters, 1 given'); } return Math.floor(Math.random() * (max - min + 1)) + min; } function randomBotao() { if (started == 1){ var botao = document.getElementById("mainbutton"); var rand_width = rand(25,375); var rand_height = rand(25,275); botao.style.top = rand_height+"px"; botao.style.left = rand_width+"px"; setTimeout("randomBotao();",velocidade*100); } } function pontuar() { if (started == 1) { var botao = document.getElementById("mainbutton"); var rand_width = rand(25,375); var rand_height = rand(25,275); botao.style.top = rand_height+"px"; botao.style.left = rand_width+"px"; pontos++; if ((pontos%10)==0){ velocidade--; if (velocidade == 0){ started = 0; if (pontos > record){ record = pontos; document.getElementById("record").innerHTML = record; } alert("VOCE GANHOU!!!. Pontos feitos: "+pontos+"\nRecord: "+record+""); } segundos= segundos+10; } document.getElementById("pontuacao").innerHTML = pontos; } } function iniciarjogo() { if (confirm("Você deseja começar um novo jogo?") == true) { alert("Jogo iniciado.\nPara jogar, basta clicar o máximo de vezes no quadrado que aparecerá na tela."); pontos = 0; started = 1; document.getElementById("mainbutton").style.display = "block"; randomBotao(); segundos = 60; document.getElementById("tempo_restante").innerHTML = segundos; iniciarTimer(); document.getElementById("pontuacao").innerHTML = 0; } else { alert("Jogo não iniciado."); } } function iniciarTimer() { if (segundos > 1) { segundos = segundos - 1; document.getElementById("tempo_restante").innerHTML = segundos; setTimeout("iniciarTimer();",1000); } else { segundos = 0; document.getElementById("tempo_restante").innerHTML = segundos; if (pontos > record){ record = pontos; document.getElementById("record").innerHTML = record; } alert("Jogo terminado!\nPontos feitos: "+pontos+"\nRecord: "+record+""); pontos = 0; started = 0; document.getElementById("pontuacao").innerHTML = 0; document.getElementById("mainbutton").style.display = "none"; } } </script> <body onload="bemvindo();"> <input type="button" value="Iniciar" onMouseUP="iniciarjogo();" /> <font color="#0055FF" lang="Verdana">Para reiniciar o record, aperte "F5"</font> <br> <br> <div id="jogo"><input type="button" value=" " onMouseUp="pontuar();" id="mainbutton" class="botao" style="display: none;" /></div> <br> <div style="margin-left: 30px;"><b>Pontos:</b> <span id="pontuacao">0</span> <b>Segundos Restantes:</b> <span id="tempo_restante">0</span><b><br>Record:</b><span id="record">0</span></div> </body> </html> Créditos: Leslie HoareOnno MarsmannoobinhuSky Editado Julho 28, 2009 por Sky Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-769214 Compartilhar em outros sites More sharing options...
Diogo 29 Postado Abril 15, 2010 Share Postado Abril 15, 2010 Clique uma vez, segure o espaço e seja um verdadeiro vencedor. Link para o comentário https://xtibia.com/forum/topic/111206-jogo-simples-em-js/#findComment-863081 Compartilhar em outros sites More sharing options...
Posts Recomendados