利用JS實(shí)現(xiàn)機(jī)器人總動員小游戲
前言
本節(jié)教程我會帶大家使用 HTML 、CSS和 JS 來制作一個 機(jī)器人總動員小游戲
本節(jié)示例將會實(shí)現(xiàn)如下所示的效果:
在線演示地址:https://code.haiyong.site/moyu/bwjqr

項(xiàng)目基本結(jié)構(gòu)


HTML源碼
<body>
<div id="main_container">
<div id="progress_container">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td id="progress">
<div><a id="tt_load_logo_c" rel="external nofollow" target="_blank"><img id="tt_load_logo" border="" src="logo.png"></a></div>
<div id="tt_load_progress_cont">
<div id="tt_load_progress" > </div>
</div>
<div id="tt_load_play"><img id="tt_load_button" src="tt_load_button.png" height="55px"></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="screen_background_container" align="center">
<div id="screen_background_wrapper"><canvas
id="screen_background"></canvas><canvas
id="screen_background2"></canvas></div>
</div>
<div id="screen_container" align="center">
<div id="screen_wrapper"><canvas id="screen">You browser does
not support this application :(</canvas><canvas id="screen2"></canvas></div>
</div>
</div>
<div id="p2l_container" align="center"><img
id="p2l" src="./robot_files/p2l.png" style="padding-top: 100px;"></div>CSS 源碼
body
body{
margin: 0px;
padding: 0px;
background-color: rgb(0, 0, 0);
overflow: hidden;
}progress_container
#progress_container{
height: 2048px;
display: none;
width: 1536px;
position: absolute;
left: 0px;
top: 0px;
background: rgb(102, 102, 102);
z-index: 1000;
}p2l_container
#p2l_container {
width: 100%;
height: 746px;
position: absolute;
left: 0px;
top: 0px;
display: none;
z-index: 1000;
background: #fff;
}JS 源碼
js 代碼較多,這里提供部分
var CRENDER_DEBUG = !1;
function ImagesPreloader() {
function a() {
var e = 0,
f = 0,
g;
for (g in c.loadedImages) c.loadedImages[g].complete && e++,
f++;
e >= f ? c.endCallback && c.endCallback(c.loadedImages) : (c.processCallback && c.processCallback(Math.floor(e / f * 100)), setTimeout(a, 50))
}
var c = this;
this.curItem = -1;
this.loadedImages = {};
this.processCallback = this.endCallback = this.data = null;
this.load = function(c, f, g) {
this.data = c;
this.endCallback = f;
this.processCallback = g;
for (c = 0; c < this.data.length; c++) f = this.data[c],
g = new Image,
g.src = f.src,
this.loadedImages[f.name] = g;
a()
}
}到此這篇關(guān)于利用JS實(shí)現(xiàn)機(jī)器人總動員小游戲的文章就介紹到這了,更多相關(guān)JS機(jī)器人總動員游戲內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
JavaScript設(shè)計(jì)模式發(fā)布訂閱模式
這篇文章主要介紹了JavaScript設(shè)計(jì)模式發(fā)布訂閱模式,發(fā)布訂閱設(shè)計(jì)模式是和觀察者設(shè)計(jì)模式基本上相同,但是他們兩個設(shè)計(jì)模式不同的是發(fā)布訂閱者擁有一個事件處理中心而觀察者并沒有2022-06-06
three.js簡單實(shí)現(xiàn)類似七圣召喚的擲骰子
這篇文章主要為大家介紹了three.js簡單實(shí)現(xiàn)類似七圣召喚的擲骰子示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01
JS中const對于復(fù)雜類型變量和普通類型變量的區(qū)別詳解
我們在開發(fā)的過程中一定常常發(fā)現(xiàn)const關(guān)鍵字定義的簡單類型變量不可以改變,但是你如果定義的是一個復(fù)雜類型變量(比如對象)的話對里面屬性的增刪改查是可以的,那這又是為什么呢,接下來就來和小編一起探討一下吧2023-11-11
js實(shí)現(xiàn)按鈕開關(guān)單機(jī)下拉菜單效果
這篇文章主要介紹了js實(shí)現(xiàn)按鈕開關(guān)單機(jī)下拉菜單效果,代碼簡單易懂,非常不錯,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-11-11
解決JSON.stringify()自動將中文轉(zhuǎn)譯成unicode的問題
下面小編就為大家分享一篇解決JSON.stringify()自動將中文轉(zhuǎn)譯成unicode的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01
JavaScript實(shí)現(xiàn)精美個性導(dǎo)航欄筋斗云效果
這篇文章主要介紹了JavaScript實(shí)現(xiàn)精美個性導(dǎo)航欄筋斗云效果,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2017-10-10

