在好例子网,分享、交流、成长!
您当前所在位置:首页CSS 开发实例Box Model → 打砖块射击游戏代码

打砖块射击游戏代码

Box Model

下载此实例
  • 开发语言:CSS
  • 实例大小:3.32KB
  • 下载次数:10
  • 浏览次数:157
  • 发布时间:2020-08-20
  • 实例类别:Box Model
  • 发 布 人:2753313930
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 游戏

实例介绍

【实例简介】打砖块游戏
【实例截图】from clipboard
【核心代码】<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>打砖块射击</title>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  min-height: 100%;
  max-width: 100%;
  background: #111;
  font-family: Lato, sans-serif;
}

.container {
  min-height: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.game-wrap {
  position: relative;
  padding: 20px 0 0;
}

canvas {
  position: relative;
  max-width: 100%;
  border: 2px solid black;
  max-height: 100%;
  display: block;
  margin: 0 auto;
}

.content {
  color: #ccc;
  text-align: center;
  padding: 0 20px;
}

p {
  margin: 10px 0;
  font-size: 18px;
  line-height: 1.5em;
}

code {
  background: #222;
  background: -webkit-linear-gradient(#222, #000);
  background: linear-gradient(#222, #000);
  line-height: 1.3em;
  display: inline-block;
  border-radius: 3px;
  font-family: monospace;
  padding: 1px 5px;
  margin: 0 2px;
}

a {
  color: skyblue;
  text-decoration: none;
  -webkit-transition: .2s;
  transition: .2s;
}
a:hover {
  color: #b3e0f2;
  text-decoration: underline;
}

.title {
  font-size: 40px;
  font-weight: 900;
  margin: 20px 0;
}
.title span:nth-child(1) {
  color: #bf8040;
}
.title span:nth-child(2) {
  color: #bfbf40;
}
.title span:nth-child(3) {
  color: #80bf40;
}
.title span:nth-child(4) {
  color: #40bf40;
}
.title span:nth-child(5) {
  color: #40bf80;
}
.title span:nth-child(6) {
  color: #40bfbf;
}
.title span:nth-child(7) {
  color: #4080bf;
}
.title span:nth-child(8) {
  color: #4040bf;
}
.title span:nth-child(9) {
  color: #8040bf;
}
.title span:nth-child(10) {
  color: #bf40bf;
}
.title span:nth-child(11) {
  color: #bf4080;
}
</style>
</head>
<body>
<div class="container">
<div class="game-wrap">
<canvas width="960px" height="540" id="game"></canvas>
<article class="content">
<h1 class="title"><span>C</span><span>o</span><span>l</span><span>o</span><span>r</span><span> </span><span>B</span><span>l</span><span>a</span><span>s</span><span>t</span></h1>

<p>使用 小键盘"左" 和 "右" 箭头或 "a" 和 "d" 键移动, "空格键" 发射子弹。</p>
</article>
</div>
</div><script>
// Color Blast!
// License MIT
// ? 2014 Nate Wiley

(function(window){

var Game = {

init: function(){
this.c = document.getElementById("game");
this.c.width = this.c.width;
this.c.height = this.c.height;
this.ctx = this.c.getContext("2d");
this.color = "rgba(20,20,20,.7)";
this.bullets = [];
this.enemyBullets = [];
this.enemies = [];
this.particles = [];
this.bulletIndex = 0;
this.enemyBulletIndex = 0;
this.enemyIndex = 0;
this.particleIndex = 0;
this.maxParticles = 10;
this.maxEnemies = 6;
this.enemiesAlive = 0;
this.currentFrame = 0;
this.max剩余复活次数 = 3;
this.life = 0;
this.binding();
this.player = new Player();
this.本局游戏分值 = 0;
this.paused = false;
this.shooting = false;
this.oneShot = false;
this.isGameOver = false;
     this.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
for(var i = 0; i<this.maxEnemies; i ){
new Enemy();
this.enemiesAlive ;
}
this.invincibleMode(2000);

this.loop();
},

binding: function(){
window.addEventListener("keydown", this.buttonDown);
window.addEventListener("keyup", this.buttonUp);
window.addEventListener("keypress", this.keyPressed);
this.c.addEventListener("click", this.clicked);
},

clicked: function(){
if(!Game.paused) {
Game.pause();
} else {
if(Game.isGameOver){

标签: 游戏

实例下载地址

打砖块射击游戏代码

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警