乙個網頁的小遊戲,養寵物,可以練習一下
<
!doctype html>
"en"
>
"utf-8"
>
"viewport" content=
"width=device-width, initial-scale=1.0"
>
document<
/title>
<
/head>
"./pet.js"
>
<
/script>
"./util.js"
>
<
/script>
class
user
}class
pet}
let endtime =
+new
date
let endtime1 =
+new
date
class
dogextends
petintroduceself()
我是個$
孩子 我的狀態值目前是
$我的主人叫$`
);}eat(
) console.
log(
this
.nickname +
'吃骨頭去了');
this
.state +=
20 endtime =
+new
date
}play()
}class
catextends
petintroduceself()
我是個$
孩子 我的狀態值目前是
$我的主人叫$`
);}eat(
) console.
log(
this
.nickname +
'吃貓糧');
this
.state +=
20 endtime =
+new
date
}play()
}let zed =
,register
(nickname, pwd)
,registerpet
(nickname, type, gender)
this
.petlist.
push
(pet)},
login
(nickname, pwd)
,checkuserhaspet()
,checkuserrepeat
(nickname)
,checksensitivewords
(str)},
showbuypetpage()
let nickname =
'', type =
'', gender =
''let isvalidnickname =
false
, isvalidtype =
false
, isvalidgender =
falsedo}
while
(!isvalidtype);do
}while
(!isvalidnickname);do
}while
(!isvalidgender)
;this
.service.
registerpet
(nickname, type, gender)
this
.showmainpage()
},showpetdetailpage()
else
this
.showmainpage()
},showgamepage
(pet)
pet.
introduceself()
},showloginpage()
while
(!isvalidnickname);do
while
(!isvalidpwd);if
(this
.service.
login
(nickname, pwd)
)else},
showmainpage()
},showregisterpage()
if(this
.service.
checksensitivewords
(nickname))}
while
(!isvalidnickname);do
while
(!isvalidpwd);do
while
(!isvalidcpwd)
;this
.service.
register
(nickname, pwd)
this
.showwelcomepage()
},showwelcomepage()
}}zed.
showwelcomepage()
<
/script>
<
/body>
<
/html>
js 檔案
let lee =
,checkstrnullorempty
(str)
,checkstrhasval
(str)
,checkstrlength
(str, len)
,trim
(str)
else},
throttle
(fn, wait)
fn.(this
,arguments)
endtime =
+new
date}}
,}
js實現2048小遊戲
頁面class hidden id end id endspan id table colspan 4 id s1 id s2 id s3 id s4 id s5 id s6 id s7 id s8 id s9 id s10 id s11 id s12 id s13 id s14 id s15 id...
純js寫小遊戲
html部分 css部分 大盒子容器 div1 彈動的小球 ball 底部小滑塊 slide 頂部磚塊的父級盒子 brick 頂部磚塊 brick div js部分 window.onload function if ball.offsettop 0 if ball.offsettop 580 小球...
unity之小遊戲
歡迎來到我們的狗刨網,我們今天主要做了三個小遊戲,分別是打磚塊,滾動的盒子和 一 首先來看第乙個小遊戲 打磚塊 public gameobject wall void start for int i 0 i 10 i for int j 0 j 10 j instantiate wall,new v...