手机游戏缺少index_264.html,html5手机端大家来找茬微信小游戏代码

特效描述:html5 手机端大家来找茬 微信小游戏代码。html5手机端大家来找茬微信小游戏代码

代码结构

1. HTML代码

剩余时间: 30 s
分数: 0
  • 2.png

点 击 开 始 游 戏

护眼模式

var btn=document.querySelector('button');

var z=30.00;

var sec=document.getElementById('sec');

var uls=document.querySelector('ul');

var li_1=document.getElementsByClassName('list1')[0];

var score=document.getElementById('score');

var level=1;

var n=0;

var turnOff=document.getElementById('turnOff');

turnOff.οnclick=function(){

document.body.style.background='rgb(199,237,204)';

turnOff.innerHTML='普通模式';

turn();

}

function turn(){

turnOff.οnclick=function(){

document.body.style.background='';

turnOff.innerHTML='护眼模式';

turnOff.οnclick=function(){

document.body.style.background='rgb(199,237,204)';

turnOff.innerHTML='普通模式';

turn();

}

}

}

var back=document.getElementById('back');

btn.οnclick=function(){

// 1.计时器

var timer=setInterval(function(){

z-=0.01;

z=z.toFixed(2);

sec.innerHTML=z;

if (z<=0) {

clearInterval(timer);

if (n<8) {

alert('GAME OVER!'+' '+'等级:睁眼瞎');

}else if (n>=20) {

alert('GAME OVER!'+' '+'等级:超神');

}else if (n>=12) {

alert('GAME OVER!'+' '+'等级:火眼金睛');

}else{

alert('GAME OVER!'+' '+'等级:高度近视');

}

back.style.display='block';

}

},10)

// 2.点击按钮消失,第一个li消失

btn.remove();

li_1.remove();

turnOff.remove();

// 3.添加4个li>img

app();

function app(){

level+=1;

for (var i=0;i

var newLi=document.createElement('li');

uls.appendChild(newLi);

var newImg=document.createElement('img');

newLi.appendChild(newImg);

newLi.style.width=100/level+'%';

newLi.style.float='left';

newImg.style.display='block';

newImg.style.width=100+'%';

newImg.src='img/1.png';

newLi.style.backgroundColor='rgb('+rand(50,255)+','+rand(50,255)+','+rand(50,255)+')';

}

var x=rand(0,level*level-1);// 赋予一个随机房祖名下标

var imgs1=document.querySelectorAll('img');

imgs1[x].src='img/2.png';// 随机一张图片变成房祖名

var li=document.querySelectorAll('li');

li[x].οnclick=function(){

for (var i=0;i

li[i].remove(this);

}

n+=1;

score.innerHTML=n;

if (level>10) {

level=10;

}

app();

}

}

}

// 随机函数

function rand(min,max){

return Math.round(Math.random()*(max-min)+min);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很高兴为您解答这个问题!以下是一个简单的用HTML、CSS和JavaScript实现的找茬游戏的示例代码HTML代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>找茬游戏</title> <link rel="stylesheet" href="style.css"> </head> <body> <div id="picture-container"> <img id="picture1" src="picture1.jpg"> <img id="picture2" src="picture2.jpg"> </div> <button id="find-differences-button">找茬</button> <script src="script.js"></script> </body> </html> ``` CSS代码: ``` #picture-container { display: flex; justify-content: center; align-items: center; margin-top: 50px; } img { margin: 20px; } #find-differences-button { display: block; margin: 0 auto; margin-top: 50px; font-size: 24px; padding: 10px; } ``` JavaScript代码: ``` const picture1 = document.getElementById("picture1"); const picture2 = document.getElementById("picture2"); const findDifferencesButton = document.getElementById("find-differences-button"); let differences = 0; picture2.style.opacity = "0.5"; picture2.addEventListener("click", function(event) { const x = event.pageX - picture2.offsetLeft; const y = event.pageY - picture2.offsetTop; const canvas = document.createElement("canvas"); canvas.width = picture2.width; canvas.height = picture2.height; const context = canvas.getContext("2d"); context.drawImage(picture2, 0, 0, picture2.width, picture2.height); const pixel = context.getImageData(x, y, 1, 1).data; if (pixel[3] === 255) { differences++; if (differences === 7) { alert("你找到了全部的!"); differences = 0; picture2.style.opacity = "0.5"; } } }); findDifferencesButton.addEventListener("click", function() { differences = 0; picture2.style.opacity = "1"; alert("请找到两张图片中的7处不同之处!"); }); ``` 这个示例实现了一个简单的找茬游戏,其中包括两张图片(picture1.jpg和picture2.jpg)和一个按钮(find-differences-button)。当用户点击按钮时,游戏开始,图片2的不透明度变为1,用户需要在图片2上找到7处不同之处。当用户找到一个不同之处时,游戏将在图片2上显示一个黑点。当用户找到全部7处不同之处时,游戏结束,提示用户找到了全部的

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值