Advertisement
Guest User

Untitled

a guest
Jul 20th, 2011
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Source by 51L3N7 */
  2.  
  3. // Como o objeto 'document' é usado muitas vezes no código, achei bom usar um with, para evitar mtas repetições
  4. // Assim, ao invés de ter que ficar colocando "document.metodo()" é só colocar "metodo()"
  5. with ( document ) {
  6.  
  7. //* Função usada para verificar qual a resposta dada pelo jogador (Mais a frente) *//
  8. function getReply( setReply ) {
  9.    
  10. //O switch verifica o valor do parametro setReply, e exibe na tela a resposta adequada
  11. switch ( setReply ) {
  12. case 1: showText.innerHTML = 'Então o homem diz: Há um quartinho próximo a aquela casa abandonada que alugam para turistas em épocas como esta.'
  13.                              + ' Você pode ir até lá e pedir informações. '
  14.                              + 'Mas fique em alerta pois, há algum tempo pessoas estão morrendo de forma mistériosa na cidade';
  15. break;
  16.                
  17. case 2: showText.innerHTML = 'O homem logo o repreende dizendo: Se acalme meu jovem. Entendo tua apreensão pela fama'
  18.                              + 'que esta cidade tem afora. Mas não sou o que aparento ser. As pessoas mais antigas desta cidade costumam voltar dos bares tarde da noite';
  19. break;
  20.        
  21. case 3: showText.innerHTML = 'Rapidamente o estranho homem arremessa sua faca da qual atinge em cheio a sua testa. '
  22.                              + 'Você morre e a história acaba<br /><br />' + '<div style="font-size:50px;text-align:center;color:red;margin-left:200px;margin-top:150px">Game over.</div>'.bold();
  23. break;
  24. } // Fim do switch
  25.  
  26. //* Adiciona a página o elemento "reticence" e remove os elementos "showQuestion" e etc, que são as perguntas            
  27. getElementById( 'showText' ).appendChild( reticence );
  28. getElementsByTagName( 'body' )[0].removeChild( showQuestion );
  29. getElementsByTagName( 'body' )[0].removeChild( showQuestion2 );
  30. getElementsByTagName( 'body' )[0].removeChild( showQuestion3 );
  31.                        
  32. } // Fim da função
  33.  
  34. //Título da página       
  35. title = 'Solo RPG Adventure 2011';
  36.  
  37. //Background da página
  38. body.style.backgroundImage = "url('http://img824.imageshack.us/img824/9176/unled2kt.png')";
  39.  
  40. //* Cria os elementos HTML para serem usados mais abaixo *//       
  41. var getChar      = createElement( 'input' ),
  42.     setChar      = createElement( 'input' ),
  43.     Continue     = createElement( 'input' ),
  44.     Continue2    = createElement( 'input' ),
  45.     description  = createElement( 'span' ),
  46.     reticence    = createElement( 'span' ),
  47.     showName     = createElement( 'div' ),
  48.     showText     = createElement( 'div' ),
  49.     showQuestion = createElement( 'a' ),
  50.     showQuestion2 = createElement( 'a' ),
  51.     showQuestion3 = createElement( 'a' );  
  52.        
  53. //* input text *//
  54. getChar.setAttribute( 'type', 'text' ); //Define o que o input é de texto
  55. getChar.setAttribute( 'id', 'getCharName' );  //Define uma id ao input (Que serve pra pegar o nome do jogador)
  56. getChar.style.left = '450px'; //Usado pra centralizar o input
  57. getChar.style.top = '250px'; //Idem
  58. getChar.style.position = 'absolute'; //Idem
  59. getChar.style.fontFamily = 'Courier New'; //Muda o tipo da família da fonte do digitado no input    
  60.        
  61. //* input button *//
  62. setChar.setAttribute( 'type', 'button' ); //Define que o input é um butão
  63. setChar.setAttribute( 'value', 'Começar!' ); //Dá um nome ao botão
  64. setChar.style.left = '482px'; //Serve pra centralizar o botão
  65. setChar.style.top = '275px'; //Idem
  66. setChar.style.position = 'absolute'; //Idem
  67. setChar.style.padding = '10px'; //Acrescenta mais 10px de altura/largura ao redor do botão
  68. setChar.style.color = 'white'; //Muda a cor do nome do botão
  69. setChar.style.fontSize = '18px'; //Altera o tamanho da fonte
  70. setChar.style.cursor = 'pointer'; //Altera o tipo do cursor quando o mesmo for passado pelo botão
  71. setChar.style.background = '#069'; //Altera o fundo
  72. setChar.style.border = '0px'; //Deixa sem borda
  73. setChar.style.fontWeight = 'bold'; //Deixa a fonte como negrito
  74.    
  75. //* span *//
  76. description.style.left = '350px'; //Serve para centralizar o texto
  77. description.style.top = '230px'; //Idem
  78. description.style.position = 'absolute'; //Idem
  79. description.style.fontFamily = 'Courier New'; //Muda a família da fonte
  80. description.innerHTML = 'Digite um nome para o seu personagem:'; //Adiciona o texto
  81.        
  82. //* Nome *//
  83. showName.style.color = '#FFF'; //Altera a cor do texto
  84. showName.style.left = '250px';//Serve para centralizar  
  85. showName.style.position = 'absolute'; //Idem
  86. showName.style.fontSize = '50px'; //Idem
  87. showName.style.fontFamily = 'Comic Sans MS'; //Altera a família da fonte
  88. showName.innerHTML = 'Solo RPG Adventure 2011'; //Adiciona o texto
  89.        
  90. //* Adiciona ao corpo da página os elementos criados acima *//
  91. getElementsByTagName( 'body' )[0].appendChild( showName );
  92. getElementsByTagName( 'body' )[0].appendChild( getChar );
  93. getElementsByTagName( 'body' )[0].appendChild( setChar );  
  94. getElementsByTagName( 'body' )[0].appendChild( description );
  95.    
  96. //* Esse evento ocorre quando o botão é clicado *//
  97. setChar.onclick = function() {
  98.  
  99. //Verifica se o jogador digitou o nome do personagem
  100. //Se não digitou..
  101. if ( getElementById( 'getCharName' ).value == '' ) alert( 'Digite o nome do seu personagem.' );
  102.  
  103. //Se digitou..
  104. else {
  105.                        
  106. showText.setAttribute( 'id', 'showText' ); //Define um id
  107. getCharName = getElementById( 'getCharName' ).value; //Pega o nome do personagem
  108.  
  109. //Exibe o texto na tela. O metodo bold() serve para deixar o nome do personagem em negrito
  110. showText.innerHTML = getCharName.bold() + ' estava viajando em busca de aventuras até chegar a uma cidade temida'
  111.                      + 'por muitos como a mais violenta da região e por este motivo, '
  112.                      + 'era comum cidadãos andarem armados';  
  113. showText.style.color = 'gold'; //Mudar a cor do texto
  114. showText.style.top = '100px'; //Deixa o texto abaixo do nome do jogo
  115. showText.style.position = 'absolute'; //Idem
  116. showText.style.fontFamily = 'Tahoma'; //Muda a família da fonte
  117.  
  118. //Adiciona ao corpo da página o texto
  119. getElementsByTagName( 'body' )[0].appendChild( showText );
  120.            
  121. reticence.setAttribute( 'id', 'addReticence' ); //Define um id
  122. getElementById( 'showText' ).appendChild( reticence ); //Adiciona ao id "showText" o elemento "reticence"
  123.  
  124. //* Serve para acrescentar 3 pontos de cada texto na página
  125. //Ex: . .. ... --> . .. ... e assim por diante
  126. add = '';
  127. function counter() {
  128. add += '.'; //Adiciona a variavel add um ponto ( . )
  129. setTimeout( counter, 1000 ); //Chama a função a cada mil milissegundos (1 segundo)
  130. getElementById( 'addReticence' ).innerHTML = add; //Adiciona ao id "addReticence" a variavel add
  131. if ( add.length == 3 ) add = '';  //Verifica se o add tem 3 pontos. Se tiver, zera a variavel.
  132. }
  133. counter(); //Chama a função
  134.  
  135. //* Remove os elementos getChar, setChar e description do corpo da página *//                     
  136. getElementsByTagName( 'body' )[0].removeChild( getChar );
  137. getElementsByTagName( 'body' )[0].removeChild( setChar );
  138. getElementsByTagName( 'body' )[0].removeChild( description );
  139.                        
  140. Continue.setAttribute( 'type', 'button' ); //Define o input com um botão
  141. Continue.value = "Continuar..."; //Nome do botão
  142. Continue.style.top = '150px'; //Adiciona o botão abaixo do texo (showText)
  143. Continue.style.position = 'absolute'; //Idem
  144. getElementsByTagName( 'body' )[0].appendChild( Continue ); //Adiciona o botão ao corpo da página
  145.  
  146. //Quando o botão for clicado:                     
  147. Continue.onclick = function() {
  148.  
  149. //Remove o primeiro botão
  150. getElementsByTagName( 'body' )[0].removeChild( Continue );
  151.  
  152. //Muda o texto
  153. showText.innerHTML = 'Ao chegar na cidade as 2:45 da madrugada logo percebeu-se que a rua estava deserta'
  154.                       + 'não havia ninguém pois, provavelmente todos estavam dormindo naquele horario.'
  155.                       + 'Então, ' + getCharName.bold() + ' resolve procurar um lugar para se hospedar. Quando de repente, sente que alguém estava lhe seguindo.'
  156.                       + 'Instintivamente, ' + getCharName.bold() + ' olha para trás e ver um vulto de alguém que aparentemente se escondera.'
  157.                       + ' Desconfiado(a), então resolve apressar o passo em direção a uma esquina mais iluminada';
  158. Continue.style.top = '185px'; //Abaixa um pouco mais o botão
  159. getElementById( 'showText' ).appendChild( reticence ); //Adiciona ao id "showText" o elemento "reticence"
  160.                                
  161. Continue2.setAttribute( 'type', 'button' ); //Define como um botão
  162. Continue2.value = "Continuar..."; //Nome do botão
  163. Continue2.style.top = '190px'; //Define a posição do botão
  164. Continue2.style.position = 'absolute'; //Idem
  165. getElementsByTagName( 'body' )[0].appendChild( Continue2 ); //Adiciona o botão ao corpo da página
  166.  
  167. //Quando o botão for clicado:             
  168. Continue2.onclick = function() {
  169.  
  170. //Remove-se então o segundo botão
  171. getElementsByTagName( 'body' )[0].removeChild( Continue2 );    
  172.  
  173. //Troca o texto da página                         
  174. showText.innerHTML = 'De repente, o que parecia um vulto, se mostra em forma de um homem em meia luz da esquina com um capuz'
  175.                                                               + ' cobrindo seu rosto e o aborda perguntando: ' + 'O que faz aquí a esta hora da noite jovem?'.bold();
  176. getElementById( 'showText' ).appendChild( reticence ); //Adiciona o elemento "Reticence" a id "showText"
  177.  
  178. //* Primeira pergunta *//                                      
  179. showQuestion.setAttribute( 'href', 'javascript:getReply(1)' ); //Chama a função getReply() com o parametro definido com 1
  180. //Texto da pergunta
  181. showQuestion.innerHTML = '1 – Responder ao homem: Sou de fora e estou perdido nesta cidade. Pode me informar um lugar bom para hospedar-me??'
  182. showQuestion.style.top = '150px'; //Posição da pergunta
  183. showQuestion.style.position = 'absolute'; //Idem
  184.  
  185. //* Segunda pergunta *//
  186. showQuestion2.setAttribute( 'href', 'javascript:getReply(2)' ); //Chama a função getReply() com o parametro definido com 2
  187. //Texto da pergunta
  188. showQuestion2.innerHTML = '2 – Responder ao homem: Porque você quer saber? Por acaso pedi a tua ajuda?';
  189. showQuestion2.style.top = '200px'; //Posição da pergunta
  190. showQuestion2.style.position = 'absolute';//Idem
  191.  
  192. //* Terceira pergunta *//
  193. showQuestion3.setAttribute( 'href', 'javascript:getReply(3)' ); //Chama a função getReply() com o parametro definido com 3
  194. //Texto da pergunta
  195. showQuestion3.innerHTML = '3 – Agir contra o homem: Nome saca a arma que tem pendurada '
  196.                           + 'no cinto e o ameaça dizendo: Vá embora antes que eu atire.';
  197. showQuestion3.style.top = '235px'; //Posição da pergunta
  198. showQuestion3.style.position = 'absolute'; //Idem  
  199.  
  200. //Adiciona ao corpo da página as perguntas                                    
  201. getElementsByTagName( 'body' )[0].appendChild( showQuestion );
  202. getElementsByTagName( 'body' )[0].appendChild( showQuestion2 );
  203. getElementsByTagName( 'body' )[0].appendChild( showQuestion3 );
  204. }
  205. }
  206. }  
  207. }      
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement