博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自己写的微信小程序炸金花简单版
阅读量:4692 次
发布时间:2019-06-09

本文共 3832 字,大约阅读时间需要 12 分钟。

app.json:

{  "pages":[    "pages/index/index"  ],  "window":{    "navigationBarBackgroundColor": "#333333",      "navigationBarTextStyle":"white",    "navigationBarTitleText": "炸金花",    "backgroundColor":"#ffffff",    "backgroundTextStyle":"light",    "enablePullDownRefresh":false  }}

  index.js

Page({  data:{  num1:1,  num2:2,  num3:3,  imgNum1:1,  imgNum2:2,  imgNum3:3,  b1:"white",  b2:"white",  b3:"white",  flag:true,  butype:"primary",  butext:"开始",  hidden:true,  score:0  },  start:function(){    var that=this;    that.setData({        butype:"default",        butext:"停止"    })    if(this.data.flag){    this.go=setInterval(function(){        that.setData({              num1:Math.ceil(Math.random()*10),              num2:Math.ceil(Math.random()*10),              num3:Math.ceil(Math.random()*10),              imgNum1:Math.ceil(Math.random()*4),              imgNum2:Math.ceil(Math.random()*4),              imgNum3:Math.ceil(Math.random()*4),              b1:"#"+Math.floor(Math.random()*1000000),              b2:"#"+Math.floor(Math.random()*1000000),              b3:"#"+Math.floor(Math.random()*1000000)        })    },100)    this.setData({      flag:false,      hidden:true,      score:0        })        }else{            clearInterval(this.go)      this.setData({        flag:true,        butype:"primary",        butext:"开始",        b1:"white",        b2:"white",        b3:"white"      })      var n1=this.data.num1;      var n2=this.data.num2;      var n3=this.data.num3;      var img1=this.data.imgNum1;      var img2=this.data.imgNum2;      var img3=this.data.imgNum3;      var result=n1+n2+n3;           if(img1==img2&&img2==img3){        result+=20;      }else if(img1==img2 || img2==img3 || img1==img3){       result+=10;      }            var newarr=new Array();      newarr.push(n1)      newarr.push(n2)      newarr.push(n3)           for(var i=0;i
newarr[j]){ var tmp = newarr[i]; newarr[i] = newarr[j]; newarr[j] = tmp; } } } if(((newarr[2]-newarr[1])==1)&&((newarr[1]-newarr[0])==1)){ result+=30; }else if(newarr[2]==newarr[1] || newarr[2]==newarr[0] || newarr[0]==newarr[1]){ result+=10; }else if(newarr[2]==newarr[1]&&newarr[2]==newarr[0]){ result+=40; } this.setData({ hidden:false, score:result }) } }, onShareAppMessage: function () { return { title: "大小之争", desc: '激烈的竞技游戏', path: '/pages/index/index' } }})

  index.wxml:

{
{num1}}
{
{num1}}
{
{num2}}
{
{num2}}
{
{num3}}
{
{num3}}
1.如果三张数字相同得40分,如果三张数字是连续的得30分,如果两个数字是相同的得10分
2.如果三张花色一样得20分,如果两张花色一样得10分
3.三张数字之和
以上所有数字的总和为总分

  index.wxss:

.container{width:30%;height:200px;position:relative;border:1px solid #787775;box-sizing:border-box; display: inline-block;flex:1;margin:10px;border-radius:10px;box-shadow:  5px 5px 3px #787775}.text{width:30px;height:30px;position:absolute;top:15px;left:15px;font-size: 25px;font-weight: bolder}.img{width:50px;height:50px;position:absolute;top:50%;left:50%;margin-left:-25px;margin-top:-25px}.text1{width:30px;height:30px;position:absolute;bottom:15px;right:15px;font-size: 25px;font-weight: bolder;transform: rotate(180deg)}

  1.png:

2.png:

3.png

 

4.png

 

 

转载于:https://www.cnblogs.com/liuhao-web/p/6406194.html

你可能感兴趣的文章
React Native在开发过程中遇到的一些问题(俗称:坑)
查看>>
自控力阅读思维导图
查看>>
结构体的应用-成绩录入初步
查看>>
【UVa 712】S-Trees
查看>>
一次MySQL(INNODB存储引擎) 死锁捉虫记
查看>>
python urllib、urlparse、urllib2、cookielib
查看>>
ListBox和ComboBox绑定数据简单例子
查看>>
QQ聊天窗口上的广告与QQ弹窗广告的完美屏蔽去除
查看>>
weblogic连接池问题总结(转载)
查看>>
C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 数据权限增强、范围权限增强...
查看>>
基础概述
查看>>
MySQL中BLOB字段类型介绍
查看>>
Redis Sentinel机制与用法(一)
查看>>
js 更新本地当前时间
查看>>
XAF-如何在详细视图界面显示按钮(含示例项目下载)
查看>>
切换,背景、字体、图片变化
查看>>
sun.misc.BASE64Encoder找不到的解决方案
查看>>
python写注册
查看>>
js如何返回两个数的商的整数和余数部分?
查看>>
根据汉字首拼、全拼及汉字检索
查看>>