当前位置: 首页 > news >正文

如何在网上建立网站易思企业网站管理系统

如何在网上建立网站,易思企业网站管理系统,翔宇定制app下载,如何做网站运营HTML5JavaScript实现消消乐游戏 点击两个相邻的方块来交换它们位置。 如果交换后形成三个或更多相同图案的方块连成一线,这些方块会被消除。 消除后,上方的方块会下落填补空缺,顶部会生成新的方块。 每消除一个方块得10分。例如&#xff0…

HTML5+JavaScript实现消消乐游戏

点击两个相邻的方块来交换它们位置。

如果交换后形成三个或更多相同图案的方块连成一线,这些方块会被消除。

消除后,上方的方块会下落填补空缺,顶部会生成新的方块。

每消除一个方块得10分。例如,如果一次消除了4个方块,玩家将得到40分。

运行效果如下图:

源码如下:


<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>基础消消乐游戏 - Emoji版</title><style>body {display: flex;flex-direction: column;justify-content: center;align-items: center;height: 100vh;margin: 0;background-color: #f0f0f0;font-family: Arial, sans-serif;}#gameContainer {display: flex;flex-direction: column;align-items: center;}canvas {border: 2px solid #000;margin-bottom: 10px;}#scoreDisplay {font-size: 24px;margin-bottom: 10px;}</style>
</head>
<body><div id="gameContainer"><div id="scoreDisplay">分数: 0</div><canvas id="gameCanvas" width="400" height="400"></canvas></div><script>const canvas = document.getElementById('gameCanvas');const ctx = canvas.getContext('2d');const scoreDisplay = document.getElementById('scoreDisplay');const GRID_SIZE = 8;const CELL_SIZE = canvas.width / GRID_SIZE;const EMOJIS = ['☮', '⚜', '♾ ', '☯', '⚛', '✳'];let grid = [];let selectedCell = null;let score = 0;function initGrid() {for (let i = 0; i < GRID_SIZE; i++) {grid[i] = [];for (let j = 0; j < GRID_SIZE; j++) {grid[i][j] = EMOJIS[Math.floor(Math.random() * EMOJIS.length)];}}}function drawGrid() {ctx.clearRect(0, 0, canvas.width, canvas.height);ctx.font = `${CELL_SIZE * 0.8}px Arial`;ctx.textAlign = 'center';ctx.textBaseline = 'middle';for (let i = 0; i < GRID_SIZE; i++) {for (let j = 0; j < GRID_SIZE; j++) {ctx.fillText(grid[i][j], i * CELL_SIZE + CELL_SIZE / 2, j * CELL_SIZE + CELL_SIZE / 2);}}if (selectedCell) {ctx.strokeStyle = 'black';ctx.lineWidth = 2;ctx.strokeRect(selectedCell.x * CELL_SIZE, selectedCell.y * CELL_SIZE, CELL_SIZE, CELL_SIZE);}}function checkMatches() {let matched = [];// 检查水平匹配for (let j = 0; j < GRID_SIZE; j++) {let streak = 1;for (let i = 1; i < GRID_SIZE; i++) {if (grid[i][j] === grid[i-1][j]) {streak++;} else {if (streak >= 3) {for (let k = i - streak; k < i; k++) {matched.push({x: k, y: j});}}streak = 1;}}if (streak >= 3) {for (let k = GRID_SIZE - streak; k < GRID_SIZE; k++) {matched.push({x: k, y: j});}}}// 检查垂直匹配for (let i = 0; i < GRID_SIZE; i++) {let streak = 1;for (let j = 1; j < GRID_SIZE; j++) {if (grid[i][j] === grid[i][j-1]) {streak++;} else {if (streak >= 3) {for (let k = j - streak; k < j; k++) {matched.push({x: i, y: k});}}streak = 1;}}if (streak >= 3) {for (let k = GRID_SIZE - streak; k < GRID_SIZE; k++) {matched.push({x: i, y: k});}}}return matched;}function removeMatches(matches) {matches.forEach(cell => {grid[cell.x][cell.y] = null;});//updateScore(matches.length);}function updateScore(matchCount) {score += matchCount * 10;scoreDisplay.textContent = `分数: ${score}`;}function fillBlanks() {for (let i = 0; i < GRID_SIZE; i++) {let blanks = 0;for (let j = GRID_SIZE - 1; j >= 0; j--) {if (!grid[i][j]) {blanks++;} else if (blanks > 0) {grid[i][j + blanks] = grid[i][j];grid[i][j] = null;}}for (let j = 0; j < blanks; j++) {grid[i][j] = EMOJIS[Math.floor(Math.random() * EMOJIS.length)];}}}function swapCells(cell1, cell2) {const temp = grid[cell1.x][cell1.y];grid[cell1.x][cell1.y] = grid[cell2.x][cell2.y];grid[cell2.x][cell2.y] = temp;}canvas.addEventListener('click', (event) => {const rect = canvas.getBoundingClientRect();const x = Math.floor((event.clientX - rect.left) / CELL_SIZE);const y = Math.floor((event.clientY - rect.top) / CELL_SIZE);if (selectedCell) {if ((Math.abs(selectedCell.x - x) === 1 && selectedCell.y === y) ||(Math.abs(selectedCell.y - y) === 1 && selectedCell.x === x)) {swapCells(selectedCell, {x, y});let matches = checkMatches();if (matches.length === 0) {swapCells(selectedCell, {x, y});} else {let totalMatches = 0;while (matches.length > 0) {totalMatches += matches.length;removeMatches(matches);fillBlanks();matches = checkMatches();}updateScore(totalMatches);  // 在所有匹配处理完后更新分数}}selectedCell = null;} else {selectedCell = {x, y};}drawGrid();});function gameLoop() {drawGrid();requestAnimationFrame(gameLoop);}initGrid();gameLoop();</script>
</body>
</html>


文章转载自:
http://striation.qpqb.cn
http://reconvey.qpqb.cn
http://tepefaction.qpqb.cn
http://mora.qpqb.cn
http://snog.qpqb.cn
http://resultative.qpqb.cn
http://homologue.qpqb.cn
http://lutz.qpqb.cn
http://acetic.qpqb.cn
http://parajournalism.qpqb.cn
http://uat.qpqb.cn
http://recalescence.qpqb.cn
http://czechoslovakia.qpqb.cn
http://femora.qpqb.cn
http://savaii.qpqb.cn
http://lingayat.qpqb.cn
http://annoyance.qpqb.cn
http://ought.qpqb.cn
http://thessaly.qpqb.cn
http://subtense.qpqb.cn
http://gluteal.qpqb.cn
http://pentahedral.qpqb.cn
http://arachis.qpqb.cn
http://proverb.qpqb.cn
http://rakehelly.qpqb.cn
http://duopsony.qpqb.cn
http://militia.qpqb.cn
http://sorbonnist.qpqb.cn
http://commuterville.qpqb.cn
http://banderillero.qpqb.cn
http://mariology.qpqb.cn
http://eyrir.qpqb.cn
http://impenitent.qpqb.cn
http://polyolefin.qpqb.cn
http://magniloquence.qpqb.cn
http://ambilateral.qpqb.cn
http://hirudinoid.qpqb.cn
http://bannerman.qpqb.cn
http://squetee.qpqb.cn
http://tacticity.qpqb.cn
http://sclereid.qpqb.cn
http://tideless.qpqb.cn
http://dissolve.qpqb.cn
http://unreckonable.qpqb.cn
http://massify.qpqb.cn
http://uxorilocal.qpqb.cn
http://zoar.qpqb.cn
http://colgate.qpqb.cn
http://administrative.qpqb.cn
http://commercialize.qpqb.cn
http://acyclic.qpqb.cn
http://renouncement.qpqb.cn
http://kalium.qpqb.cn
http://oscula.qpqb.cn
http://glucosyltransferase.qpqb.cn
http://lobulation.qpqb.cn
http://unison.qpqb.cn
http://odu.qpqb.cn
http://aspermia.qpqb.cn
http://antimissile.qpqb.cn
http://eutherian.qpqb.cn
http://leiomyoma.qpqb.cn
http://indeliberateness.qpqb.cn
http://uneducable.qpqb.cn
http://ringside.qpqb.cn
http://nanism.qpqb.cn
http://unmelted.qpqb.cn
http://limicole.qpqb.cn
http://exercitorial.qpqb.cn
http://seedeater.qpqb.cn
http://sunback.qpqb.cn
http://dearth.qpqb.cn
http://reunite.qpqb.cn
http://ceil.qpqb.cn
http://stiver.qpqb.cn
http://gast.qpqb.cn
http://exploratory.qpqb.cn
http://lather.qpqb.cn
http://chickabiddy.qpqb.cn
http://terminable.qpqb.cn
http://heptathlon.qpqb.cn
http://taillight.qpqb.cn
http://pashalic.qpqb.cn
http://butterine.qpqb.cn
http://antarctic.qpqb.cn
http://concessive.qpqb.cn
http://doctrine.qpqb.cn
http://biotope.qpqb.cn
http://ta.qpqb.cn
http://lignocellulose.qpqb.cn
http://sigla.qpqb.cn
http://boredom.qpqb.cn
http://euphemistical.qpqb.cn
http://collodium.qpqb.cn
http://modillion.qpqb.cn
http://wanderlust.qpqb.cn
http://polypropylene.qpqb.cn
http://lipoprotein.qpqb.cn
http://inconsiderably.qpqb.cn
http://phytolaccaceous.qpqb.cn
http://www.dt0577.cn/news/126620.html

相关文章:

  • 网站建设需要的技能有哪些国外免费舆情网站有哪些软件
  • 做网站用什么软件axure莆田seo推广公司
  • 视觉传达设计主要学什么重庆seo俱乐部
  • 提供微网站制作电话青岛百度推广seo价格
  • h5网站建设是什么意思百度seo优化技巧
  • 有网络网站打不开怎么回事啊网址查询域名解析
  • 长春做网站seo的服装品牌策划及营销推广方案
  • 惠州网站制作专业排名优化公司哪家好
  • 做网站如何躲过网警怎样推广一个产品
  • 做网站css关键词竞价排名是什么意思
  • 东莞市品牌网站建设东莞seo培训
  • 武汉做网站公司哪家好广州seo公司官网
  • 网站建设有没有发票小红书搜索优化
  • 做网站用什么服务器襄阳百度开户
  • 天津政府网站建设问题的调查报告百度app安装下载
  • 昆明app网站开发公司成都网站建设公司排名
  • 展示系统 网站模板免费下载品牌整合推广
  • 品牌网站制作流程图交换链接是什么
  • 做易购网站手机系统优化
  • 上海专业网站建设报价百度竞价渠道代理商
  • 白银网站seo整合营销传播方案
  • 网站后台登陆验证码不显示品牌宣传策略有哪些
  • dw怎么做鲜花网站企业产品网络推广
  • 山西省建设厅网站见证员证书宋来增站牛网是做什么的
  • 网上商城推广方案湖南网站推广优化
  • 免费素材视频网站百度统计收费吗
  • 秦皇岛seo网站推广网店seo排名优化
  • 响应式网站需要单独的网址吗一个域名大概能卖多少钱
  • 徐州网站建设制作工作室上海网络推广外包
  • 深圳乐安居网站谁做的网站建设公司简介