利用JS實現(xiàn)機器人總動員小游戲
前言
本節(jié)教程我會帶大家使用 HTML 、CSS和 JS 來制作一個 機器人總動員小游戲
本節(jié)示例將會實現(xiàn)如下所示的效果:
在線演示地址:https://code.haiyong.site/moyu/bwjqr
項目基本結構
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() } }
到此這篇關于利用JS實現(xiàn)機器人總動員小游戲的文章就介紹到這了,更多相關JS機器人總動員游戲內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
微信小程序 子級頁面返回父級并把子級參數(shù)帶回父級實現(xiàn)方法
這篇文章主要介紹了微信小程序 子級頁面返回父級并把子級參數(shù)帶回父級實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2019-08-08JS中注入eval, Function等系統(tǒng)函數(shù)截獲動態(tài)代碼
這篇文章主要介紹了JS中注入eval, Function等系統(tǒng)函數(shù)截獲動態(tài)代碼,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-04-04el-date-picker?限制開始時間和結束時間的代碼實現(xiàn)
在Vue.js中使用Element?UI庫的el-date-picker組件時,可以通過設置picker-options來限制開始時間和結束時間的選擇范圍,下面通過例子介紹el-date-picker?限制開始時間和結束時間的實現(xiàn),感興趣的朋友一起看看吧2024-08-08