页面布局

html{

font-size: 125%;

margin: 0rem;

}

.wap-main{

background: -webkit-linear-gradient(right,#7e2b9a,#ac3e34); /*safari 5.1 to 6.0*/

background: -o-linear-gradient(right,#7e2b9a,#ac3e34); /*opera 11.1 to 12.0*/

background: -moz-linear-gradient(right,#7e2b9a,#ac3e34);/*firefox 3.6 to 15*/

background: linear-gradient(to right,#7e2b9a,#ac3e34);/*#7e2b9a,#ac3e34*/

height: 32rem;

}

/*动画猜拳区域*/

.game-content{

position: fixed;

background: url(img/bg_ring@2x.png)no-repeat center/contain;

width: 13.36rem;

height: 16.64rem;

left: 50%;

margin-left: -6.68rem;

top: 2.56rem;

}

.list1{

position: absolute;

width: 7.2rem;

height: 4.2rem;

background: url(img/bg-round1.png)no-repeat center/contain;

left: 50%;

margin-left: -3.34rem;

top: 4.5rem;

}

.list2{

position: absolute;

width: 7.2rem;

height: 3.2rem;

background: url(img/countdown_ready@2x.png)no-repeat center/contain;

left: 50%;

margin-left: -3.34rem;

top: 8.5rem;

}

.list3{

position: absolute;

width: 6.2rem;

height: 2.0rem;

background: url(img/tip_choosegesture@2x.png)no-repeat center/contain;

left: 50%;

margin-left: -3rem;

top: 15rem;

}

/*石头剪刀布选择区域*/

.game-btn{

position: absolute;

background-color: #df574a;

width: 14.48rem;

height: 4.8rem;

left: 50%;

margin-left: -7.24rem;

top: 20rem;

border: 0.2rem #f8e71c solid;

/*圆角矩形*/

border-radius: 1em;

}

.btn{

width: 3.5rem;

height: 3.5rem;

float: left;

margin-left: 1rem;

margin-top: 0.6rem;

/*background: url();*/

}

.btn1{

background: url(img/btn_gesture_jiandao@2x.png)no-repeat center/contain;

}

.btn2{

background: url(img/btn_gesture_shitou@3x.png)no-repeat center/contain;

}

.btn3{

background: url(img/btn_gesture_bu@2x.png)no-repeat center/contain;

}

.game-chong{

position: absolute;

width: 6.2rem;

height: 10rem;

background: url(img/chongxinkaishi.png)no-repeat center/contain;

left: 50%;

margin-left: -3rem;

top: 15rem;

}

/*倒计时*/

.game-time{

position: absolute;

width: 6rem;

height: 8rem;

top: 3rem;

left: 50%;

margin-left: -3rem;

animation: imgmove1 1s linear;

animation-fill-mode: forwards;

-moz-animation: imgmove1 1s linear;

-moz-animation-fill-mode: forwards;

-webkit-animation: imgmove1 1s linear;

-webkit-animation-fill-mode: forwards;

}

@keyframes imgmove1{

from{

transform: scale(0);

opacity: 1;

}

to{

transform: scale(1.5);

opacity: 0;

}

}

/*结果样式*/

.game-result{

position: absolute;

top:5rem;

left: 50%;

margin-left: -3.8rem;

width: 7.6rem;

height:6.08rem;

animation: move 1.5s linear ;

animation-fill-mode: forwards;

}

@keyframes move{

0%{

/*transform: translateY(0rem);*/

top:6rem;

margin-left: -3rem;

width: 3.8rem;

height:3.04rem;

}

100%{

/*transform: translateY(-2rem);*/

width: 7.6rem;

height:6.08rem;

}

}

/*出拳动画样式*/

.game-enemy, .game-player{

position: absolute;

left: 50%;

margin-left:-1.5rem;

width: 3.2rem;

height: 6.4rem;

}

.game-enemy{

top:-6.4rem;

animation: move1 1.5s linear ;

animation-fill-mode: forwards;

-webkit-animation: move1 1.5s linear ;

-moz-animation: move1 1.5s linear ; ;

-moz-animation-fill-mode:forwards ;

-webkit-animation-fill-mode:forwards ;

}

@keyframes move1{

0%{

/*transform: translateY(0rem);*/

top:-6.4rem

}

100%{

/*transform: translateY(-2rem);*/

top:-2rem

}

}

.game-player{

bottom: -6.4rem;

animation: move2 1.5s linear ;

animation-fill-mode: forwards;

-webkit-animation: move2 1.5s linear ;

-moz-animation: move2 1.5s linear ; ;

-moz-animation-fill-mode:forwards ;

-webkit-animation-fill-mode:forwards ;

}

@keyframes move2{

0%{

/*transform: translateY(0rem);*/

bottom:-6.4rem

}

100%{

/*transform: translateY(-2rem);*/

bottom:-1rem

}

}

function aa(n){

//电脑猜拳数1剪刀2拳头3布

/*Math.random()  [0,1)*3---->[0,3)+1------->[1,4) --->1,3*/

var cnum=cnum=parseInt(Math.random()*3+1,0);

var num=5;

var gametimeaa=function(){

if(num>0){

console.log(num)

document.getElementById("game-content").innerHTML=""

num--;

}else{

clearInterval(gametimeinterobj)

}

}

gametimeinterobj=setInterval(gametimeaa,1000);

function check(){

//电脑随机

console.log("cnum:"+cnum);

if(cnum==1){ //剪刀

if(n==1){

console.log("平");

return 1;

}else if(n==2){

console.log("赢");

return 2;

}else{

console.log("输");

return 3;

}

}else if(cnum==2){//石头

if(n==1){

console.log("输");

return 3;

}else if(n==2){

console.log("平");

return 1;

}else{

console.log("赢");

return 2;

}

}else if(cnum==3){//步

if(n==1){

console.log("赢");

return 2;

}else if(n==2){

console.log("输");

return 3;

}else{

console.log("平");

return 1;

}

}

}

setTimeout(bbb,5000);

function bbb(){

document.getElementById("game-content").innerHTML="";;

}

}

--

猜拳游戏html,JavaScript中实现猜拳小游戏相关推荐

  1. html5翻卡片游戏,用 JavaScript 写一个卡片小游戏

    小游戏使用了HTML5,CSS3和JavaScript的基本的技术. 将讨论数据属性.定位.透视.转换.flexbox.事件处理.超时和三元组. 你不需要在编程方面有太多的知识和经验就能看懂,不过还是 ...

  2. 电脑c语言小游戏,C语言中的一个小游戏的排行榜系统...

    我把你的代码改了一下,我已经运行过了,你看看 #include #include #include int play(int suiji); void paihangbang(struct p a[1 ...

  3. html5 网页游戏论文,JavaScript编写的网页小游戏,很给力

    以下为游戏代码: var timerID = null; var INT = 40; var loadFLG = 0; var gameFLG = 0; var missFLG = 0; var ti ...

  4. javascript小游戏_个人网站集成js小游戏《圈小猫》教程及源码

    今天在某网站浏览帖子的时候,发现帖子被删除了,然后弹出了404页面,页面上集成了一个小游戏,小游戏长什么样子呢?看下面这个图! 第一步 查看小游戏源码,发现这个小游戏完全是由JavaScript编写的 ...

  5. 用javascript编写的打字小游戏

    最近在学ExtJs,看了蔡世友老师的视频课程,在第十课中留了一个小作业,就是用javascript写一个打字小游戏,于是按照前几课所讲的知识自己编写了一个. 一.需求:网页上在随机位置会出现字母,字母 ...

  6. 弹力细胞,一个由JavaScript写的网页小游戏

    弹力细胞 (BounceCell) 一个由JavaScript写的网页小游戏 作为大一菜鸟,这是我第一次比较正式的写文章 [害臊] 游戏玩法 通过鼠标或触屏控制屏幕底部的滑动弹板将发射的小球反弹出去撞 ...

  7. 用javascript+jquery编写的小游戏-贪吃蛇(双人对战版)

    前言 这是我在多年前初学jquery, 并结合javascript, 编写的一个小游戏.那洋洋洒洒几千行的js代码时刻提醒着我"不忘初心!". 效果演示 代码 引入文件 由于用到了 ...

  8. 原生JavaScript抒写——贪吃蛇小游戏

    原生JavaScript抒写--贪吃蛇小游戏 文章目录 原生JavaScript抒写--贪吃蛇小游戏 前言 一.需求分析 二.效果展示 三.具体逻辑代码分析 1.首先创建一个html文件,然后我们利用 ...

  9. 在SAP GUI中玩扫雷小游戏

    在GUI中玩扫雷小游戏 ABAP代码: *&---------------------------------------------------------------------* *&a ...

最新文章

  1. 随机森林及重要参数解析
  2. WinDBG工具简介(.net大会中张银奎先生介绍)
  3. 图解使用CURL下载和上传文件
  4. [转载] NoSQL开篇——为什么要使用NoSQL
  5. 中山大学计算机专业研究生报录比,中山大学报录比(中山大学2019各专业报录比)...
  6. 树莓派2 利用网卡进行无线网破解
  7. 机器学习面试- 推荐系统的常用算法
  8. python-enurmate
  9. 安卓rom制作教程_刹那 刷机教程20-1三星S10 N10等系列 韩版国行安卓9升级10 详细步骤...
  10. 分布式对象存储解决方案
  11. 在中文维基百科新建用户框
  12. 无法获得 VMCI 驱动程序的版本: 句柄无效解决
  13. 基因芯片(Affymetrix)分析3:获取差异表达基因
  14. 解决Ubuntu插上耳机没声音
  15. 记录一次紫狐Rootkit应急响应过程
  16. 虚拟地址空间【详解】 虚拟地址空间是什么 | 为什么要有虚拟地址空间
  17. 云存储中不可不知的五个安全问题及应对措施
  18. unity跨平台原理
  19. Docker 很难么?带你从头到尾捋一遍,不信你学不会(文末送书)
  20. Android应用开发最强原创知识体系(更新至2019.11.21)

热门文章

  1. react native仿微信性别选择-自定义弹出框
  2. React Native顶|底部导航使用小技巧
  3. C# Winform 窗体美化(十、自定义窗体)
  4. linux 更改文件权限(子文件夹)
  5. Linux新建用户可以在shell中切换到该用户也能登录到图形桌面
  6. Log4j.properties的简单配置
  7. 百度地图离线sdk java_百度地图SDK java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapSDK...
  8. 批处理结束某个进程_进程调度
  9. kalilinux安装qt_Kali Linux 安装和搜狗输入法的安装
  10. 我xp电脑桌面没有计算机图标不见了,xp系统我的电脑图标不见了怎么办|如何找回我的电脑图标-系统城...