当前位置:网站首页>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

边栏推荐
- Maya Front Office Rendering plug - in Mel script Tool
- Several common instructions for virsh to create / shut down / stop virtual machines
- Hypergraph tilted data is merged into root node and transferred to 3dfiles
- Start ticwatch2
- RPC 入门
- 跨域有哪些解决方法?
- Selection (045) - what is the output of the following code?
- Force deduction programming problem - solution summary
- Force deduction solution summary interview question 17.11- word distance
- WPS table learning notes - highlight duplicate values
猜你喜欢

DbNull if statement - DbNull if statement

El upload upload file

Start ticwatch2

SSH public key login failed with error: Sign_ and_ send_ pubkey: no mutual signature supported

Apply concentrated load to nodes in batch in ABAQUS

Unity3D中DrawCall、Batches、SetPassCall

Query the duplicate values of multiple fields in the database, output the number, and add them.

About 100 to realize the query table? Really? Let's experience the charm of amiya.

Proxy and reflection (II)

【点云压缩】Sparse Tensor-based Point Cloud Attribute Compression
随机推荐
Demand and business model innovation - demand 10- observation and document review
Force deduction solution summary - Sword finger offer II 114 Alien dictionary
Force deduction solution summary 699- dropped blocks
Force deduction solution summary 875- coco who likes bananas
Force deduction solution summary 462- minimum number of moves to make array elements equal II
微信小程序项目实例——我有一支画笔(画画)
微积分复习2
The unique path of leetcode topic resolution II
About 100 to realize the query table? Really? Let's experience the charm of amiya.
如何防止商场电气火灾的发生?
Force deduction solution summary 386 dictionary order
Force deduction solution summary interview question 01.05 Edit once
[high code file format API] downing provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code
Apply concentrated load to nodes in batch in ABAQUS
Force deduction solution summary 1037- effective boomerang
Xiaopi can't start the MySQL database. Please find out!
Alertmanager alarm configuration
Maya foreground rendering plug-in Mel scripting tool
min25筛
Ue4\ue5 touch screen touch event: single finger and double finger