当前位置:网站首页>Wechat applet project example - renju for two
Wechat applet project example - renju for two
2022-06-12 02:48:00 【Long lost brother】
Wechat applet project example —— Double Gobang
List of articles
See the bottom of the text for the project code , Praise, focus and surprise
One 、 Project presentation
Wechat applet project example —— Double Gobang
Gobang for two is a small game program
Two players can play in 15x15 On the chessboard
Play Gobang
At the same time, the applet has set the repentance function

Two 、 Project core code
Click to drop
step: function(event)
{
var pos=event.currentTarget.dataset.pos;
wx.setStorageSync('vak', this.data.vak);
if(this.data.vak[pos]=="white"||this.data.vak[pos]=="black")return;
this.count++;
if(this.count%2)
{
this.data.vak[pos]="black";
}
else
{
this.data.vak[pos]="white";
}
this.setData({
vak : this.data.vak
})
this.judge(pos);
}
Judge the outcome
judge: function(pos)
{
var color=this.data.vak[pos];
var x0=parseInt(pos/15),y0=pos%15,x,y,round;
for(var i=0;i<4;i++)
{
var five=0;
round=0;
for(x=x0,y=y0;round<5;x+=this.vec[i][0],y+=this.vec[i][1],round++)
{
if(this.data.vak[15*x+y]==color)
{
five++;
}
else
{
break;
}
}
round=0;
for(x=x0,y=y0;round<5;x-=this.vec[i][0],y-=this.vec[i][1],round++)
{
if(this.data.vak[15*x+y]==color)
{
five++;
}
else
{
break;
}
}
var rstr=color+"win";
if(five>=6)
{
this.setData({
result : rstr
});
wx.showModal({
title: color+' win victory ',
content: ' Another round ',
success: function(res) {
if (res.confirm) {
wx.redirectTo({
url:"./index"
});
}
}
})
}
}
},
3、 ... and 、 Effect display
Victory effect

restart

Repentance

At the end of the article
That's all for the specific introduction
Interested students can continue to study
The code is in the link below

边栏推荐
- 架构入门讲解 - 谁动了我的蛋糕
- 【点云压缩】Sparse Tensor-based Point Cloud Attribute Compression
- Application of ankery anti shake electric products in a chemical project in Hebei
- Force deduction solution summary 732- my schedule III
- Cvpr2022 | IFS RCNN: an incremental small sample instance splitter
- Force deduction programming problem - solution summary
- How should programmers solve the problem of buying vegetables? Take you hand in hand to quickly order and grab vegetables by using the barrier free auxiliary function
- Audio and video technology under the trend of full true Internet | Q recommendation
- 余压监控系统在高层民用建筑的应用
- Introduction to program environment and preprocessing C language (advanced level)
猜你喜欢

Hypergraph tilted data is merged into root node and transferred to 3dfiles

博创智能冲刺科创板:年营收11亿 应收账款账面价值3亿

errno: -4091, syscall: ‘listen‘, address: ‘::‘, port: 8000

How to build urban smart bus travel? Quick code to answer

Unity3D中DrawCall、Batches、SetPassCall

errno: -4078, code: ‘ECONNREFUSED‘, syscall: ‘connect‘, address: ‘127.0.0.1‘, port: 3306;postman报错

Introduction to architecture - who moved my cake

微信小程序项目实例——双人五子棋

Calculus review 2

maya前臺渲染插件mel脚本工具
随机推荐
String number with special style
Start ticwatch2
oracle之模式对象
cupp字典生成工具(同类工具还有crunch)
微积分复习2
如何防止商场电气火灾的发生?
The road of global evolution of vivo global mall -- multilingual solution
【高代码文件格式API】道宁为您提供文件格式API集——Aspose,只需几行代码即可创建转换和操作100多种文件格式
Xcall cluster script (view JPS command)
Navicat for MySQL 11 Linux cracking method
Force deduction solution summary interview question 17.11- word distance
2022 Fujian Provincial Safety Officer C certificate (full-time safety officer) examination simulation 100 questions and answers
Ue4\ue5 touch screen touch event: single finger and double finger
Force deduction solution summary 386 dictionary order
Maya Front Office Rendering plug - in Mel script Tool
Proxy and reflection (II)
ZABBIX notes: 6.0 lts source code installation
Min25 sieve
I2C protocol overview
AcrelCloud-6000安全用电云平台在某商业广场的应用