当前位置:网站首页>小球弹弹乐
小球弹弹乐
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>
效果截图
边栏推荐
- 开关电源电压型与电流型控制
- 博客登录框
- To batch add background pictures and color changing effects to videos
- Liuhaiping's mobile phone passes [[uiapplication sharedapplication] delegate] window. safeAreaInsets. The height of the bottom security zone is 0
- How to develop the language pack in the one-to-one video chat source code
- Performance degradation during dpdk source code testing
- [leetcode] 12. Integer to Roman numeral
- Unity out ref params
- Leetcode 88: merge two ordered arrays
- [untitled] drv8825 stepping motor drive board schematic diagram
猜你喜欢

A guide to P2P network penetration (stun) for metartc5.0 programming

sqlmap工具使用手册

2022 safety officer-b certificate examination question bank and answers

WordPress zibll sub theme 6.4.1 happy version is free of authorization

How high is the gold content of grade II cost engineer certificate? Just look at this

Pcr/qpcr research: lumiprobe dsgreen is used for real-time PCR

Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid

OpenSSL client programming: SSL session failure caused by an obscure function

交流电和直流电的区别是什么?

MySQL export database dictionary to excel file
随机推荐
mysql 导出查询结果成 excel 文件
MySQL 45 talk | 05 explain the index in simple terms (Part 2)
[JVM] - memory partition in JVM
DPDK 源码测试时性能下降问题
MySQL export database dictionary to excel file
If a programmer goes to prison, will he be assigned to write code?
[Linux] - using xshell to install MySQL on Linux and realize the deployment of webapp
交流电和直流电的区别是什么?
2022 high altitude installation, maintenance and removal examination questions and answers
Online yaml to JSON tool
BioVendor sRAGE抗体解决方案
Extjs图书管理系统源码 智能化图书管理系统源码
Can wechat applets import the data in the cloud development database into makers with one click in the map component
关系数据库与文档数据库对比
IP datagram sending and forwarding process
【SkyWalking】一口气学完分布式链路追踪SkyWalking
[JVM] - Division de la mémoire en JVM
证明素数/质数有无限多个
分享|智慧环保-生态文明信息化解决方案(附PDF)
线条动画