WapegoShare game wapego 3

12 bài đăng
17.05.2018 / 22:30
nguyentuanh
Bài đăng: 25
Member
Có điều muốn hỏi

Hôm nay em xin share 1 game

Đi thẵng vào vấn đề chính luôn

Game này là game rắn săn mồi ( ai xài đập đá chắc biết rồi)

Demo :http://3x4rum.gowap.lt/main.php?f=3644385

Code này em đã gộp chung : html,js,css rồi nên mấy bác cứ thêm html -> dán code vào là sữ dụng thôi

Sẵn bác nào có code xóa qc đầu trang cuối trang wapego cho e xin , hướng dẫn e sữ dụng luôn :')

///code

<!doctype html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1" >

<style type="text/css">

@import url('https://fonts.googleapis.com/css?family=Acme|Josefin+Sans');

@import url('https://fonts.googleapis.com/css?family=Architects+Daughter');

body{

margin:0px;

padding:0px;

background:#78dfff;

max-width:700px;

}

header{

height:30px;

background:#e93330;

}

#hl{

width:40%;

float:left;

padding-left:5%;

padding-top:5px;

color:#fff;

font-weight:900;

font-family: 'Acme', sans-serif;

}

#hr{

width:40%;

float:right;

text-align:right;

padding-right:5%;

padding-top:5px;

color:#fff;

font-weight:900;

font-family: 'Acme', sans-serif;

}

#DIV{

width:300px;

margin:0 auto;

}

p{

height:10px;

width:10px;

background:#000;

position:relative;

display:inline-block;

margin:0px;

padding:0px;

line-height:10px;

}

button{

transform:translateY(-270px);

-moz-transform:translateY(-270px);

-webkit-transform:translateY(-270px);

-ms-transform:translateY(-270px);

width:30%;

height:40px;

margin:0;

padding:0;

border:2px solid blue;

border-radius:30px;

}

.ud{

margin:5px 30%;

}

#l{

margin:5px 2% 5px 13%;

font-size:18px;

}

#r{

margin:5px 13% 5px 2%;

font-size:18px;

}

#d span{

display:block;

-moz-transform:rotateX(180deg);

-webkit-transform:rotateX(180deg);

-ms-transform:rotateX(180deg);

transform:rotateX(180deg);

font-size:20px;

margin-top:-5px;

}

#u span{

margin-top:5px;

display:block;

font-size:20px;

}

#load{

background:#000;

position:absolute;

top:0;

left:0;

height:100%;

width:100%;

z-index:500;

color:#fff;

}

#cp{

width:300px;

margin:25px auto;

}

#bd{

width:100%;

background-color:#eee;

border-radius:3px;

padding:1px;

box-shadow:inset 0px 3px 1px #ddd;

}

#bf{

display:block;

width:0%;

height:10px;

background-color:#0f9816;

border-radius:3px;

transition:width 0.05s ease;

}

h4,h3{

font-family: 'Architects Daughter', cursive;

text-align:center;

}

</style>

</head>

<body onload="mover()">

<div id="load">

<h1 style="text-align:center;">Snake</h1>

<h3>loading....</h3>

<div id="cp">

<div id="bd"><span id="bf"></span></div>

</div>

<script>

var e = document.querySelector("#bf");

var w = 0;

var interval=setInterval(function(){

e.style.width=w+"%";

w=w+1;

if(w==100){document.getElementById("load").style.display="none";}

},50);

</script>

<h4>Created by: 3x4rum</h4>

</div>

<header>

<div id="hl">Your Score :</div>

<div id="hr">0</div>

</header>

<div id="DIV">

</div>

<button id="u" class="ud" onclick="moveu()"><span>^^^</span></button><br>

<button id="l" onclick="movel()"><<<</button>

<button id="r" onclick="mover()">>>></button><br>

<button id="d" class="ud" onclick="moved()"><span>^^^</span></button>

<script>

for(n=0;n<900;n++){

var para = document.createElement("p");

var DIV = document.getElementById("DIV");

var PARA = document.getElementById("para1");

DIV.insertBefore(para, PARA);}

for(m=0;m<900;m++){

var dd = Math.floor(m/30);

document.getElementsByTagName("p")[m].style.transform="translateY(-"+dd*10+"px)";

document.getElementsByTagName("p")[m].style.mozTransform="translateY(-"+dd*10+"px)";

document.getElementsByTagName("p")[m].style.webkitTransform="translateY(-"+dd*10+"px)";

document.getElementsByTagName("p")[m].style.msTransform="translateY(-"+dd*10+"px)";}

var bd=[464,465];

var intv1;

var intv2;

var intv3;

var intv4;

var pnt=Math.floor(Math.random()*900);

var score=0;

function moved(){

clearInterval(intv2);

clearInterval(intv3);

clearInterval(intv4);

document.getElementById("u").disabled=true;

document.getElementById("d").disabled=true;

document.getElementById("r").disabled=false;

document.getElementById("l").disabled=false;

intv1=setInterval(function(){

var ttt=bd[bd.length-1]+30;

if(ttt>899){

ttt=ttt-900;}

if(bd.indexOf(ttt)>0){

document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");

clearInterval(intv1);}

else{

bd.push(ttt);

if(ttt==pnt){

score+=10;

document.getElementById("hr").innerHTML=score;

pnt=Math.floor(Math.random()*900);}

else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}

for(l=0;l<bd.length;l++){

document.getElementsByTagName("p")[bd[l]].style.background="blue";}

document.getElementsByTagName("p")[pnt].style.background="red";

}},200)}

function mover(){

clearInterval(intv1);

clearInterval(intv3);

clearInterval(intv4);

document.getElementById("r").disabled=true;

document.getElementById("l").disabled=true;

document.getElementById("u").disabled=false;

document.getElementById("d").disabled=false;

intv2=setInterval(function(){

var ttt=bd[bd.length-1]+1;

if(ttt%30==0){

ttt=ttt-30;}

if(bd.indexOf(ttt)>0){

document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");

clearInterval(intv2);}

else{

bd.push(ttt);

if(ttt==pnt){

score+=10;

document.getElementById("hr").innerHTML=score;

pnt=Math.floor(Math.random()*900);}

else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}

for(l=0;l<bd.length;l++){

document.getElementsByTagName("p")[bd[l]].style.background="blue";}

document.getElementsByTagName("p")[pnt].style.background="red";}},200)}

function movel(){

clearInterval(intv1);

clearInterval(intv2);

clearInterval(intv4);

document.getElementById("r").disabled=true;

document.getElementById("l").disabled=true;

document.getElementById("u").disabled=false;

document.getElementById("d").disabled=false;

intv3=setInterval(function(){

var ttt=bd[bd.length-1]-1;

if(ttt%30==29 && ttt>0){

ttt=ttt+30;}

if(ttt<0){ttt=ttt+30

} if(bd.indexOf(ttt)>0){

document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");

clearInterval(intv3);}

else{

bd.push(ttt);

if(ttt==pnt){

score+=10;

document.getElementById("hr").innerHTML=score;

pnt=Math.floor(Math.random()*900);}

else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}

for(l=0;l<bd.length;l++){

document.getElementsByTagName("p")[bd[l]].style.background="blue";

}

document.getElementsByTagName("p")[pnt].style.background="red";

}},200)}

function moveu(){

clearInterval(intv1);

clearInterval(intv2);

clearInterval(intv3);

document.getElementById("u").disabled=true;

document.getElementById("d").disabled=true;

document.getElementById("r").disabled=false;

document.getElementById("l").disabled=false;

intv4=setInterval(function(){

var ttt=bd[bd.length-1]-30;

if(ttt<0){

ttt=ttt+900;}

if(bd.indexOf(ttt)>0){

document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");

clearInterval(intv4);}

else{

bd.push(ttt);

if(ttt==pnt){

score+=10;

document.getElementById("hr").innerHTML=score;

pnt=Math.floor(Math.random()*900);}

else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}

for(l=0;l<bd.length;l++){

document.getElementsByTagName("p")[bd[l]].style.background="blue";}

document.getElementsByTagName("p")[pnt].style.background="red";}

},200)

}

</script>

</body>

</html>

17.05.2018 / 22:36
dat2013
Bài đăng: 376
Member
Tổn thương :(

Bỏ vào thẻ [code][/code] đi em

17.05.2018 / 22:44
Manhkhuyen99999
Bài đăng: 117
Member
YOUTUBER TRIỆU TRIỆU VIEW

Làm game chém nhau đi

17.05.2018 / 23:02
nguyentuanh
Bài đăng: 25
Member
Có điều muốn hỏi
Manhkhuyen99999 đã viết

Làm game chém nhau đi

:x bác đùa kkkkk

17.05.2018 / 23:02
nguyentuanh
Bài đăng: 25
Member
Có điều muốn hỏi
dat2013 đã viết

Bỏ vào thẻ [code][/code] đi em

E hk pit bác oi :')

17.05.2018 / 23:07
dat2013
Bài đăng: 376
Member
Tổn thương :(
nguyentuanh đã viết

E hk pit bác oi :')

[code&html]

Code ở đây

[/code]

Thay & bằng =

Đã chỉnh sửa. dat2013 (17.05.2018 / 23:08)
17.05.2018 / 23:09
Manhkhuyen99999
Bài đăng: 117
Member
YOUTUBER TRIỆU TRIỆU VIEW
nguyentuanh đã viết

:x bác đùa kkkkk

Làm game bắn súng chơi pk dc nữa càng tốt.

=)) Tôi ủng hộ ~

17.05.2018 / 23:11
nguyentuanh
Bài đăng: 25
Member
Có điều muốn hỏi
Manhkhuyen99999 đã viết

Làm game bắn súng chơi pk dc nữa càng tốt.

=)) Tôi ủng hộ ~

em có rồi :')

Nhưng bác đợi đi e đang đi tìm cách rút gọn code chứ dài quá wapego nó ko cho :((

17.05.2018 / 23:16
dat2013
Bài đăng: 376
Member
Tổn thương :(
HTML5
  1. <!doctype html>
  2.  
  3. <html>
  4.  
  5. <head>
  6.  
  7. <meta name="viewport" content="width=device-width, initial-scale=1" >
  8.  
  9. <style type="text/css">
  10.  
  11. @import url('https://fonts.googleapis.com/css?family=Acme|Josefin+Sans');
  12.  
  13. @import url('https://fonts.googleapis.com/css?family=Architects+Daughter');
  14.  
  15. body{
  16.  
  17. margin:0px;
  18.  
  19. padding:0px;
  20.  
  21. background:#78dfff;
  22.  
  23. max-width:700px;
  24.  
  25. }
  26.  
  27. header{
  28.  
  29. height:30px;
  30.  
  31. background:#e93330;
  32.  
  33. }
  34.  
  35. #hl{
  36.  
  37. width:40%;
  38.  
  39. float:left;
  40.  
  41. padding-left:5%;
  42.  
  43. padding-top:5px;
  44.  
  45. color:#fff;
  46.  
  47. font-weight:900;
  48.  
  49. font-family: 'Acme', sans-serif;
  50.  
  51. }
  52.  
  53. #hr{
  54.  
  55. width:40%;
  56.  
  57. float:right;
  58.  
  59. text-align:right;
  60.  
  61. padding-right:5%;
  62.  
  63. padding-top:5px;
  64.  
  65. color:#fff;
  66.  
  67. font-weight:900;
  68.  
  69. font-family: 'Acme', sans-serif;
  70.  
  71. }
  72.  
  73. #DIV{
  74.  
  75. width:300px;
  76.  
  77. margin:0 auto;
  78.  
  79. }
  80.  
  81. p{
  82.  
  83. height:10px;
  84.  
  85. width:10px;
  86.  
  87. background:#000;
  88.  
  89. position:relative;
  90.  
  91. display:inline-block;
  92.  
  93. margin:0px;
  94.  
  95. padding:0px;
  96.  
  97. line-height:10px;
  98.  
  99. }
  100.  
  101. button{
  102.  
  103. transform:translateY(-270px);
  104.  
  105. -moz-transform:translateY(-270px);
  106.  
  107. -webkit-transform:translateY(-270px);
  108.  
  109. -ms-transform:translateY(-270px);
  110.  
  111. width:30%;
  112.  
  113. height:40px;
  114.  
  115. margin:0;
  116.  
  117. padding:0;
  118.  
  119. border:2px solid blue;
  120.  
  121. border-radius:30px;
  122.  
  123. }
  124.  
  125. .ud{
  126.  
  127. margin:5px 30%;
  128.  
  129. }
  130.  
  131. #l{
  132.  
  133. margin:5px 2% 5px 13%;
  134.  
  135. font-size:18px;
  136.  
  137. }
  138.  
  139. #r{
  140.  
  141. margin:5px 13% 5px 2%;
  142.  
  143. font-size:18px;
  144.  
  145. }
  146.  
  147. #d span{
  148.  
  149. display:block;
  150.  
  151. -moz-transform:rotateX(180deg);
  152.  
  153. -webkit-transform:rotateX(180deg);
  154.  
  155. -ms-transform:rotateX(180deg);
  156.  
  157. transform:rotateX(180deg);
  158.  
  159. font-size:20px;
  160.  
  161. margin-top:-5px;
  162.  
  163. }
  164.  
  165. #u span{
  166.  
  167. margin-top:5px;
  168.  
  169. display:block;
  170.  
  171. font-size:20px;
  172.  
  173. }
  174.  
  175. #load{
  176.  
  177. background:#000;
  178.  
  179. position:absolute;
  180.  
  181. top:0;
  182.  
  183. left:0;
  184.  
  185. height:100%;
  186.  
  187. width:100%;
  188.  
  189. z-index:500;
  190.  
  191. color:#fff;
  192.  
  193. }
  194.  
  195. #cp{
  196.  
  197. width:300px;
  198.  
  199. margin:25px auto;
  200.  
  201. }
  202.  
  203. #bd{
  204.  
  205. width:100%;
  206.  
  207. background-color:#eee;
  208.  
  209. border-radius:3px;
  210.  
  211. padding:1px;
  212.  
  213. box-shadow:inset 0px 3px 1px #ddd;
  214.  
  215. }
  216.  
  217. #bf{
  218.  
  219. display:block;
  220.  
  221. width:0%;
  222.  
  223. height:10px;
  224.  
  225. background-color:#0f9816;
  226.  
  227. border-radius:3px;
  228.  
  229. transition:width 0.05s ease;
  230.  
  231. }
  232.  
  233. h4,h3{
  234.  
  235. font-family: 'Architects Daughter', cursive;
  236.  
  237. text-align:center;
  238.  
  239. }
  240.  
  241. </style>
  242.  
  243. </head>
  244.  
  245. <body onload="mover()">
  246.  
  247. <div id="load">
  248.  
  249. <h1 style="text-align:center;">Snake</h1>
  250.  
  251. <h3>loading....</h3>
  252.  
  253. <div id="cp">
  254.  
  255. <div id="bd"><span id="bf"></span></div>
  256.  
  257. </div>
  258.  
  259. <script>
  260.  
  261. var e = document.querySelector("#bf");
  262.  
  263. var w = 0;
  264.  
  265. var interval=setInterval(function(){
  266.  
  267. e.style.width=w+"%";
  268.  
  269. w=w+1;
  270.  
  271. if(w==100){document.getElementById("load").style.display="none";}
  272.  
  273. },50);
  274.  
  275. </script>
  276.  
  277. <h4>Created by: 3x4rum</h4>
  278.  
  279. </div>
  280.  
  281. <header>
  282.  
  283. <div id="hl">Your Score :</div>
  284.  
  285. <div id="hr">0</div>
  286.  
  287. </header>
  288.  
  289. <div id="DIV">
  290.  
  291. </div>
  292.  
  293. <button id="u" class="ud" onclick="moveu()"><span>^^^</span></button><br>
  294.  
  295. <button id="l" onclick="movel()"><<<</button>
  296.  
  297. <button id="r" onclick="mover()">>>></button><br>
  298.  
  299. <button id="d" class="ud" onclick="moved()"><span>^^^</span></button>
  300.  
  301. <script>
  302.  
  303. for(n=0;n<900;n++){
  304.  
  305. var para = document.createElement("p");
  306.  
  307. var DIV = document.getElementById("DIV");
  308.  
  309. var PARA = document.getElementById("para1");
  310.  
  311. DIV.insertBefore(para, PARA);}
  312.  
  313. for(m=0;m<900;m++){
  314.  
  315. var dd = Math.floor(m/30);
  316.  
  317. document.getElementsByTagName("p")[m].style.transform="translateY(-"+dd*10+"px)";
  318.  
  319. document.getElementsByTagName("p")[m].style.mozTransform="translateY(-"+dd*10+"px)";
  320.  
  321. document.getElementsByTagName("p")[m].style.webkitTransform="translateY(-"+dd*10+"px)";
  322.  
  323. document.getElementsByTagName("p")[m].style.msTransform="translateY(-"+dd*10+"px)";}
  324.  
  325. var bd=[464,465];
  326.  
  327. var intv1;
  328.  
  329. var intv2;
  330.  
  331. var intv3;
  332.  
  333. var intv4;
  334.  
  335. var pnt=Math.floor(Math.random()*900);
  336.  
  337. var score=0;
  338.  
  339. function moved(){
  340.  
  341. clearInterval(intv2);
  342.  
  343. clearInterval(intv3);
  344.  
  345. clearInterval(intv4);
  346.  
  347. document.getElementById("u").disabled=true;
  348.  
  349. document.getElementById("d").disabled=true;
  350.  
  351. document.getElementById("r").disabled=false;
  352.  
  353. document.getElementById("l").disabled=false;
  354.  
  355. intv1=setInterval(function(){
  356.  
  357. var ttt=bd[bd.length-1]+30;
  358.  
  359. if(ttt>899){
  360.  
  361. ttt=ttt-900;}
  362.  
  363. if(bd.indexOf(ttt)>0){
  364.  
  365. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  366.  
  367. clearInterval(intv1);}
  368.  
  369. else{
  370.  
  371. bd.push(ttt);
  372.  
  373. if(ttt==pnt){
  374.  
  375. score+=10;
  376.  
  377. document.getElementById("hr").innerHTML=score;
  378.  
  379. pnt=Math.floor(Math.random()*900);}
  380.  
  381. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  382.  
  383. for(l=0;l<bd.length;l++){
  384.  
  385. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  386.  
  387. document.getElementsByTagName("p")[pnt].style.background="red";
  388.  
  389. }},200)}
  390.  
  391. function mover(){
  392.  
  393. clearInterval(intv1);
  394.  
  395. clearInterval(intv3);
  396.  
  397. clearInterval(intv4);
  398.  
  399. document.getElementById("r").disabled=true;
  400.  
  401. document.getElementById("l").disabled=true;
  402.  
  403. document.getElementById("u").disabled=false;
  404.  
  405. document.getElementById("d").disabled=false;
  406.  
  407. intv2=setInterval(function(){
  408.  
  409. var ttt=bd[bd.length-1]+1;
  410.  
  411. if(ttt%30==0){
  412.  
  413. ttt=ttt-30;}
  414.  
  415. if(bd.indexOf(ttt)>0){
  416.  
  417. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  418.  
  419. clearInterval(intv2);}
  420.  
  421. else{
  422.  
  423. bd.push(ttt);
  424.  
  425. if(ttt==pnt){
  426.  
  427. score+=10;
  428.  
  429. document.getElementById("hr").innerHTML=score;
  430.  
  431. pnt=Math.floor(Math.random()*900);}
  432.  
  433. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  434.  
  435. for(l=0;l<bd.length;l++){
  436.  
  437. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  438.  
  439. document.getElementsByTagName("p")[pnt].style.background="red";}},200)}
  440.  
  441. function movel(){
  442.  
  443. clearInterval(intv1);
  444.  
  445. clearInterval(intv2);
  446.  
  447. clearInterval(intv4);
  448.  
  449. document.getElementById("r").disabled=true;
  450.  
  451. document.getElementById("l").disabled=true;
  452.  
  453. document.getElementById("u").disabled=false;
  454.  
  455. document.getElementById("d").disabled=false;
  456.  
  457. intv3=setInterval(function(){
  458.  
  459. var ttt=bd[bd.length-1]-1;
  460.  
  461. if(ttt%30==29 && ttt>0){
  462.  
  463. ttt=ttt+30;}
  464.  
  465. if(ttt<0){ttt=ttt+30
  466.  
  467. } if(bd.indexOf(ttt)>0){
  468.  
  469. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  470.  
  471. clearInterval(intv3);}
  472.  
  473. else{
  474.  
  475. bd.push(ttt);
  476.  
  477. if(ttt==pnt){
  478.  
  479. score+=10;
  480.  
  481. document.getElementById("hr").innerHTML=score;
  482.  
  483. pnt=Math.floor(Math.random()*900);}
  484.  
  485. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  486.  
  487. for(l=0;l<bd.length;l++){
  488.  
  489. document.getElementsByTagName("p")[bd[l]].style.background="blue";
  490.  
  491. }
  492.  
  493. document.getElementsByTagName("p")[pnt].style.background="red";
  494.  
  495. }},200)}
  496.  
  497. function moveu(){
  498.  
  499. clearInterval(intv1);
  500.  
  501. clearInterval(intv2);
  502.  
  503. clearInterval(intv3);
  504.  
  505. document.getElementById("u").disabled=true;
  506.  
  507. document.getElementById("d").disabled=true;
  508.  
  509. document.getElementById("r").disabled=false;
  510.  
  511. document.getElementById("l").disabled=false;
  512.  
  513. intv4=setInterval(function(){
  514.  
  515. var ttt=bd[bd.length-1]-30;
  516.  
  517. if(ttt<0){
  518.  
  519. ttt=ttt+900;}
  520.  
  521. if(bd.indexOf(ttt)>0){
  522.  
  523. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  524.  
  525. clearInterval(intv4);}
  526.  
  527. else{
  528.  
  529. bd.push(ttt);
  530.  
  531. if(ttt==pnt){
  532.  
  533. score+=10;
  534.  
  535. document.getElementById("hr").innerHTML=score;
  536.  
  537. pnt=Math.floor(Math.random()*900);}
  538.  
  539. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  540.  
  541. for(l=0;l<bd.length;l++){
  542.  
  543. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  544.  
  545. document.getElementsByTagName("p")[pnt].style.background="red";}
  546.  
  547. },200)
  548.  
  549. }
  550.  
  551. </script>
  552.  
  553. </body>
  554.  
  555. </html>
17.05.2018 / 23:18
nguyentuanh
Bài đăng: 25
Member
Có điều muốn hỏi
dat2013 đã viết
HTML5
  1. <!doctype html>
  2.  
  3. <html>
  4.  
  5. <head>
  6.  
  7. <meta name="viewport" content="width=device-width, initial-scale=1" >
  8.  
  9. <style type="text/css">
  10.  
  11. @import url('https://fonts.googleapis.com/css?family=Acme|Josefin+Sans');
  12.  
  13. @import url('https://fonts.googleapis.com/css?family=Architects+Daughter');
  14.  
  15. body{
  16.  
  17. margin:0px;
  18.  
  19. padding:0px;
  20.  
  21. background:#78dfff;
  22.  
  23. max-width:700px;
  24.  
  25. }
  26.  
  27. header{
  28.  
  29. height:30px;
  30.  
  31. background:#e93330;
  32.  
  33. }
  34.  
  35. #hl{
  36.  
  37. width:40%;
  38.  
  39. float:left;
  40.  
  41. padding-left:5%;
  42.  
  43. padding-top:5px;
  44.  
  45. color:#fff;
  46.  
  47. font-weight:900;
  48.  
  49. font-family: 'Acme', sans-serif;
  50.  
  51. }
  52.  
  53. #hr{
  54.  
  55. width:40%;
  56.  
  57. float:right;
  58.  
  59. text-align:right;
  60.  
  61. padding-right:5%;
  62.  
  63. padding-top:5px;
  64.  
  65. color:#fff;
  66.  
  67. font-weight:900;
  68.  
  69. font-family: 'Acme', sans-serif;
  70.  
  71. }
  72.  
  73. #DIV{
  74.  
  75. width:300px;
  76.  
  77. margin:0 auto;
  78.  
  79. }
  80.  
  81. p{
  82.  
  83. height:10px;
  84.  
  85. width:10px;
  86.  
  87. background:#000;
  88.  
  89. position:relative;
  90.  
  91. display:inline-block;
  92.  
  93. margin:0px;
  94.  
  95. padding:0px;
  96.  
  97. line-height:10px;
  98.  
  99. }
  100.  
  101. button{
  102.  
  103. transform:translateY(-270px);
  104.  
  105. -moz-transform:translateY(-270px);
  106.  
  107. -webkit-transform:translateY(-270px);
  108.  
  109. -ms-transform:translateY(-270px);
  110.  
  111. width:30%;
  112.  
  113. height:40px;
  114.  
  115. margin:0;
  116.  
  117. padding:0;
  118.  
  119. border:2px solid blue;
  120.  
  121. border-radius:30px;
  122.  
  123. }
  124.  
  125. .ud{
  126.  
  127. margin:5px 30%;
  128.  
  129. }
  130.  
  131. #l{
  132.  
  133. margin:5px 2% 5px 13%;
  134.  
  135. font-size:18px;
  136.  
  137. }
  138.  
  139. #r{
  140.  
  141. margin:5px 13% 5px 2%;
  142.  
  143. font-size:18px;
  144.  
  145. }
  146.  
  147. #d span{
  148.  
  149. display:block;
  150.  
  151. -moz-transform:rotateX(180deg);
  152.  
  153. -webkit-transform:rotateX(180deg);
  154.  
  155. -ms-transform:rotateX(180deg);
  156.  
  157. transform:rotateX(180deg);
  158.  
  159. font-size:20px;
  160.  
  161. margin-top:-5px;
  162.  
  163. }
  164.  
  165. #u span{
  166.  
  167. margin-top:5px;
  168.  
  169. display:block;
  170.  
  171. font-size:20px;
  172.  
  173. }
  174.  
  175. #load{
  176.  
  177. background:#000;
  178.  
  179. position:absolute;
  180.  
  181. top:0;
  182.  
  183. left:0;
  184.  
  185. height:100%;
  186.  
  187. width:100%;
  188.  
  189. z-index:500;
  190.  
  191. color:#fff;
  192.  
  193. }
  194.  
  195. #cp{
  196.  
  197. width:300px;
  198.  
  199. margin:25px auto;
  200.  
  201. }
  202.  
  203. #bd{
  204.  
  205. width:100%;
  206.  
  207. background-color:#eee;
  208.  
  209. border-radius:3px;
  210.  
  211. padding:1px;
  212.  
  213. box-shadow:inset 0px 3px 1px #ddd;
  214.  
  215. }
  216.  
  217. #bf{
  218.  
  219. display:block;
  220.  
  221. width:0%;
  222.  
  223. height:10px;
  224.  
  225. background-color:#0f9816;
  226.  
  227. border-radius:3px;
  228.  
  229. transition:width 0.05s ease;
  230.  
  231. }
  232.  
  233. h4,h3{
  234.  
  235. font-family: 'Architects Daughter', cursive;
  236.  
  237. text-align:center;
  238.  
  239. }
  240.  
  241. </style>
  242.  
  243. </head>
  244.  
  245. <body onload="mover()">
  246.  
  247. <div id="load">
  248.  
  249. <h1 style="text-align:center;">Snake</h1>
  250.  
  251. <h3>loading....</h3>
  252.  
  253. <div id="cp">
  254.  
  255. <div id="bd"><span id="bf"></span></div>
  256.  
  257. </div>
  258.  
  259. <script>
  260.  
  261. var e = document.querySelector("#bf");
  262.  
  263. var w = 0;
  264.  
  265. var interval=setInterval(function(){
  266.  
  267. e.style.width=w+"%";
  268.  
  269. w=w+1;
  270.  
  271. if(w==100){document.getElementById("load").style.display="none";}
  272.  
  273. },50);
  274.  
  275. </script>
  276.  
  277. <h4>Created by: 3x4rum</h4>
  278.  
  279. </div>
  280.  
  281. <header>
  282.  
  283. <div id="hl">Your Score :</div>
  284.  
  285. <div id="hr">0</div>
  286.  
  287. </header>
  288.  
  289. <div id="DIV">
  290.  
  291. </div>
  292.  
  293. <button id="u" class="ud" onclick="moveu()"><span>^^^</span></button><br>
  294.  
  295. <button id="l" onclick="movel()"><<<</button>
  296.  
  297. <button id="r" onclick="mover()">>>></button><br>
  298.  
  299. <button id="d" class="ud" onclick="moved()"><span>^^^</span></button>
  300.  
  301. <script>
  302.  
  303. for(n=0;n<900;n++){
  304.  
  305. var para = document.createElement("p");
  306.  
  307. var DIV = document.getElementById("DIV");
  308.  
  309. var PARA = document.getElementById("para1");
  310.  
  311. DIV.insertBefore(para, PARA);}
  312.  
  313. for(m=0;m<900;m++){
  314.  
  315. var dd = Math.floor(m/30);
  316.  
  317. document.getElementsByTagName("p")[m].style.transform="translateY(-"+dd*10+"px)";
  318.  
  319. document.getElementsByTagName("p")[m].style.mozTransform="translateY(-"+dd*10+"px)";
  320.  
  321. document.getElementsByTagName("p")[m].style.webkitTransform="translateY(-"+dd*10+"px)";
  322.  
  323. document.getElementsByTagName("p")[m].style.msTransform="translateY(-"+dd*10+"px)";}
  324.  
  325. var bd=[464,465];
  326.  
  327. var intv1;
  328.  
  329. var intv2;
  330.  
  331. var intv3;
  332.  
  333. var intv4;
  334.  
  335. var pnt=Math.floor(Math.random()*900);
  336.  
  337. var score=0;
  338.  
  339. function moved(){
  340.  
  341. clearInterval(intv2);
  342.  
  343. clearInterval(intv3);
  344.  
  345. clearInterval(intv4);
  346.  
  347. document.getElementById("u").disabled=true;
  348.  
  349. document.getElementById("d").disabled=true;
  350.  
  351. document.getElementById("r").disabled=false;
  352.  
  353. document.getElementById("l").disabled=false;
  354.  
  355. intv1=setInterval(function(){
  356.  
  357. var ttt=bd[bd.length-1]+30;
  358.  
  359. if(ttt>899){
  360.  
  361. ttt=ttt-900;}
  362.  
  363. if(bd.indexOf(ttt)>0){
  364.  
  365. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  366.  
  367. clearInterval(intv1);}
  368.  
  369. else{
  370.  
  371. bd.push(ttt);
  372.  
  373. if(ttt==pnt){
  374.  
  375. score+=10;
  376.  
  377. document.getElementById("hr").innerHTML=score;
  378.  
  379. pnt=Math.floor(Math.random()*900);}
  380.  
  381. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  382.  
  383. for(l=0;l<bd.length;l++){
  384.  
  385. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  386.  
  387. document.getElementsByTagName("p")[pnt].style.background="red";
  388.  
  389. }},200)}
  390.  
  391. function mover(){
  392.  
  393. clearInterval(intv1);
  394.  
  395. clearInterval(intv3);
  396.  
  397. clearInterval(intv4);
  398.  
  399. document.getElementById("r").disabled=true;
  400.  
  401. document.getElementById("l").disabled=true;
  402.  
  403. document.getElementById("u").disabled=false;
  404.  
  405. document.getElementById("d").disabled=false;
  406.  
  407. intv2=setInterval(function(){
  408.  
  409. var ttt=bd[bd.length-1]+1;
  410.  
  411. if(ttt%30==0){
  412.  
  413. ttt=ttt-30;}
  414.  
  415. if(bd.indexOf(ttt)>0){
  416.  
  417. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  418.  
  419. clearInterval(intv2);}
  420.  
  421. else{
  422.  
  423. bd.push(ttt);
  424.  
  425. if(ttt==pnt){
  426.  
  427. score+=10;
  428.  
  429. document.getElementById("hr").innerHTML=score;
  430.  
  431. pnt=Math.floor(Math.random()*900);}
  432.  
  433. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  434.  
  435. for(l=0;l<bd.length;l++){
  436.  
  437. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  438.  
  439. document.getElementsByTagName("p")[pnt].style.background="red";}},200)}
  440.  
  441. function movel(){
  442.  
  443. clearInterval(intv1);
  444.  
  445. clearInterval(intv2);
  446.  
  447. clearInterval(intv4);
  448.  
  449. document.getElementById("r").disabled=true;
  450.  
  451. document.getElementById("l").disabled=true;
  452.  
  453. document.getElementById("u").disabled=false;
  454.  
  455. document.getElementById("d").disabled=false;
  456.  
  457. intv3=setInterval(function(){
  458.  
  459. var ttt=bd[bd.length-1]-1;
  460.  
  461. if(ttt%30==29 && ttt>0){
  462.  
  463. ttt=ttt+30;}
  464.  
  465. if(ttt<0){ttt=ttt+30
  466.  
  467. } if(bd.indexOf(ttt)>0){
  468.  
  469. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  470.  
  471. clearInterval(intv3);}
  472.  
  473. else{
  474.  
  475. bd.push(ttt);
  476.  
  477. if(ttt==pnt){
  478.  
  479. score+=10;
  480.  
  481. document.getElementById("hr").innerHTML=score;
  482.  
  483. pnt=Math.floor(Math.random()*900);}
  484.  
  485. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  486.  
  487. for(l=0;l<bd.length;l++){
  488.  
  489. document.getElementsByTagName("p")[bd[l]].style.background="blue";
  490.  
  491. }
  492.  
  493. document.getElementsByTagName("p")[pnt].style.background="red";
  494.  
  495. }},200)}
  496.  
  497. function moveu(){
  498.  
  499. clearInterval(intv1);
  500.  
  501. clearInterval(intv2);
  502.  
  503. clearInterval(intv3);
  504.  
  505. document.getElementById("u").disabled=true;
  506.  
  507. document.getElementById("d").disabled=true;
  508.  
  509. document.getElementById("r").disabled=false;
  510.  
  511. document.getElementById("l").disabled=false;
  512.  
  513. intv4=setInterval(function(){
  514.  
  515. var ttt=bd[bd.length-1]-30;
  516.  
  517. if(ttt<0){
  518.  
  519. ttt=ttt+900;}
  520.  
  521. if(bd.indexOf(ttt)>0){
  522.  
  523. document.write("<h1 style='text-align:center; color:#fff; background:#1b4d4e; width:60%; margin:40px 20%; border-radius:30%; padding:16px 0px;'>"+"Game Over"+"</h1>"+"<h3 style='font-size:25px; color:#a1dcfd; text-align:center; background:#ff0b47; width:70%; margin:50px 15%; border-top-left-radius:30px; border-bottom-right-radius:30px; padding:20px 0px;'>"+"Your Score: "+score+"</h3>");
  524.  
  525. clearInterval(intv4);}
  526.  
  527. else{
  528.  
  529. bd.push(ttt);
  530.  
  531. if(ttt==pnt){
  532.  
  533. score+=10;
  534.  
  535. document.getElementById("hr").innerHTML=score;
  536.  
  537. pnt=Math.floor(Math.random()*900);}
  538.  
  539. else{document.getElementsByTagName("p")[bd.shift()].style.background="#000";}
  540.  
  541. for(l=0;l<bd.length;l++){
  542.  
  543. document.getElementsByTagName("p")[bd[l]].style.background="blue";}
  544.  
  545. document.getElementsByTagName("p")[pnt].style.background="red";}
  546.  
  547. },200)
  548.  
  549. }
  550.  
  551. </script>
  552.  
  553. </body>
  554.  
  555. </html>

gi đây bác :')