当前位置:网站首页>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 
边栏推荐
- JSP connecting Oracle to realize login and registration
- The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded
- Comparison between relational database and document database
- pytorch详解
- How to do a good job of dam safety monitoring
- Using pytorch and tensorflow to calculate the confusion matrix of classification model
- Interpretation of cloud native microservice technology trend
- 电商转化率这么抽象,到底是个啥?
- Qtcanpool q05: no border
- Syn retransmission caused by IPVS
猜你喜欢

Shanghai Yuge ASR CAT1 4G module 2-way low power 4G application

jq图片放大器

博客登录框

Bidirectional level conversion circuit

Shutter nestedscrollview sliding folding head pull-down refresh effect

Oracle 常用基础函数

ES9023音频解码芯片的工作原理

小球弹弹乐

JSP connects with Oracle to realize login and registration (simple)

FB、WhatsApp群发消息在2022年到底有多热门?
随机推荐
Mysql-17- create and manage tables
联想混合云Lenovo xCloud,新企业IT服务门户
Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
Data middle office: six questions data middle office
全球国家(和地区)信息JSON数据
V4l2 driver layer analysis
Jdbc的使用
[C language practice - printing hollow square and its deformation]
Online yaml to JSON tool
线条动画
[CAD drawing Video] AutoCAD 2014 master's way
Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall
学术搜索相关论文
Typescript interface
V4L2 驱动层分析
开发者的时代红利在哪里?
脚本语言和编程语言
Install fmpefg
JSP
Yin Yang master page