当前位置:网站首页>小球弹弹乐
小球弹弹乐
2022-06-28 05:21:00 【辕小白】
小球弹弹乐
css部分
<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部分
<body>
<div class="qiu"></div>
<div class="ban"></div>
</body>
jq部分
<script type="text/javascript">
var x=0;
var y=0;
var h;
var w;
var w_flag=false; //是否接触x轴边界
var h_flag=false; //是否接触y轴边界
var flag=false; //是否接触下移板
var point=0; //得分
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轴边界
w=$(window).width()-$(".qiu").width(); //x轴边界
var ban_y=y+$(".qiu").height(); //小球实时坐标(Y轴底部)
var ban_x=x+$(".qiu").width()/2; //小球实时坐标(X轴中心)
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("游戏结束,你的得分是:"+point);
point=0;
}
$(".ban").css("top",h);
$(".qiu").css({"left":x,"top":y});
var time=setTimeout("start()",1);
};
</script>
效果截图
边栏推荐
- 证明素数/质数有无限多个
- 二级造价工程师考试还没完?还有资格审核规定!
- MySQL 45讲 | 05 深入浅出索引(下)
- JS text box loses focus to modify width text and symbols
- Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
- Determine whether an attribute exists in an object
- Sharing | intelligent environmental protection - ecological civilization informatization solution (PDF attached)
- 阴阳师页面
- BioVendor sRAGE Elisa试剂盒化学性质和技术研究
- 8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
猜你喜欢

sqlmap工具使用手册
![[untitled] drv8825 stepping motor drive board schematic diagram](/img/30/02f695592f3b624ebbb2b7a9f68052.png)
[untitled] drv8825 stepping motor drive board schematic diagram

Lumiprobe细胞成像分析:PKH26 细胞膜标记试剂盒

Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid

线条动画

Extjs图书管理系统源码 智能化图书管理系统源码
![[Linux] - using xshell to install MySQL on Linux and realize the deployment of webapp](/img/07/e044a6ef14a6576dbee1c6a009ab4f.png)
[Linux] - using xshell to install MySQL on Linux and realize the deployment of webapp

!‘ Cat 'is not an internal or external command, nor is it a runnable program or batch file.

【无标题】drv8825步进电机驱动板子原理图

jsp连接oracle实现登录注册(简单)
随机推荐
What are functions in C language? What is the difference between functions in programming and functions in mathematics? Understanding functions in programming languages
Metartc5.0 API programming guide (I)
Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
2022 high altitude installation, maintenance and removal examination questions and answers
证明素数/质数有无限多个
刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
Wedding studio portal applet based on wechat applet
指定默认参数值 仍报错:error: the following arguments are required:
mysql 导出查询结果成 excel 文件
Voltage mode and current mode control of switching power supply
Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
羧酸研究:Lumiprobe 磺基花青7二羧酸
Sharing | intelligent environmental protection - ecological civilization informatization solution (PDF attached)
SlicePlane的Heading角度与Math.atan2(y,x)的对应转换关系
Quartus replication IP core
TypeScript接口
PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR
Deeplearning ai-week1-quiz
Shutter nestedscrollview sliding folding head pull-down refresh effect
Excel将一行的内容进行复制时,列与列之间是用制表符“\t”进行分隔的