大家来找茬游戏助手、外挂的实现

    在家陪女女打游戏‘大家来找茬’,老是输,让哥心里很窝火,于是想到了作弊,嘿嘿,说干就干,我用的是最笨的方法,首先FindWindow找到‘大家来找茬’的位置,然后根据计算好的相对位置,截取两幅图像进行对比。

    刚开始直接对比RGB值,结果惨不忍睹,分析原因,R、G、B可能只有一个或者几个不同,不能直接RGB整个对比,于是就R、G、B分开比较,只要有一个大于阈值(阈值取10,经验值)就认为像素不同,这样下来,效果还是很差。

    不经意间看到大学时代买的《数字图像处理》这本书,N久都没翻过了,现在拿起来浏览一下,看能不能找到点灵感,快速浏览了一下目录,还是有收获,采用模板对比来代替单个像素对比,效果一下子就大大改观。考虑到效率问题,最终采取5x5矩阵来对比。

    算法介绍:对比每个像素周围的5x5区域,如果5x5区域内每个像素的R、G、B值任一个大于阈值(取10),就认为这个像素是不同的,然后标记为特定颜色(比如红色),下面是实际运行效果图:

       

 

这里下载 

 

.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
很高兴为您解答这个问题!以下是一个简单的用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处不同之处时,游戏结束,提示用户找到了全部的

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值