-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
673 additions
and
432 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background-image: url("3.jpg"); | ||
} | ||
|
||
header { | ||
position: fixed; | ||
top: 0; | ||
width: 100%; | ||
} | ||
|
||
nav { | ||
background-color: #555; | ||
padding: 15px; | ||
text-align: center; | ||
box-shadow: 0 5px 4px rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
nav a { | ||
text-decoration: none; | ||
color: white; | ||
padding: 15px; | ||
} | ||
|
||
nav a:hover { | ||
background-color: #16c4ef; | ||
color: black; | ||
} | ||
|
||
section { | ||
margin: 100px; | ||
} | ||
|
||
article { | ||
background-color: rgba(255, 255, 255, 0.8); | ||
border-radius: 30px; | ||
padding: 100px; | ||
margin-bottom: 60px; | ||
box-shadow: 0 10px 4px rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
} | ||
|
||
footer { | ||
background-color: #555; | ||
color: #fff; | ||
padding: 10px; | ||
text-align: center; | ||
} | ||
|
||
.tips { | ||
width: 200px; | ||
height: auto; | ||
margin-left: 30px; | ||
margin-right: 30px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="shortcut icon" href="/assets/img/favicon.ico"> | ||
<link rel="stylesheet" type="text/css" href="/assets/style/style.css"> | ||
<title>醉墨编程</title> | ||
</head> | ||
<header> | ||
<nav> | ||
<a href="/">网站首页</a> | ||
<a href="/code">编程空间</a> | ||
<a href="/game">在线游戏</a> | ||
<a href="/tool">在线工具</a> | ||
<a href="/tips">充电打赏</a> | ||
</nav> | ||
</header> | ||
|
||
<body> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
function flush() { | ||
if (player.gameIsOver) { | ||
return | ||
} | ||
player.update() | ||
updateBullet() | ||
updateRocks() | ||
requestAnimationFrame(flush) | ||
function flush() { | ||
if (player.gameIsOver) { | ||
return | ||
} | ||
player.update() | ||
updateBullet() | ||
updateRocks() | ||
requestAnimationFrame(flush) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
var win = document.getElementById('win') | ||
var score = document.getElementById('score') | ||
var hp = document.getElementById('hp') | ||
|
||
var PERFIX_SRC = 'https://go75.github.io/plane/resource/img/' | ||
|
||
var PlAYER_SRC = PERFIX_SRC + 'player.png' | ||
var BULLET_SRC = PERFIX_SRC + 'bullet.png' | ||
var POSTFIX_ROCK = 'rock.png' | ||
var SHIELD_SRC = PERFIX_SRC + 'shield.png' | ||
var LIGHT_SRC = PERFIX_SRC + 'gun.png' | ||
|
||
var PLAYER_SPEED = 20 | ||
var BULLET_SPEED = 20 | ||
var MAX_ROCK_SPEED_X = 5 | ||
var MIN_ROCK_SPEED_Y = 5 | ||
var VAR_ROCK_SPEED_Y = 5 | ||
|
||
var BULLET_CREATE_INTERVAL = 200 | ||
|
||
var ROCK_COUNT = 10 | ||
var ROCK_KIND = 5 | ||
|
||
var ROCK_HURT = 10 | ||
|
||
var TOOL_PROBABILITY = 0.05 | ||
|
||
var SHIELD_NUM = 10 | ||
var win = document.getElementById('win') | ||
var score = document.getElementById('score') | ||
var hp = document.getElementById('hp') | ||
|
||
var PERFIX_SRC = 'https://go75.github.io/game/plane/resource/img/' | ||
|
||
var PlAYER_SRC = PERFIX_SRC + 'player.png' | ||
var BULLET_SRC = PERFIX_SRC + 'bullet.png' | ||
var POSTFIX_ROCK = 'rock.png' | ||
var SHIELD_SRC = PERFIX_SRC + 'shield.png' | ||
var LIGHT_SRC = PERFIX_SRC + 'gun.png' | ||
|
||
var PLAYER_SPEED = 20 | ||
var BULLET_SPEED = 20 | ||
var MAX_ROCK_SPEED_X = 5 | ||
var MIN_ROCK_SPEED_Y = 5 | ||
var VAR_ROCK_SPEED_Y = 5 | ||
|
||
var BULLET_CREATE_INTERVAL = 200 | ||
|
||
var ROCK_COUNT = 10 | ||
var ROCK_KIND = 5 | ||
|
||
var ROCK_HURT = 10 | ||
|
||
var TOOL_PROBABILITY = 0.05 | ||
|
||
var SHIELD_NUM = 10 | ||
var LIGHT_NUM = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var player = new Player(PlAYER_SRC, PLAYER_SPEED) | ||
flush() | ||
var player = new Player(PlAYER_SRC, PLAYER_SPEED) | ||
flush() | ||
var createBulletTimer = setInterval(createBullet, BULLET_CREATE_INTERVAL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="shortcut icon" href="/assets/img/favicon.ico"> | ||
<link rel="stylesheet" type="text/css" href="/assets/style/style.css"> | ||
<title>醉墨编程</title> | ||
<link rel="stylesheet" href="/game/plane/style/style.css"> | ||
</head> | ||
<header> | ||
<nav> | ||
<a href="/">网站首页</a> | ||
<a href="/code">编程空间</a> | ||
<a href="/game">在线游戏</a> | ||
<a href="/tool">在线工具</a> | ||
<a href="/tips">充电打赏</a> | ||
</nav> | ||
</header> | ||
|
||
<body> | ||
<div id="win"> | ||
<div id="score">0</div> | ||
<div id="hp"></div> | ||
</div> | ||
<script src="/game/plane/game/init.js"></script> | ||
<script src="/game/plane/model/controls.js"></script> | ||
<script src="/game/plane/model/image.js"></script> | ||
<script src="/game/plane/model/rock.js"></script> | ||
<script src="/game/plane/model/bullet.js"></script> | ||
<script src="/game/plane/model/player.js"></script> | ||
<script src="/game/plane/game/flush.js"></script> | ||
<script src="/game/plane/game/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
class Bullet extends Img { | ||
constructor(imgSrc, speed) { | ||
super(imgSrc) | ||
this.img.onload = () => { | ||
this.setX(player.x() + player.w() / 2 - this.w() / 2) | ||
this.setY(player.y()) | ||
} | ||
|
||
this.speed = speed | ||
} | ||
|
||
move() { | ||
let y = this.y() - this.speed | ||
|
||
this.setY(y) | ||
} | ||
} | ||
|
||
var bullets = [] | ||
|
||
function createBullet() { | ||
let bullet = new Bullet(BULLET_SRC, BULLET_SPEED) | ||
bullets.push(bullet) | ||
} | ||
|
||
function updateBullet() { | ||
for (let i = 0; i < bullets.length; i++) { | ||
let bullet = bullets[i] | ||
bullet.move() | ||
|
||
if (bullet.y() < 0) { | ||
bullet.remove() | ||
bullets.splice(i, 1) | ||
} | ||
|
||
crashProcess() | ||
} | ||
} | ||
|
||
function crashProcess() { | ||
for (let j = 0; j < ROCK_COUNT; j++) { | ||
let rock = rocks[j] | ||
if (rock.type != 0) { | ||
continue | ||
} | ||
for (let i = 0; i < bullets.length; i++) { | ||
let bullet = bullets[i] | ||
if (bullet.cross(rock)) { | ||
let randNum = Math.random() | ||
if (randNum < TOOL_PROBABILITY) { | ||
if (randNum < TOOL_PROBABILITY / 2) { | ||
rock.img.src = SHIELD_SRC | ||
rock.type = 1 | ||
} else { | ||
rock.img.src = LIGHT_SRC | ||
rock.type = 2 | ||
} | ||
} else { | ||
player.setScore(player.score() + 1) | ||
bullet.remove() | ||
bullets.splice(i, 1) | ||
rock.init() | ||
} | ||
} | ||
} | ||
} | ||
class Bullet extends Img { | ||
constructor(imgSrc, speed) { | ||
super(imgSrc) | ||
this.img.onload = () => { | ||
this.setX(player.x() + player.w() / 2 - this.w() / 2) | ||
this.setY(player.y()) | ||
} | ||
|
||
this.speed = speed | ||
} | ||
|
||
move() { | ||
let y = this.y() - this.speed | ||
|
||
this.setY(y) | ||
} | ||
} | ||
|
||
var bullets = [] | ||
|
||
function createBullet() { | ||
let bullet = new Bullet(BULLET_SRC, BULLET_SPEED) | ||
bullets.push(bullet) | ||
} | ||
|
||
function updateBullet() { | ||
for (let i = 0; i < bullets.length; i++) { | ||
let bullet = bullets[i] | ||
bullet.move() | ||
|
||
if (bullet.y() < 0) { | ||
bullet.remove() | ||
bullets.splice(i, 1) | ||
} | ||
|
||
crashProcess() | ||
} | ||
} | ||
|
||
function crashProcess() { | ||
for (let j = 0; j < ROCK_COUNT; j++) { | ||
let rock = rocks[j] | ||
if (rock.type != 0) { | ||
continue | ||
} | ||
for (let i = 0; i < bullets.length; i++) { | ||
let bullet = bullets[i] | ||
if (bullet.cross(rock)) { | ||
let randNum = Math.random() | ||
if (randNum < TOOL_PROBABILITY) { | ||
if (randNum < TOOL_PROBABILITY / 2) { | ||
rock.img.src = SHIELD_SRC | ||
rock.type = 1 | ||
} else { | ||
rock.img.src = LIGHT_SRC | ||
rock.type = 2 | ||
} | ||
} else { | ||
player.setScore(player.score() + 1) | ||
bullet.remove() | ||
bullets.splice(i, 1) | ||
rock.init() | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.