电商商城定制开发HTML小游戏16 —— 消除游戏《魔法石》源码(附完整源码)

  • 💂 网站推荐:【】【】
  • 🤟 电商商城定制开发前端学习课程:👉【】【】
  • 💅 电商商城定制开发想寻找共同学习交流、电商商城定制开发摸鱼划水的小伙伴,请点击【】
  • 💬 免费且实用的计算机相关知识题库:👉

给大家安利一个免费且实用的前端刷题(大全)网站,👉。

本节教程我会带大家使用 HTML 、CSS和 JS 来制作一个

✨ 前言


🕹️ 本文已收录于🎖️100个HTML小游戏专栏:
🎮 目前已有100+小游戏,源码在持续更新中,前100位订阅限时优惠,先到先得。
🐬 订阅专栏后可阅读100个HTML小游戏文章;还可私聊进前端/游戏制作学习交流群;领取一百个小游戏源码。


源码也可在文末进行获取


✨ 项目基本结构


大致目录结构如下(共251个子文件):

  1. ├── lib
  2. │   ├── jquery-1.11.1.min.js
  3. │   └── underscore.min.js
  4. ├── js
  5. │   ├── developer.js
  6. │   └── game.js
  7. ├── img
  8. │   └── logo_A10_202x50.png
  9. ├── res
  10. │   ├── audio
  11. │   │   ├── audiosprite.ogg
  12. │   │   ├── music_ingame.ogg
  13. │   │   └── music_menu.ogg
  14. │   ├── bg
  15. │   │   ├── black_bg.png
  16. │   │   ├── gp_bg.png
  17. │   │   └── mm_bg.png
  18. │   ├── css
  19. │   │   ├── pattern.png
  20. │   │   └── styles.css
  21. │   ├── dragonBones
  22. │   ├── fonts
  23. │   ├── frameByFrame
  24. │   ├── img
  25. │   ├── levels
  26. │   ├── loadingScreen
  27. │   ├── ui
  28. │   ├── achievements.json
  29. │   └── localization.json
  30. ├── game.min.js
  31. ├── yx8.js
  32. └── index.html

 

场景展示

HTML源码

  1. <div id="gameContainer"></div>
  2. <a href="https://code.haiyong.site/moyu" target="_blank" class="btn btn_left">更多游戏</a>
  3. <a href="https://code.haiyong.site/ziyuan/game/" target="_blank" class="btn btn_right" id="fullscr">游戏源码</a>

CSS 源码

body

  1. body {
  2. margin: 0;
  3. padding: 0;
  4. background-image: url("pattern.png");
  5. background-repeat: repeat;
  6. }

rotate-device-

  1. #rotate-device-overlay {
  2. position: absolute;
  3. width: 100%;
  4. height: 100%;
  5. z-index: 9998;
  6. top: 0;
  7. left: 0;
  8. background-size: auto
  9. }

rotate-device-image

  1. .rotate-device-image {
  2. background: #26252e url('rotation_screen.png') no-repeat center center
  3. }

a

  1. a:link { color: #d07500;}
  2. a:visited { color:#d07500;}
  3. a:hover { color:#ffffff;}
  4. a:active { color:#f0f0f0;}

JS 源码

js 代码较多,这里提供部分,完整源码可以在文末下载

初始化游戏 HTML5 API

  1. GameAPI.loadAPI(function(apiInstance) {
  2. // API已准备好使用
  3. API_INSTANCE = apiInstance;
  4. if (window.console && window.console.log) {
  5. console.log('GameAPI version ' + apiInstance.version + ' loaded!');
  6. }
  7. initgame();
  8. }, SpilData);

yx8.js

  1. {
  2. "configar": {
  3. "branding": {
  4. "main": {
  5. "label": "main",
  6. "image": "img\/logo_A10_202x50.png",
  7. "url": "http:\/\/www.haiyong.site\/moyu",
  8. "style": "",
  9. "width": "202",
  10. "height": "50",
  11. "mime": "image\/png",
  12. "type": "png",
  13. "handler": "newTab",
  14. "blacklisted": false
  15. },
  16. "more_games": {
  17. "label": "more_games",
  18. "image": "#",
  19. "url": "http:\/\/www.haiyong.site\/moyu",
  20. "style": "",
  21. "width": "0",
  22. "height": "0",
  23. "mime": "image\/png",
  24. "type": "png",
  25. "handler": "newTab",
  26. "blacklisted": false
  27. },
  28. "logo": {
  29. "label": "logo",
  30. "image": "img\/logo_A10_202x50.png",
  31. "url": "http:\/\/www.haiyong.site\/moyu",
  32. "style": "",
  33. "width": "202",
  34. "height": "50",
  35. "mime": "image\/png",
  36. "type": "png",
  37. "handler": "newTab",
  38. "blacklisted": true
  39. },
  40. "splash_screen": {
  41. "label": "splash_screen",
  42. "image": "place_holder_string",
  43. "url": "http:\/\/www.haiyong.site\/moyu",
  44. "style": "",
  45. "width": "0",
  46. "height": "0",
  47. "mime": "image\/png",
  48. "type": "png",
  49. "handler": "newTab",
  50. "blacklisted": true
  51. },
  52. "google_play": {
  53. "label": "google_play",
  54. "image": "img\/google_play.png",
  55. "url": "https:\/\/play.google.com\/store\/apps\/details?id=com.spilgames.shopaholicworld&hl=nl_NL",
  56. "style": "",
  57. "width": "270",
  58. "height": "80",
  59. "mime": "image\/png",
  60. "type": "png",
  61. "handler": "newTab",
  62. "blacklisted": false
  63. },
  64. "appstore": {
  65. "label": "appstore",
  66. "image": "img\/appstore.png",
  67. "url": "https:\/\/itunes.apple.com\/app\/shopaholic-world\/id514563522?mt=8",
  68. "style": "",
  69. "width": "240",
  70. "height": "80",
  71. "mime": "image\/png",
  72. "type": "png",
  73. "handler": "newTab",
  74. "blacklisted": false
  75. }
  76. }
  77. }
  78. }

侦听来自父级的方向更改事件,并在发送后模拟本机事件

  1. utils.addEventListener('message', function (message) {
  2. if (
  3. message &&
  4. message.data.mssg &&
  5. message.data.mssg === 'orientationchange'
  6. ) {
  7. var orientationEvent = d.createEvent('Event');
  8. orientationEvent.initEvent('orientationchange', true, true);
  9. orientationEvent.orientation = message.data.orientation;
  10. w.dispatchEvent(orientationEvent);
  11. // 由于最小的ui错误而向后滚动
  12. w.scrollTo(0, 0);
  13. }
  14. }, w);

图片资源

 

 


一共十几张图片,全都打包放在文末的下载链接里了。

音频资源

源码下载


3.也可通过下方卡片添加好友回复魔法石获取

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发