html5游戏开发的示例分析

  介绍

小编给大家分享一下html5游戏开发的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获、下面让我们一起去了解一下吧!

一直对HMTL5做游戏饶有兴趣,而这本书刚好就是html5 2游戏初级入门的书.Demo简单注释详细,可以拿来练练的手,一个星期左右就可以读完。若要追求酷炫高大上效果,这本书恐怕要让你失望了。但作为上手书还是不错的。

 html5游戏开发的示例分析

http://pan.baidu.com/s/1dD29Nhf一共十章,都是类似于下面的小游戏,从浅到深,演示下载

 html5游戏开发的示例分析

图形和图片的绘制都很简单,关键的地方还是用数组和定时器去实现游戏的业务逻辑和效果。简单的本地存储,声音视频播放。但含金量太少了,不能满足学游戏的胃口。当当上面评价却不错。书的出发点也是做基本的入门,基本指南html5

1。基本图形:

//ball 球function 球(sy, sx,还以为,rad, stylestring), {,,, this.sx =, sx,,,,, this.sy =, sy,,,,, this.rad =, rad,,,,, this.draw =, drawball;,,,, this.moveit =, moveball;,,,, this.fillstyle =, stylestring;   }function  drawball (), {   ,,,ctx.fillStyle =, this.fillstyle;   ,,,ctx.beginPath (),,,,,//ctx.fillStyle=, rgb (0, 0, 0);   ,,,ctx.arc (this.sx, this.sy,, this.rad,, 0,, Math.PI  *, 2,,真的);   ,,,ctx.fill ();   }function  moveball (dx, dy), {,,, this.sx  +=, dx,,,,, this.sy  +=, dy;   }//Rect 方形function  Myrectangle (sy, sx,还以为,向下,sheight,, stylestring), {,,, this.sx =, sx,,,,, this.sy =, sy,,,,, this.swidth =,向下的,,,,,this.sheight =, sheight;,,,, this.fillstyle =, stylestring;,,,, this.draw =,绘制矩形,,,,,this.moveit =, moveball;//移动方法是一样的}function 绘制矩形(),{   ,,,ctx.fillStyle =, this.fillstyle;   ,,,ctx.fillRect (this.sy, this.sx,还以为,this.swidth, this.sheight);   }//多边形function  Polycard (sx, sy,, rad,, n, frontbgcolor,,背景色,,polycolor), {,,, this.sx =, sx,,,,, this.sy =, sy,,,,, this.rad =, rad,,,,, this.draw =, drawpoly;,,,, this.frontbgcolor =, frontbgcolor;,,,, this.backcolor =,背景色,,,,,this.polycolor =, polycolor;,,,, this.n =, n,,,,, this.angle =, (2, *, Math.PI),/, n,,,//parens  may  not  be 必要的。   ,,,this.moveit =, generalmove;   }//画多边形function  drawpoly (), {   ,,,ctx.fillStyle =, this.frontbgcolor;   ,,,ctx.strokeStyle =, this.backcolor;   ,,,ctx.fillRect (this.sx 安康;2,*,this.rad,, this.sy 作用;2,*,this.rad,, 4, *, this.rad,, 4, *, this.rad);   ,,,ctx.beginPath ();   ,,,ctx.fillStyle =, this.polycolor;,,,, var 我,,,,,var  rad =, this.rad;   ,,,ctx.beginPath ();   ,,,ctx.moveTo(时间+ this.sx  rad  *, Math.cos (-.5  *, this.angle),, this.sy  +, rad  *, sin (-.5  *, this.angle)),,,,, for (小姐:=,1,,小姐:& lt;, this.n;,我+ +),{   ,,,,,,,ctx.lineTo(时间+ this.sx  rad  *, Math.cos((小姐,安康;5),*,this.angle),, this.sy  +, rad  *, sin((小姐,安康;5),*,this.angle));   ,,,}   ,,,ctx.fill ();   }function  generalmove (dx, dy), {,,, this.sx  +=, dx,,,,, this.sy  +=, dy;   }//图像function 图片(sy, sx,还以为,向下,sheight,, imga), {,,, this.sx =, sx,,,,, this.sy =, sy,,,,, this.img =, imga;,,,, this.swidth =,向下的,,,,,this.sheight =, sheight;,,,, this.draw =, drawAnImage;   }function  drawAnImage (), {   ,,,ctx.drawImage (this.sx, this.img,还以为,this.sy, this.swidth,, this.sheight);   }

视图代码2。null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

html5游戏开发的示例分析