当前位置:网站首页>Small ball playing
Small ball playing
2022-06-28 05:52:00 【Yuanxiaobai】
Small ball playing music
css part
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
.qiu{
width: 80px;
height: 80px;
background-image: url(img/0.jpg);
border-radius: 80px;
position: absolute;
}
.ban{
width: 200px;
height: 10px;
background-color: skyblue;
border-radius: 10px;
position: relative;
}
</style>
html part
<body>
<div class="qiu"></div>
<div class="ban"></div>
</body>
jq part
<script type="text/javascript">
var x=0;
var y=0;
var h;
var w;
var w_flag=false; // Contact or not x Axis boundary
var h_flag=false; // Contact or not y Axis boundary
var flag=false; // Whether it contacts the downward moving plate
var point=0; // score
var a=0;
$(function(e){
$(window).keydown(function(e){
// left 37|65,right 39\68;
//alert(e.keyCode);
w=$(window).width()-$(".ban").width();
if(e.keyCode==37||e.keyCode==65){
//alert(1);
if(0<a){
a-=20;
}
}else if(e.keyCode==39||e.keyCode==68){
if(a<w){
a+=20;
}
}
$(".ban").css("left",a);
})
start();
});
function start(){
h=$(window).height()-$(".qiu").height(); //y Axis boundary
w=$(window).width()-$(".qiu").width(); //x Axis boundary
var ban_y=y+$(".qiu").height(); // Sphere real-time coordinates (Y Shaft bottom )
var ban_x=x+$(".qiu").width()/2; // Sphere real-time coordinates (X Shaft center )
if(x < w && w_flag==false){
x=x+1;
}else{
if(x>0){
w_flag=true;
}else{
w_flag=false;
}
x-=1;
}
if(y<h && h_flag==false){
if(flag==false){
y=y+1;
if(ban_y ==h &&a<=ban_x&&ban_x<=(a+200)){
flag=true;
point+=10;
}
}else{
h_flag=true;
flag=false;
}
}else{
if(y>0){
h_flag=true;
}else{
h_flag=false;
}
y-=1;
}
if(y==h){
alert(" Game over , Your score is :"+point);
point=0;
}
$(".ban").css("top",h);
$(".qiu").css({"left":x,"top":y});
var time=setTimeout("start()",1);
};
</script>
Effect screenshots 
边栏推荐
- Cryptography notes
- YYGH-BUG-03
- 电商转化率这么抽象,到底是个啥?
- Ethereum Classic的难度计算|猿创征文
- File foundation - read / write, storage
- Relevant implementation records of CSI and local disk
- RL practice (0) - and the platform xinchou winter season [rule based policy]
- 使用pytorch和tensorflow计算分类模型的混淆矩阵
- Application of Beidou No.3 short message terminal in dam safety monitoring scheme
- YYGH-BUG-02
猜你喜欢

5G网络整体架构

jsp连接Oracle实现登录注册
![Video tutorial on website operation to achieve SEO operation [21 lectures]](/img/1f/9ae2ed5bfec5749c764630d1daccea.jpg)
Video tutorial on website operation to achieve SEO operation [21 lectures]

FB、WhatsApp群发消息在2022年到底有多热门?

Mysql-16-subquery

一看就会 MotionLayout使用的几种方式

pytorch详解

联想混合云Lenovo xCloud,新企业IT服务门户

Data middle office: six questions data middle office

Capacity scheduling absolute value configuration queue usage and pit avoidance
随机推荐
JSP connecting Oracle to realize login and registration
YYGH-6-微信登录
Data center: Seven Swords of data governance
数据仓库:DWS层设计原则
Mysql-16-subquery
预训练模型参数不匹配
Zzuli:1071 decomposing prime factor
Mosaic data enhanced mosaic
独立站卖家都在用的五大电子邮件营销技巧,你知道吗?
PKG package node project (express)
Detailed usage configuration of the shutter textbutton, overview of the shutter buttonstyle style and Practice
使用pytorch和tensorflow计算分类模型的混淆矩阵
函数栈帧的创建和销毁
1404. 将二进制表示减到1的步骤数
Interpretation of cloud native microservice technology trend
Animation de ligne
6. 毕业设计温湿度监控系统(ESP8266 + DHT11 +OLED 实时上传温湿度数据给公网服务器并在OLED显示屏上显示实时温湿度)
Data warehouse: detailed explanation of hierarchical design
一看就会 MotionLayout使用的几种方式
Data warehouse: DWS layer design principle