当前位置: 首页 > news >正文

佛山自助建站软件湖南seo优化推荐

佛山自助建站软件,湖南seo优化推荐,现在网站都是拿什么软件做的,网页版微信登录二维码已失效手撸俄罗斯方块#xff08;五#xff09;——游戏主题 当确定游戏载体#xff08;如控制台#xff09;后#xff0c;界面将呈现出来。但是游戏的背景色、方块的颜色、方框颜色都应该支持扩展。 当前游戏也是如此#xff0c;引入了 Theme 的概念#xff0c;支持主题的扩…手撸俄罗斯方块五——游戏主题 当确定游戏载体如控制台后界面将呈现出来。但是游戏的背景色、方块的颜色、方框颜色都应该支持扩展。 当前游戏也是如此引入了 Theme 的概念支持主题的扩展。 AbstractTheme 系统抽象了一个AbstractTheme它将一些渲染过程中的行为进行了抽象抽象定义如下 abstract class AbstractTheme {/*** 设置外框的样式如外框的颜色、整体的背景等。* param outer 指代外框对象的元素通过修改其内容改变显示样式。*/abstract outStyle(outer: any): void;/*** 设置内框的样式如内框的颜色、整体的背景等。* param inner 指代内框对象的元素通过修改其内容改变显示样式。*/abstract innerStyle(inner: any): void;/*** 设置分数的样式。* param score 指代分数对象的元素通过修改其内容改变显示样式。*/abstract scoreStyle(score: any): void;/*** 设置状态栏的样式* param status 指代状态对象的元素。*/abstract statusStyle(status: any): void;/*** 分数的格式化字符串输入一个分数的数字将其转换为目标的样式* param score {number} 当前游戏的分数*/abstract scoreTemplate(score: number): string;abstract nextStyle(blocks: any): void;abstract currentStyle(current: any): void;/*** 设置方块区域的样式* param block 指代当前方块区域*/abstract blockStyle(block: any): void;/*** 设置current区域和已填充区域的小方块的样式* param blockItem 当前小方块如一个IBlock会拆分成4各BlockItem。* param point 当前小方块的位置信息包括x轴和y轴的坐标等信息*/abstract blockPointStyle(blockItem: any, point: Point): void;/*** 设置next区域的小方块的样式* param blockItem* param point*/abstract nextPointStyle(blockItem: any, point: Point): void; }注释已经描述得比较清晰了分别对外框、内框等进行了设定。 控制台如何实现主题 为了使主题生效需要在AbstractCanvas子类中调用Theme提供的方法。这里以ConsoleCanvas为例它的实现如下 export class ConsoleCanvas extends AbstractCanvas {render(): void {const { game } this;if (!game) {return;}const { stage, dimension } game;const printArray: string[] [];console.clear();const { score, current, next } stage;const { xSize, ySize } dimension;const outLength 1 1 xSize 1 this.rightWidth 1;if (!this.isHideOuter) {// 1. 渲染外边框的上边框const outLine1 this.getOutterLine(this.outerLeftTopChar this.createChar(xSize 2 this.rightWidth, this.horizonalChar) this.outerRightTopChar);printArray.push(outLine1);}// 2. 渲染scoreconst scoreText this.theme.scoreTemplate(score);const scoreConsoleChar ConsoleChar.create(scoreText);this.theme.scoreStyle(scoreConsoleChar);// 计算左侧需要补充的空格const leftSpace this.rightWidth - scoreText.length - 3;// 右侧需要补充的空格const rightSpace 3;let scoreLine this.getOutterLine(this.outerLeftVerticalChar) this.createChar(xSize 2 leftSpace) scoreConsoleChar.ch this.createChar(rightSpace) this.getOutterLine(this.outerRightVerticalChar);printArray.push(scoreLine);// 3. 渲染内边框的上边框let line1 this.getOutterLine(this.outerLeftVerticalChar) this.getInnerLine(this.innerLeftTopChar);for (let x 0; x xSize; x) {const oneBlockItem current?.points.find((item) item.x x);if (oneBlockItem) {line1 this.getInnerLine(bold(this.horizonalChar));} else {line1 this.getInnerLine(this.horizonalChar);}}line1 this.getInnerLine(this.innerRightTopChar) this.createChar(this.rightWidth) this.getOutterLine(this.outerRightVerticalChar);printArray.push(line1);let line2 this.getOutterLine(this.outerLeftVerticalChar) this.getInnerLine(this.innerLeftBottomChar);for (let x 0; x xSize; x) {const oneBlockItem current?.points.find((item) item.x x);if (oneBlockItem) {line2 this.getInnerLine(bold(this.horizonalChar));} else {line2 this.getInnerLine(this.horizonalChar);}}line2 this.getInnerLine(this.innerRightBottomChar) this.createChar(this.rightWidth) this.getOutterLine(this.outerRightVerticalChar);printArray.push(line2);if (!this.isHideOuter) {const outLine2 this.getOutterLine(this.outerLeftBottomChar this.createChar(xSize 2 this.rightWidth, this.horizonalChar) this.outerRightBottomChar);printArray.push(outLine2);}if (this.exitMessage) {printArray.push(this.exitMessage);} else {printArray.push();}process.stdout.write(this.handleOutput(outLength, printArray).join(\n));} }我们看到渲染上边框调用了getOutterLine方法这个方法是在AbstractCanvas中定义的它的实现如下 export class ConsoleCanvas extends AbstractCanvas {// ...getOutterLine(char: string): string {if (this.isHideOuter) {return ;}const consoleChar new ConsoleChar(str || |);this.theme.outStyle(consoleChar);return consoleChar.ch;}// ... }它内部调用了 theme.outStyle 方法对应我们上述 theme 的定义。 类似的对于内边框的渲染也是调用了getInnerLine方法它的实现如下 export class ConsoleCanvas extends AbstractCanvas {// ...getInnerLine(char: string): string {const consoleChar new ConsoleChar(str || |);this.theme.innerStyle(consoleChar);return consoleChar.ch;}// ... }这样我们就实现了主题的扩展。 主题的扩展 我们可以通过继承AbstractTheme实现自己的主题比如实现一个RedTheme export class RedTheme extends DefaultTheme {outStyle(outer: any): void {outer.ch color.red(outer.ch);} }它实现了outStyle方法将外边框的颜色设置为红色。 我们使用该主题效果如下 详细内容可以我的git项目 https://github.com/shushanfx/tetris 也可以关注我的git账号 https://github.com/shushanfx 自此手撸俄罗斯方块的代码部分就讲到这里后续将依次为开始展开从俄罗斯方块开始我们能走多远。
http://www.w-s-a.com/news/777285/

相关文章:

  • 免费微信微网站模板下载不了优化人员配置
  • wordpress 导航网站主题画流程图的网站
  • 皮卡剧网站怎样做排名网
  • 网站开发 兼职哪个网站是做安全教育
  • 商品展示类网站怎么用群晖nas做网站
  • 长腿蜘蛛wordpresssem优化推广
  • 中国铁路建设监理协会官方网站深圳福田区怎么样
  • 互联网网站开发发展wordpress文章自定义栏目
  • 众筹网站平台建设工信部网站备案系统
  • 网站301重定向代码wordpress 加子目录
  • 淄博网站制作优化推广asp做学生信息网站
  • 海口招商建设有限公司网站淮安哪有专业做网站的公司
  • 喀什哪有做网站的国内正规seo网络推广
  • 网站设计初步规划公司网页打不开是什么原因
  • 深圳企业网站建设推广服务php做的商城网站设计论文
  • 韩雪冬网站手机网站开发 宽度
  • 奉贤专业做网站新手怎么做企业网站
  • 做网站用哪几个端口 比较好手机号网站源码
  • 手机免费代理ip网站那个旅游网站做攻略最好
  • 西安做网站找哪家公司好苏州专业网站建设开发
  • dedecms如何做网站网站设计实施方案
  • 网站建设合约品牌设计有哪些
  • 织梦企业门户网站宝塔搭建wordpress网站
  • 网站为什么没有排名了11月将现新冠感染高峰
  • 网站开发维护专员岗位职责辽阳企业网站建设
  • 做外国订单有什么网站网站设计论文提纲
  • 商城网站建设报价方案导师让做网站
  • 清远市企业网站seo联系方式动易官方网站
  • 手机上怎么做能打开的网站一级域名和二级域名跨域
  • 网站首页效果图wordpress 在线教育