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

边栏推荐
- oracle之模式对象
- Force deduction solution summary 953 verification of alien language dictionary
- 中国银屑病药物市场评估与投资方向研究报告(2022版)
- Force deduction solution summary 449 serialization and deserialization binary search tree
- Force deduction solution summary 675- cutting trees for golf competition
- Demand and business model innovation - demand 9- prototype
- How to use DAO to build a knowledge database with collective wisdom and sustainable incentive mechanism
- 【高代码文件格式API】道宁为您提供文件格式API集——Aspose,只需几行代码即可创建转换和操作100多种文件格式
- Force deduction solution summary 467- unique substring in surrounding string
- Drawcall, batches, setpasscall in unity3d
猜你喜欢

Getting started with RPC

如何防止商场电气火灾的发生?

Demand and business model innovation - demand 10- observation and document review

I2C协议概述

Cupp dictionary generation tool (similar tools include crunch)

How to make div 100% page (not screen) height- How to make a div 100% of page (not screen) height?

How to use DAO to build a knowledge database with collective wisdom and sustainable incentive mechanism

Maya Front Office Rendering plug - in Mel script Tool

Abaqus中批量对节点施加集中力荷载

Graduation design of fire hydrant monitoring system --- thesis (add the most comprehensive hardware circuit design - > driver design - > Alibaba cloud Internet of things construction - > Android App D
随机推荐
About 100 to realize the query table? Really? Let's experience the charm of amiya.
(9) Serial port interrupt
Xiaopi can't start the MySQL database. Please find out!
Using SSH public key to transfer files
中国银屑病药物市场评估与投资方向研究报告(2022版)
2022 Fujian Provincial Safety Officer C certificate (full-time safety officer) examination simulation 100 questions and answers
跨域有哪些解决方法?
Force deduction solution summary 875- coco who likes bananas
The force deduction solution summarizes the shortest distance of 821 characters
maya前臺渲染插件mel脚本工具
余压监控系统在高层民用建筑的应用
oracle之用户和表空间
Intel case
Force deduction solution summary 713- subarray with product less than k
ssh公钥登录失败报错:sign_and_send_pubkey: no mutual signature supported
Xcall cluster script (view JPS command)
Selection (046) - what is the output of the following code?
一起教育科技单季营收2.3亿:同比降51% 净亏大幅收窄
Force deduction solution summary 668- the smallest number k in the multiplication table
[digital signal processing] correlation function (energy signal | cross correlation function of energy signal | autocorrelation function of energy signal)