赛车小游戏c语言代码,网页赛车小游戏(纯JavaScript编写)

赛车(改良版)

利用js实现以下功能:

在四个赛道随记生成路障,其移动速度随用户生存的时间增加而增加

用户可以通过方向键或者A、D键控制用户小车左右移动,躲避路障

当路障与用户小车碰撞,游戏结束

实时记录和显示生存时间以及所得分数

效果展示

27c173666b9a

在这里插入图片描述

源代码

html

Document

Score: 0


Time: 0s

css

* {

margin: 0;

padding: 0;

}

body {

text-align: center;

}

#background {

margin: 0 auto;

width: 1000px;

background: url(../img/bg.jpg) no-repeat #5f5762;

background-position: center;

border-radius: 50px;

}

#band {

margin: 0 auto;

margin-top: 15px;

width: 300px;

height: 100px;

background-color: #333;

border-radius: 15px;

font-size: 25px;

line-height: 50px;

font-family: 'Times New Roman', Times, serif;

font-weight: bold;

color: #fff;

}

#bgImg {

position: relative;

}

#bg {

position: relative;

margin: 0px auto;

width: 320px;

background-color: #5d7182;

overflow: hidden;

/* background: url(../img/racing.png) repeat-y; */

opacity: 0.98;

}

.box, #mybox {

position: absolute;

width: 45px;

height: 60px;

background-color: #333;

/* opacity: 1; */

}

#mybox {

/* background-color: red; */

background: url(../img/mycar.png);

}

javascript

window.onload = function () {

alert('使用左右方向键或者A,D字母控制小车左右移动\n\n点击确定

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值