Merge branch 'master' into gh-pages
Conflicts: index.html
This commit is contained in:
commit
e38347b6ad
307
game.js
Normal file
307
game.js
Normal file
@ -0,0 +1,307 @@
|
||||
'use strict';
|
||||
/*
|
||||
* 小型游戏引擎
|
||||
*/
|
||||
function Game(id,options){
|
||||
var _ = this;
|
||||
options = options||{};
|
||||
var settings = {
|
||||
width:960, //画布宽度
|
||||
height:640 //画布高度
|
||||
};
|
||||
for(var i in settings){
|
||||
this[i] = options[i]||settings[i];
|
||||
}
|
||||
var $canvas = document.getElementById(id);
|
||||
$canvas.width = _.width;
|
||||
$canvas.height = _.height;
|
||||
var _context = $canvas.getContext('2d'); //画布上下文环境
|
||||
var _stages = []; //布景对象队列
|
||||
var _events = {}; //事件集合
|
||||
var _index, //当前布景索引
|
||||
_hander; //帧动画控制
|
||||
//活动对象构造
|
||||
var Item = function(options){
|
||||
options = options||{};
|
||||
var settings = {
|
||||
x:0, //横坐标
|
||||
y:0, //纵坐标
|
||||
width:20, //宽
|
||||
height:20, //高
|
||||
type:0, //对象类型,0表示普通对象(不与地图绑定),1表示玩家控制对象,2表示程序控制对象
|
||||
color:'#F00', //标识颜色
|
||||
status:1, //对象状态,1表示正常,0表示隐藏,2表示暂停
|
||||
orientation:0, //当前定位方向,0表示上,1表示右,2表示下,3表示左
|
||||
vector:{}, //目标坐标
|
||||
coord:{}, //如果对象与地图绑定,获得坐标值
|
||||
speed:0, //移动速度
|
||||
frames:1, //速度等级,内部计算器times多少帧变化一次
|
||||
times:0, //计数
|
||||
control:{}, //控制缓存,到达定位点时处理
|
||||
path:[], //NPC自动行走的路径
|
||||
index:0, //对象索引
|
||||
stage:null, //绑定对象与所属布景绑定
|
||||
update:function(){}, //更新参数信息
|
||||
draw:function(){} //绘制
|
||||
};
|
||||
for(var i in settings){
|
||||
this[i] = options[i]||settings[i];
|
||||
}
|
||||
};
|
||||
Item.prototype.bind = function(eventType,callback){
|
||||
if(!_events[eventType]){
|
||||
_events[eventType] = {};
|
||||
$canvas.addEventListener(eventType,function(e){
|
||||
var position = _.getPosition(e);
|
||||
_stages[_index].items.forEach(function(item){
|
||||
if(Math.abs(position.x-item.x)<item.width/2&&Math.abs(position.y-item.y)<item.height/2){
|
||||
var key = 's'+_index+'i'+item.index;
|
||||
if(_events[eventType][key]){
|
||||
_events[eventType][key](e);
|
||||
}
|
||||
}
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
_events[eventType]['s'+this.stage.index+'i'+this.index] = callback.bind(this); //绑定作用域
|
||||
};
|
||||
//地图对象构造器
|
||||
var Map = function(options){
|
||||
options = options||{};
|
||||
var settings = {
|
||||
x:0, //地图起点坐标
|
||||
y:0,
|
||||
size:20, //地图单元的宽度
|
||||
data:[], //地图数据
|
||||
stage:null, //布景
|
||||
x_length:0, //二维数组x轴长度
|
||||
y_length:0, //二维数组y轴长度
|
||||
update:function(){}, //更新地图数据
|
||||
draw:function(){}, //绘制地图
|
||||
};
|
||||
for(var i in settings){
|
||||
this[i] = options[i]||settings[i];
|
||||
}
|
||||
};
|
||||
//获取地图上某点的值
|
||||
Map.prototype.get = function(x,y){
|
||||
if(this.data[y]&&typeof this.data[y][x]!='undefined'){
|
||||
return this.data[y][x];
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
//地图坐标转画布坐标
|
||||
Map.prototype.coord2position = function(cx,cy){
|
||||
return {
|
||||
x:this.x+cx*this.size+this.size/2,
|
||||
y:this.y+cy*this.size+this.size/2
|
||||
};
|
||||
};
|
||||
//画布坐标转地图坐标
|
||||
Map.prototype.position2coord = function(x,y){
|
||||
var fx = (x-this.x)%this.size-this.size/2;
|
||||
var fy = (y-this.y)%this.size-this.size/2;
|
||||
return {
|
||||
x:Math.floor((x-this.x)/this.size),
|
||||
y:Math.floor((y-this.y)/this.size),
|
||||
offset:Math.sqrt(fx*fx+fy*fy)
|
||||
};
|
||||
};
|
||||
//寻址算法
|
||||
Map.prototype.finder = function(param){
|
||||
var defaults = {
|
||||
map:null,//this.data,
|
||||
start:{},
|
||||
end:{}
|
||||
};
|
||||
var options = (function(target, params) {
|
||||
for (var prop in params) {
|
||||
target[prop] = params[prop];
|
||||
}
|
||||
return target;
|
||||
})(defaults,param);
|
||||
var result = [];
|
||||
if(options.map[options.start.y][options.start.x]||options.map[options.end.y][options.end.x]){ //当起点或终点设置在墙上
|
||||
return [];
|
||||
}
|
||||
var finded = false;
|
||||
var y_length = options.map.length;
|
||||
var x_length = options.map[0].length;
|
||||
var steps = []; //步骤的映射
|
||||
for(var y=y_length;y--;){
|
||||
steps[y] = [];
|
||||
for(var x=x_length;x--;){
|
||||
steps[y][x] = 0;
|
||||
}
|
||||
}
|
||||
var _render = function(list){
|
||||
var new_list = [];
|
||||
var next = function(from,to){
|
||||
if(!finded){
|
||||
var value = typeof options.map[to.y][to.x] !='undefined'?options.map[to.y][to.x]:-1;
|
||||
if(value!=1){ //当前点是否可以走
|
||||
if(value==-1){
|
||||
to.x = (to.x+x_length)%x_length;
|
||||
to.y = (to.y+y_length)%y_length;
|
||||
to.change = 1;
|
||||
}
|
||||
if(to.x==options.end.x&&to.y==options.end.y){
|
||||
steps[to.y][to.x] = from;
|
||||
finded = true;
|
||||
}else if(!steps[to.y][to.x]){
|
||||
steps[to.y][to.x] = from;
|
||||
new_list.push(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for(var i=0,len=list.length;i<len;i++){
|
||||
var current = list[i];
|
||||
next(current,{y:current.y+1,x:current.x});
|
||||
next(current,{y:current.y,x:current.x+1});
|
||||
next(current,{y:current.y-1,x:current.x});
|
||||
next(current,{y:current.y,x:current.x-1});
|
||||
}
|
||||
if(!finded&&new_list.length){
|
||||
_render(new_list);
|
||||
}
|
||||
};
|
||||
_render([options.start]);
|
||||
if(finded){
|
||||
var current=options.end;
|
||||
while(current.x!=options.start.x||current.y!=options.start.y){
|
||||
result.unshift(current);
|
||||
current=steps[current.y][current.x];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
//布景对象构造器
|
||||
var Stage = function(options){
|
||||
options = options||{};
|
||||
var settings = {
|
||||
status:1, //布景状态,1表示正常,0表示非活动
|
||||
map:null, //布景地图对象
|
||||
audio:[], //音频资源
|
||||
images:[], //图片资源
|
||||
items:[] //对象队列
|
||||
};
|
||||
for(var i in settings){
|
||||
this[i] = options[i]||settings[i];
|
||||
}
|
||||
};
|
||||
//动画开始
|
||||
Stage.prototype.start = function() {
|
||||
var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||window.mozRequestAnimationFrame ||window.msRequestAnimationFrame;
|
||||
var f = 0; //帧数计算
|
||||
var stage = this;
|
||||
var fn = function(){
|
||||
_context.clearRect(0,0,_.width,_.height); //清除画布
|
||||
f++;
|
||||
if(stage.map){
|
||||
stage.map.update();
|
||||
stage.map.draw(_context);
|
||||
}
|
||||
if(stage.items.length){
|
||||
stage.items.forEach(function(item,index){
|
||||
if(stage.status!=2&&item.status!=2){ //对象及布景状态不为暂停
|
||||
if(!(f%item.frames)){
|
||||
item.times = f/item.frames; //计数器
|
||||
}
|
||||
if(stage.map&&item.type){
|
||||
item.coord = stage.map.position2coord(item.x,item.y);
|
||||
}
|
||||
item.update();
|
||||
}
|
||||
item.draw(_context);
|
||||
});
|
||||
}
|
||||
_hander = requestAnimationFrame(fn);
|
||||
};
|
||||
this.stop();
|
||||
_hander = requestAnimationFrame(fn);
|
||||
};
|
||||
//动画结束
|
||||
Stage.prototype.stop = function(){
|
||||
var cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame ||window.msCancelAnimationFrame;
|
||||
_hander&&cancelAnimationFrame(_hander);
|
||||
};
|
||||
//添加对象
|
||||
Stage.prototype.createItem = function(options){
|
||||
var item = new Item(options);
|
||||
//动态属性
|
||||
item.stage = this;
|
||||
item.index = this.items.length;
|
||||
if(this.map&&item.type){
|
||||
item.coord = this.map.position2coord(item.x,item.y);
|
||||
}
|
||||
this.items.push(item);
|
||||
return item;
|
||||
};
|
||||
//获取对象列表
|
||||
Stage.prototype.getItemsByType = function(type){
|
||||
var items = this.items.filter(function(item){
|
||||
if(item.type==type){
|
||||
return item;
|
||||
}
|
||||
});
|
||||
return items;
|
||||
};
|
||||
//添加地图
|
||||
Stage.prototype.createMap = function(options){
|
||||
var map = new Map(options);
|
||||
//动态属性
|
||||
this.map = map;
|
||||
map.stage = this;
|
||||
map.y_length = map.data.length;
|
||||
map.x_length = map.data[0].length;
|
||||
return map;
|
||||
};
|
||||
//绑定事件
|
||||
Stage.prototype.bind = function(eventType,callback){
|
||||
if(!_events[eventType]){
|
||||
_events[eventType] = {};
|
||||
window.addEventListener(eventType,function(e){
|
||||
var key = 's' + _index;
|
||||
if(_events[eventType][key]){
|
||||
_events[eventType][key](e);
|
||||
}
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
_events[eventType]['s'+this.index] = callback.bind(this); //绑定事件作用域
|
||||
};
|
||||
//事件坐标
|
||||
this.getPosition = function(e){
|
||||
var box = $canvas.getBoundingClientRect();
|
||||
return {
|
||||
x:e.clientX-box.left*(_.width/box.width),
|
||||
y:e.clientY-box.top*(_.height/box.height)
|
||||
};
|
||||
}
|
||||
//创建布景
|
||||
this.createStage = function(options){
|
||||
var stage = new Stage(options);
|
||||
stage.index = _stages.length;
|
||||
_stages.push(stage);
|
||||
return stage;
|
||||
};
|
||||
//下个布景
|
||||
this.nextStage = function(){
|
||||
if(_index<_stages.length-1){
|
||||
_stages[_index] = 0;
|
||||
_index++;
|
||||
_stages[_index].start();
|
||||
}else{
|
||||
throw new Error('unfound new stage.');
|
||||
}
|
||||
};
|
||||
//初始化游戏引擎
|
||||
this.init = function(){
|
||||
_index = 0;
|
||||
if(_stages[_index]){
|
||||
_stages[_index].start();
|
||||
}
|
||||
};
|
||||
}
|
72
index.html
72
index.html
@ -1,57 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Pacman by mumuy</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
|
||||
</head>
|
||||
<body>
|
||||
<section class="page-header">
|
||||
<h1 class="project-name">Pacman</h1>
|
||||
<h2 class="project-tagline">Pacman. 吃豆游戏</h2>
|
||||
<a href="https://github.com/mumuy/pacman" class="btn">View on GitHub</a>
|
||||
<a href="https://github.com/mumuy/pacman/zipball/master" class="btn">Download .zip</a>
|
||||
<a href="https://github.com/mumuy/pacman/tarball/master" class="btn">Download .tar.gz</a>
|
||||
</section>
|
||||
|
||||
<section class="main-content">
|
||||
<h3>
|
||||
<a id="welcome-to-github-pages" class="anchor" href="#welcome-to-github-pages" aria-hidden="true"><span class="octicon octicon-link"></span></a>Welcome to GitHub Pages.</h3>
|
||||
|
||||
<p>This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here <a href="https://guides.github.com/features/mastering-markdown/">using GitHub Flavored Markdown</a>, select a template crafted by a designer, and publish. After your page is generated, you can check out the new <code>gh-pages</code> branch locally. If you’re using GitHub Desktop, simply sync your repository and you’ll see the new branch.</p>
|
||||
|
||||
<h3>
|
||||
<a id="designer-templates" class="anchor" href="#designer-templates" aria-hidden="true"><span class="octicon octicon-link"></span></a>Designer Templates</h3>
|
||||
|
||||
<p>We’ve crafted some handsome templates for you to use. Go ahead and click 'Continue to layouts' to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved.</p>
|
||||
|
||||
<h3>
|
||||
<a id="creating-pages-manually" class="anchor" href="#creating-pages-manually" aria-hidden="true"><span class="octicon octicon-link"></span></a>Creating pages manually</h3>
|
||||
|
||||
<p>If you prefer to not use the automatic generator, push a branch named <code>gh-pages</code> to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.</p>
|
||||
|
||||
<h3>
|
||||
<a id="authors-and-contributors" class="anchor" href="#authors-and-contributors" aria-hidden="true"><span class="octicon octicon-link"></span></a>Authors and Contributors</h3>
|
||||
|
||||
<p>You can <a href="https://github.com/blog/821" class="user-mention">@mention</a> a GitHub username to generate a link to their profile. The resulting <code><a></code> element will link to the contributor’s GitHub Profile. For example: In 2007, Chris Wanstrath (<a href="https://github.com/defunkt" class="user-mention">@defunkt</a>), PJ Hyett (<a href="https://github.com/pjhyett" class="user-mention">@pjhyett</a>), and Tom Preston-Werner (<a href="https://github.com/mojombo" class="user-mention">@mojombo</a>) founded GitHub.</p>
|
||||
|
||||
<h3>
|
||||
<a id="support-or-contact" class="anchor" href="#support-or-contact" aria-hidden="true"><span class="octicon octicon-link"></span></a>Support or Contact</h3>
|
||||
|
||||
<p>Having trouble with Pages? Check out our <a href="https://help.github.com/pages">documentation</a> or <a href="https://github.com/contact">contact support</a> and we’ll help you sort it out.</p>
|
||||
|
||||
<footer class="site-footer">
|
||||
<span class="site-footer-owner"><a href="https://github.com/mumuy/pacman">Pacman</a> is maintained by <a href="https://github.com/mumuy">mumuy</a>.</span>
|
||||
|
||||
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
|
||||
</footer>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Pac-Man . 吃豆游戏</title>
|
||||
<style>
|
||||
*{padding:0;margin:0;}
|
||||
canvas{display:block;background: #000;margin:0 auto;line-height:36px;text-align: center;color:#999;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" width="960" height="640">Canvas not supported</canvas>
|
||||
<script src="game.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
482
index.js
Normal file
482
index.js
Normal file
@ -0,0 +1,482 @@
|
||||
//主程序,业务逻辑
|
||||
(function(){
|
||||
var game = new Game('canvas');
|
||||
//启动页
|
||||
(function(){
|
||||
var stage = game.createStage();
|
||||
stage.bind('keydown',function(e){
|
||||
switch(e.keyCode){
|
||||
case 13:
|
||||
case 32:
|
||||
game.nextStage();
|
||||
break;
|
||||
}
|
||||
});
|
||||
//logo
|
||||
stage.createItem({
|
||||
x:game.width/2,
|
||||
y:game.height*.45,
|
||||
width:100,
|
||||
height:100,
|
||||
frames:10,
|
||||
draw:function(context){
|
||||
context.fillStyle = '#FC3';
|
||||
context.beginPath();
|
||||
if(this.times%2){
|
||||
context.arc(this.x,this.y,this.width/2,.20*Math.PI,1.80*Math.PI,false);
|
||||
}else{
|
||||
context.arc(this.x,this.y,this.width/2,.01*Math.PI,1.99*Math.PI,false);
|
||||
}
|
||||
context.lineTo(this.x,this.y);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
context.fillStyle = '#000';
|
||||
context.beginPath();
|
||||
context.arc(this.x+5,this.y-27,7,0,2*Math.PI,false);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
}
|
||||
});
|
||||
//游戏名
|
||||
stage.createItem({
|
||||
x:game.width/2,
|
||||
y:game.height*.6,
|
||||
draw:function(context){
|
||||
context.font = 'bold 42px Helvetica';
|
||||
context.textAlign = 'center';
|
||||
context.textBaseline = 'middle';
|
||||
context.fillStyle = '#FFF';
|
||||
context.fillText('Pac-Man',this.x,this.y);
|
||||
}
|
||||
});
|
||||
//版权信息
|
||||
stage.createItem({
|
||||
x:game.width-12,
|
||||
y:game.height-5,
|
||||
draw:function(context){
|
||||
context.font = '14px Helvetica';
|
||||
context.textAlign = 'right';
|
||||
context.textBaseline = 'bottom';
|
||||
context.fillStyle = '#AAA';
|
||||
context.fillText('© passer-by.com',this.x,this.y);
|
||||
}
|
||||
});
|
||||
})();
|
||||
//游戏主程序
|
||||
(function(){
|
||||
var MAP_ORIENTATION = { //地图方向
|
||||
'38':0,
|
||||
'39':1,
|
||||
'40':2,
|
||||
'37':3
|
||||
},
|
||||
MAP_DATA = [ //地图数据
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1],
|
||||
[1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1],
|
||||
[0,0,0,0,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0],
|
||||
[0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0],
|
||||
[0,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,0,0,0,0],
|
||||
[1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1],
|
||||
[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
|
||||
[1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1],
|
||||
[0,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0],
|
||||
[0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0],
|
||||
[0,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0],
|
||||
[1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1],
|
||||
[1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1],
|
||||
[1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1],
|
||||
[1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1],
|
||||
[1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1],
|
||||
[1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1],
|
||||
[1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1],
|
||||
[1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1],
|
||||
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
|
||||
],
|
||||
MAP_SIZE = 20; //地图大小
|
||||
var stage = game.createStage();
|
||||
stage.bind('keydown',function(e){
|
||||
switch(e.keyCode){
|
||||
case 13:
|
||||
case 32:
|
||||
this.status = this.status==2?1:2;
|
||||
break;
|
||||
}
|
||||
});
|
||||
//绘制地图
|
||||
var map = stage.createMap({
|
||||
x:50,
|
||||
y:10,
|
||||
data:MAP_DATA,
|
||||
draw:function(context){
|
||||
var y_length = this.data.length;
|
||||
var x_length = this.data[0].length;
|
||||
for(var j=0; j<this.y_length; j++){
|
||||
for(var i=0; i<this.x_length; i++){
|
||||
context.lineWidth = 2;
|
||||
context.strokeStyle="#09C";
|
||||
if(this.get(i,j)){
|
||||
var code = 0;
|
||||
if(this.get(i,j-1)&&!(this.get(i-1,j-1)&&this.get(i+1,j-1)&&this.get(i-1,j)&&this.get(i+1,j))){
|
||||
if(j){
|
||||
code += 1000;
|
||||
}
|
||||
}
|
||||
if(this.get(i+1,j)&&!(this.get(i+1,j-1)&&this.get(i+1,j+1)&&this.get(i,j-1)&&this.get(i,j+1))){
|
||||
if(i<x_length-1){
|
||||
code += 100;
|
||||
}
|
||||
}
|
||||
if(this.get(i,j+1)&&!(this.get(i-1,j+1)&&this.get(i+1,j+1)&&this.get(i-1,j)&&this.get(i+1,j))){
|
||||
if(j<y_length-1){
|
||||
code += 10;
|
||||
}
|
||||
}
|
||||
if(this.get(i-1,j)&&!(this.get(i-1,j-1)&&this.get(i-1,j+1)&&this.get(i,j-1)&&this.get(i,j+1))){
|
||||
if(i){
|
||||
code += 1;
|
||||
}
|
||||
}
|
||||
if(code){
|
||||
var pos = this.coord2position(i,j);
|
||||
switch(code){
|
||||
case 1100:
|
||||
context.beginPath();
|
||||
context.arc(pos.x+this.size/2,pos.y-this.size/2,this.size/2,.5*Math.PI,1*Math.PI,false);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
break;
|
||||
case 110:
|
||||
context.beginPath();
|
||||
context.arc(pos.x+this.size/2,pos.y+this.size/2,this.size/2,Math.PI,1.5*Math.PI,false);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
break;
|
||||
case 11:
|
||||
context.beginPath();
|
||||
context.arc(pos.x-this.size/2,pos.y+this.size/2,this.size/2,1.5*Math.PI,2*Math.PI,false);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
break;
|
||||
case 1001:
|
||||
context.beginPath();
|
||||
context.arc(pos.x-this.size/2,pos.y-this.size/2,this.size/2,0,.5*Math.PI,false);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
break;
|
||||
default:
|
||||
var arr = String.prototype.split.call(code,'');
|
||||
if(+arr.pop()){
|
||||
context.beginPath();
|
||||
context.moveTo(pos.x,pos.y);
|
||||
context.lineTo(pos.x-this.size/2,pos.y);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
if(+arr.pop()){
|
||||
context.beginPath();
|
||||
context.moveTo(pos.x,pos.y);
|
||||
context.lineTo(pos.x,pos.y+this.size/2);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
if(+arr.pop()){
|
||||
context.beginPath();
|
||||
context.moveTo(pos.x,pos.y);
|
||||
context.lineTo(pos.x+this.size/2,pos.y);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
if(+arr.pop()){
|
||||
context.beginPath();
|
||||
context.moveTo(pos.x,pos.y);
|
||||
context.lineTo(pos.x,pos.y-this.size/2);
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//主角
|
||||
var pos = map.coord2position(14,23);
|
||||
var player = stage.createItem({
|
||||
x:pos.x-MAP_SIZE/2,
|
||||
y:pos.y,
|
||||
width:30,
|
||||
height:30,
|
||||
type:1,
|
||||
orientation:3,
|
||||
speed:2,
|
||||
frames:10,
|
||||
update:function(){
|
||||
var coord = this.coord;
|
||||
if(!coord.offset){
|
||||
if(typeof this.control.orientation!='undefined'){
|
||||
switch(this.control.orientation){
|
||||
case 0:
|
||||
if(!map.get(coord.x,coord.y-1)){
|
||||
this.orientation = this.control.orientation;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(!map.get(coord.x+1,coord.y)){
|
||||
this.orientation = this.control.orientation;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(!map.get(coord.x,coord.y+1)){
|
||||
this.orientation = this.control.orientation;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(!map.get(coord.x-1,coord.y)){
|
||||
this.orientation = this.control.orientation;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.control = {};
|
||||
switch(this.orientation){
|
||||
case 0:
|
||||
var value = map.get(coord.x,coord.y-1);
|
||||
if(value==0){
|
||||
this.y-=this.speed;
|
||||
}else if(value<0){
|
||||
this.y += map.size*(map.y_length-1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var value = map.get(coord.x+1,coord.y);
|
||||
if(value==0){
|
||||
this.x+=this.speed;
|
||||
}else if(value<0){
|
||||
this.x -= map.size*(map.x_length-1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
var value = map.get(coord.x,coord.y+1);
|
||||
if(value==0){
|
||||
this.y+=this.speed;
|
||||
}else if(value<0){
|
||||
this.y -= map.size*(map.y_length-1);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
var value = map.get(coord.x-1,coord.y);
|
||||
if(value==0){
|
||||
this.x-=this.speed;
|
||||
}else if(value<0){
|
||||
this.x += map.size*(map.x_length-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch(this.orientation){
|
||||
case 0:
|
||||
this.y-=this.speed;
|
||||
break;
|
||||
case 1:
|
||||
this.x+=this.speed;
|
||||
break;
|
||||
case 2:
|
||||
this.y+=this.speed;
|
||||
break;
|
||||
case 3:
|
||||
this.x-=this.speed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
draw:function(context){
|
||||
context.fillStyle = '#FC3';
|
||||
context.beginPath();
|
||||
switch(this.orientation){
|
||||
case 0:
|
||||
if(this.times%2){
|
||||
context.arc(this.x,this.y,this.width/2,1.70*Math.PI,1.30*Math.PI,false);
|
||||
}else{
|
||||
context.arc(this.x,this.y,this.width/2,1.51*Math.PI,1.49*Math.PI,false);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(this.times%2){
|
||||
context.arc(this.x,this.y,this.width/2,.20*Math.PI,1.80*Math.PI,false);
|
||||
}else{
|
||||
context.arc(this.x,this.y,this.width/2,.01*Math.PI,1.99*Math.PI,false);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(this.times%2){
|
||||
context.arc(this.x,this.y,this.width/2,.70*Math.PI,.30*Math.PI,false);
|
||||
}else{
|
||||
context.arc(this.x,this.y,this.width/2,.51*Math.PI,.49*Math.PI,false);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(this.times%2){
|
||||
context.arc(this.x,this.y,this.width/2,1.20*Math.PI,.80*Math.PI,false);
|
||||
}else{
|
||||
context.arc(this.x,this.y,this.width/2,1.01*Math.PI,.99*Math.PI,false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
context.lineTo(this.x,this.y);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
}
|
||||
});
|
||||
var NPC_COLOR = ['#96F','#6C6','#C30','#3C9'];
|
||||
for(var i=0;i<4;i++){
|
||||
var pos = map.coord2position(12+i,14);
|
||||
stage.createItem({
|
||||
x:pos.x,
|
||||
y:pos.y,
|
||||
width:30,
|
||||
height:30,
|
||||
color:NPC_COLOR[i],
|
||||
type:2,
|
||||
frames:10,
|
||||
speed:1,
|
||||
update:function(){
|
||||
if(!this.coord.offset){
|
||||
var new_map = [];
|
||||
for(var j=0;j<map.data.length;j++){
|
||||
new_map[j]=[];
|
||||
for(var k=0;k<map.data[0].length;k++){
|
||||
new_map[j][k]=map.data[j][k];
|
||||
}
|
||||
}
|
||||
var items = stage.getItemsByType(2);
|
||||
var index = this.index;
|
||||
items.forEach(function(item){
|
||||
if(item.coord.y&&item.index!=index){
|
||||
new_map[item.coord.y][item.coord.x]=1;
|
||||
}
|
||||
});
|
||||
this.path = map.finder({
|
||||
map:new_map,
|
||||
start:this.coord,
|
||||
end:player.coord
|
||||
});
|
||||
if(this.path.length){
|
||||
this.vector = this.path[0];
|
||||
if(this.vector.change){ //是否转变方向
|
||||
this.coord.x = this.vector.x;
|
||||
this.coord.y = this.vector.y;
|
||||
var pos = map.coord2position(this.coord.x,this.coord.y);
|
||||
this.x = pos.x;
|
||||
this.y = pos.y;
|
||||
}
|
||||
}
|
||||
if(this.vector.x>this.coord.x){
|
||||
this.orientation = 1;
|
||||
}else if(this.vector.x<this.coord.x){
|
||||
this.orientation = 3;
|
||||
}else if(this.vector.y>this.coord.y){
|
||||
this.orientation = 2;
|
||||
}else if(this.vector.y<this.coord.y){
|
||||
this.orientation = 0;
|
||||
}
|
||||
}
|
||||
switch(this.orientation){
|
||||
case 0:
|
||||
this.y-=this.speed;
|
||||
break;
|
||||
case 1:
|
||||
this.x+=this.speed;
|
||||
break;
|
||||
case 2:
|
||||
this.y+=this.speed;
|
||||
break;
|
||||
case 3:
|
||||
this.x-=this.speed;
|
||||
break;
|
||||
}
|
||||
},
|
||||
draw:function(context){
|
||||
context.fillStyle = this.color;
|
||||
context.beginPath();
|
||||
context.arc(this.x,this.y,this.width*.5,0,Math.PI,true);
|
||||
switch(this.times%2){
|
||||
case 0:
|
||||
context.lineTo(this.x-this.width*.5,this.y+this.height*.4);
|
||||
context.quadraticCurveTo(this.x-this.width*.4,this.y+this.height*.5,this.x-this.width*.2,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x,this.y+this.height*.5,this.x+this.width*.2,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x+this.width*.4,this.y+this.height*.5,this.x+this.width*.5,this.y+this.height*.4);
|
||||
break;
|
||||
case 1:
|
||||
context.lineTo(this.x-this.width*.5,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x-this.width*.25,this.y+this.height*.5,this.x,this.y+this.height*.3);
|
||||
context.quadraticCurveTo(this.x+this.width*.25,this.y+this.height*.5,this.x+this.width*.5,this.y+this.height*.3);
|
||||
break;
|
||||
}
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.fillStyle = '#FFF';
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.15,this.y-this.height*.21,this.width*.12,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.15,this.y-this.height*.21,this.width*.12,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.fillStyle = '#000';
|
||||
switch(this.times%4){
|
||||
case 2:
|
||||
case 0:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.15,this.y-this.height*.27,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.15,this.y-this.height*.27,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
case 1:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.17,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.13,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
case 3:
|
||||
context.beginPath();
|
||||
context.arc(this.x-this.width*.13,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
context.beginPath();
|
||||
context.arc(this.x+this.width*.17,this.y-this.height*.25,this.width*.07,0,2*Math.PI,false);
|
||||
context.fill();
|
||||
context.closePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
stage.bind('keydown',function(e){
|
||||
player.control = {orientation:MAP_ORIENTATION[e.keyCode]};
|
||||
});
|
||||
})();
|
||||
game.init();
|
||||
game.nextStage(); //测试游戏主布景
|
||||
})();
|
@ -1 +0,0 @@
|
||||
{"name":"Pacman","tagline":"Pacman. 吃豆游戏","body":"### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here [using GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/), select a template crafted by a designer, and publish. After your page is generated, you can check out the new `gh-pages` branch locally. If you’re using GitHub Desktop, simply sync your repository and you’ll see the new branch.\r\n\r\n### Designer Templates\r\nWe’ve crafted some handsome templates for you to use. Go ahead and click 'Continue to layouts' to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved.\r\n\r\n### Creating pages manually\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `<a>` element will link to the contributor’s GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out our [documentation](https://help.github.com/pages) or [contact support](https://github.com/contact) and we’ll help you sort it out.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 GitHub Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
.pl-c /* comment */ {
|
||||
color: #969896;
|
||||
}
|
||||
|
||||
.pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */,
|
||||
.pl-s .pl-v /* string variable */ {
|
||||
color: #0086b3;
|
||||
}
|
||||
|
||||
.pl-e /* entity */,
|
||||
.pl-en /* entity.name */ {
|
||||
color: #795da3;
|
||||
}
|
||||
|
||||
.pl-s .pl-s1 /* string source */,
|
||||
.pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.pl-ent /* entity.name.tag */ {
|
||||
color: #63a35c;
|
||||
}
|
||||
|
||||
.pl-k /* keyword, storage, storage.type */ {
|
||||
color: #a71d5d;
|
||||
}
|
||||
|
||||
.pl-pds /* punctuation.definition.string, string.regexp.character-class */,
|
||||
.pl-s /* string */,
|
||||
.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
|
||||
.pl-sr /* string.regexp */,
|
||||
.pl-sr .pl-cce /* string.regexp constant.character.escape */,
|
||||
.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */,
|
||||
.pl-sr .pl-sre /* string.regexp source.ruby.embedded */ {
|
||||
color: #183691;
|
||||
}
|
||||
|
||||
.pl-v /* variable */ {
|
||||
color: #ed6a43;
|
||||
}
|
||||
|
||||
.pl-id /* invalid.deprecated */ {
|
||||
color: #b52a1d;
|
||||
}
|
||||
|
||||
.pl-ii /* invalid.illegal */ {
|
||||
background-color: #b52a1d;
|
||||
color: #f8f8f8;
|
||||
}
|
||||
|
||||
.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
|
||||
color: #63a35c;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pl-ml /* markup.list */ {
|
||||
color: #693a17;
|
||||
}
|
||||
|
||||
.pl-mh /* markup.heading */,
|
||||
.pl-mh .pl-en /* markup.heading entity.name */,
|
||||
.pl-ms /* meta.separator */ {
|
||||
color: #1d3e81;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pl-mq /* markup.quote */ {
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.pl-mi /* markup.italic */ {
|
||||
color: #333;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.pl-mb /* markup.bold */ {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pl-md /* markup.deleted, meta.diff.header.from-file */ {
|
||||
background-color: #ffecec;
|
||||
color: #bd2c00;
|
||||
}
|
||||
|
||||
.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ {
|
||||
background-color: #eaffea;
|
||||
color: #55a532;
|
||||
}
|
||||
|
||||
.pl-mdr /* meta.diff.range */ {
|
||||
color: #795da3;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pl-mo /* meta.output */ {
|
||||
color: #1d3e81;
|
||||
}
|
||||
|
424
stylesheets/normalize.css
vendored
424
stylesheets/normalize.css
vendored
@ -1,424 +0,0 @@
|
||||
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
|
||||
|
||||
/**
|
||||
* 1. Set default font family to sans-serif.
|
||||
* 2. Prevent iOS text size adjust after orientation change, without disabling
|
||||
* user zoom.
|
||||
*/
|
||||
|
||||
html {
|
||||
font-family: sans-serif; /* 1 */
|
||||
-ms-text-size-adjust: 100%; /* 2 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove default margin.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* HTML5 display definitions
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Correct `block` display not defined for any HTML5 element in IE 8/9.
|
||||
* Correct `block` display not defined for `details` or `summary` in IE 10/11
|
||||
* and Firefox.
|
||||
* Correct `block` display not defined for `main` in IE 11.
|
||||
*/
|
||||
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
main,
|
||||
menu,
|
||||
nav,
|
||||
section,
|
||||
summary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct `inline-block` display not defined in IE 8/9.
|
||||
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
audio,
|
||||
canvas,
|
||||
progress,
|
||||
video {
|
||||
display: inline-block; /* 1 */
|
||||
vertical-align: baseline; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent modern browsers from displaying `audio` without controls.
|
||||
* Remove excess height in iOS 5 devices.
|
||||
*/
|
||||
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address `[hidden]` styling not present in IE 8/9/10.
|
||||
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
|
||||
*/
|
||||
|
||||
[hidden],
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Links
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the gray background color from active links in IE 10.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve readability when focused and also mouse hovered in all browsers.
|
||||
*/
|
||||
|
||||
a:active,
|
||||
a:hover {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address styling not present in Safari and Chrome.
|
||||
*/
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address variable `h1` font-size and margin within `section` and `article`
|
||||
* contexts in Firefox 4+, Safari, and Chrome.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address styling not present in IE 8/9.
|
||||
*/
|
||||
|
||||
mark {
|
||||
background: #ff0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address inconsistent and variable font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove border when inside `a` element in IE 8/9/10.
|
||||
*/
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct overflow not hidden in IE 9/10/11.
|
||||
*/
|
||||
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Address margin not present in IE 8/9 and Safari.
|
||||
*/
|
||||
|
||||
figure {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address differences between Firefox and other browsers.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contain overflow in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address odd `em`-unit font size rendering in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
samp {
|
||||
font-family: monospace, monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
/* Forms
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Known limitation: by default, Chrome and Safari on OS X allow very limited
|
||||
* styling of `select`, unless a `border` property is set.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 1. Correct color not being inherited.
|
||||
* Known issue: affects color of disabled elements.
|
||||
* 2. Correct font properties not being inherited.
|
||||
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
color: inherit; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
margin: 0; /* 3 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Address `overflow` set to `hidden` in IE 8/9/10/11.
|
||||
*/
|
||||
|
||||
button {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address inconsistent `text-transform` inheritance for `button` and `select`.
|
||||
* All other form control elements do not inherit `text-transform` values.
|
||||
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
|
||||
* Correct `select` style inheritance in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
|
||||
* and `video` controls.
|
||||
* 2. Correct inability to style clickable `input` types in iOS.
|
||||
* 3. Improve usability and consistency of cursor style between image-type
|
||||
* `input` and others.
|
||||
*/
|
||||
|
||||
button,
|
||||
html input[type="button"], /* 1 */
|
||||
input[type="reset"],
|
||||
input[type="submit"] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
cursor: pointer; /* 3 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-set default cursor for disabled elements.
|
||||
*/
|
||||
|
||||
button[disabled],
|
||||
html input[disabled] {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove inner padding and border in Firefox 4+.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
|
||||
* the UA stylesheet.
|
||||
*/
|
||||
|
||||
input {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
/**
|
||||
* It's recommended that you don't attempt to style these elements.
|
||||
* Firefox's implementation doesn't respect box-sizing, padding, or width.
|
||||
*
|
||||
* 1. Address box sizing set to `content-box` in IE 8/9/10.
|
||||
* 2. Remove excess padding in IE 8/9/10.
|
||||
*/
|
||||
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
|
||||
* `font-size` values of the `input`, it causes the cursor style of the
|
||||
* decrement button to change from `default` to `text`.
|
||||
*/
|
||||
|
||||
input[type="number"]::-webkit-inner-spin-button,
|
||||
input[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
|
||||
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
|
||||
* (include `-moz` to future-proof).
|
||||
*/
|
||||
|
||||
input[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */ /* 2 */
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
|
||||
* Safari (but not Chrome) clips the cancel button when the search input has
|
||||
* padding (and `textfield` appearance).
|
||||
*/
|
||||
|
||||
input[type="search"]::-webkit-search-cancel-button,
|
||||
input[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define consistent border, margin, and padding.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
border: 1px solid #c0c0c0;
|
||||
margin: 0 2px;
|
||||
padding: 0.35em 0.625em 0.75em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct `color` not being inherited in IE 8/9/10/11.
|
||||
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
|
||||
*/
|
||||
|
||||
legend {
|
||||
border: 0; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove default vertical scrollbar in IE 8/9/10/11.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't inherit the `font-weight` (applied by a rule above).
|
||||
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
|
||||
*/
|
||||
|
||||
optgroup {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Tables
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove most spacing between table cells.
|
||||
*/
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
padding: 0;
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
* {
|
||||
box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
color: #606c71; }
|
||||
|
||||
a {
|
||||
color: #1e6bb8;
|
||||
text-decoration: none; }
|
||||
a:hover {
|
||||
text-decoration: underline; }
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
margin-bottom: 1rem;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
background-color: rgba(255, 255, 255, 0.08);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-radius: 0.3rem;
|
||||
transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
|
||||
.btn + .btn {
|
||||
margin-left: 1rem; }
|
||||
|
||||
.btn:hover {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
text-decoration: none;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(255, 255, 255, 0.3); }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.btn {
|
||||
padding: 0.75rem 1rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.btn {
|
||||
padding: 0.6rem 0.9rem;
|
||||
font-size: 0.9rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
font-size: 0.9rem; }
|
||||
.btn + .btn {
|
||||
margin-top: 1rem;
|
||||
margin-left: 0; } }
|
||||
|
||||
.page-header {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background-color: #159957;
|
||||
background-image: linear-gradient(120deg, #155799, #159957); }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.page-header {
|
||||
padding: 5rem 6rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.page-header {
|
||||
padding: 3rem 4rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.page-header {
|
||||
padding: 2rem 1rem; } }
|
||||
|
||||
.project-name {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.1rem; }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.project-name {
|
||||
font-size: 3.25rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.project-name {
|
||||
font-size: 2.25rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.project-name {
|
||||
font-size: 1.75rem; } }
|
||||
|
||||
.project-tagline {
|
||||
margin-bottom: 2rem;
|
||||
font-weight: normal;
|
||||
opacity: 0.7; }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.project-tagline {
|
||||
font-size: 1.25rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.project-tagline {
|
||||
font-size: 1.15rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.project-tagline {
|
||||
font-size: 1rem; } }
|
||||
|
||||
.main-content :first-child {
|
||||
margin-top: 0; }
|
||||
.main-content img {
|
||||
max-width: 100%; }
|
||||
.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
font-weight: normal;
|
||||
color: #159957; }
|
||||
.main-content p {
|
||||
margin-bottom: 1em; }
|
||||
.main-content code {
|
||||
padding: 2px 4px;
|
||||
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
font-size: 0.9rem;
|
||||
color: #383e41;
|
||||
background-color: #f3f6fa;
|
||||
border-radius: 0.3rem; }
|
||||
.main-content pre {
|
||||
padding: 0.8rem;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
color: #567482;
|
||||
word-wrap: normal;
|
||||
background-color: #f3f6fa;
|
||||
border: solid 1px #dce6f0;
|
||||
border-radius: 0.3rem; }
|
||||
.main-content pre > code {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
color: #567482;
|
||||
word-break: normal;
|
||||
white-space: pre;
|
||||
background: transparent;
|
||||
border: 0; }
|
||||
.main-content .highlight {
|
||||
margin-bottom: 1rem; }
|
||||
.main-content .highlight pre {
|
||||
margin-bottom: 0;
|
||||
word-break: normal; }
|
||||
.main-content .highlight pre, .main-content pre {
|
||||
padding: 0.8rem;
|
||||
overflow: auto;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.45;
|
||||
border-radius: 0.3rem; }
|
||||
.main-content pre code, .main-content pre tt {
|
||||
display: inline;
|
||||
max-width: initial;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: initial;
|
||||
line-height: inherit;
|
||||
word-wrap: normal;
|
||||
background-color: transparent;
|
||||
border: 0; }
|
||||
.main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after {
|
||||
content: normal; }
|
||||
.main-content ul, .main-content ol {
|
||||
margin-top: 0; }
|
||||
.main-content blockquote {
|
||||
padding: 0 1rem;
|
||||
margin-left: 0;
|
||||
color: #819198;
|
||||
border-left: 0.3rem solid #dce6f0; }
|
||||
.main-content blockquote > :first-child {
|
||||
margin-top: 0; }
|
||||
.main-content blockquote > :last-child {
|
||||
margin-bottom: 0; }
|
||||
.main-content table {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
word-break: normal;
|
||||
word-break: keep-all; }
|
||||
.main-content table th {
|
||||
font-weight: bold; }
|
||||
.main-content table th, .main-content table td {
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #e9ebec; }
|
||||
.main-content dl {
|
||||
padding: 0; }
|
||||
.main-content dl dt {
|
||||
padding: 0;
|
||||
margin-top: 1rem;
|
||||
font-size: 1rem;
|
||||
font-weight: bold; }
|
||||
.main-content dl dd {
|
||||
padding: 0;
|
||||
margin-bottom: 1rem; }
|
||||
.main-content hr {
|
||||
height: 2px;
|
||||
padding: 0;
|
||||
margin: 1rem 0;
|
||||
background-color: #eff0f1;
|
||||
border: 0; }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.main-content {
|
||||
max-width: 64rem;
|
||||
padding: 2rem 6rem;
|
||||
margin: 0 auto;
|
||||
font-size: 1.1rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.main-content {
|
||||
padding: 2rem 4rem;
|
||||
font-size: 1.1rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.main-content {
|
||||
padding: 2rem 1rem;
|
||||
font-size: 1rem; } }
|
||||
|
||||
.site-footer {
|
||||
padding-top: 2rem;
|
||||
margin-top: 2rem;
|
||||
border-top: solid 1px #eff0f1; }
|
||||
|
||||
.site-footer-owner {
|
||||
display: block;
|
||||
font-weight: bold; }
|
||||
|
||||
.site-footer-credits {
|
||||
color: #819198; }
|
||||
|
||||
@media screen and (min-width: 64em) {
|
||||
.site-footer {
|
||||
font-size: 1rem; } }
|
||||
|
||||
@media screen and (min-width: 42em) and (max-width: 64em) {
|
||||
.site-footer {
|
||||
font-size: 1rem; } }
|
||||
|
||||
@media screen and (max-width: 42em) {
|
||||
.site-footer {
|
||||
font-size: 0.9rem; } }
|
Loading…
x
Reference in New Issue
Block a user