phaser实现一个二维迷宫游戏
代码语言:html
所属分类:游戏
代码描述:phaser实现一个二维迷宫游戏,移动键盘上下左右键来移动。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @import url("https://fonts.googleapis.com/css2?family=VT323&display=swap"); * { font-family: "VT323", monospace; } body { background-color: #000000; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/phaser.3.55.2.js"></script> <script > 'use strict'; console.clear(); class Settings { static MAP = [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 2, 2, 2, 2, 2, 2, 0, 1], [1, 0, 2, 0, 0, 0, 0, 2, 2, 1], [1, 0, 2, 0, 2, 2, 0, 2, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 1, 0, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 3, 3, 0, 0, 0, 1], [3, 3, 3, 3, 4, 4, 3, 3, 3, 3], ]; static TRAPS_MAP = [ [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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 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, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 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, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ]; static BLOCK_SIZE = 32; static CHARACTER_X = this.BLOCK_SIZE * 8; static CHARACTER_Y = this.BLOCK_SIZE * 1; static FINISH_X = this.BLOCK_SIZE * 8; static FINISH_Y = this.BLOCK_SIZE * 13; static FONT_SETTINGS = { fontFamily: 'VT323', fontSize: 24, stroke: '#000000', strokeThickness: 4, }; static IS_DEBUG = false; } class PreloadScene extends Phaser.Scene { constructor() { super('Preload'); } preload() { const pat.........完整代码请登录后点击上方下载按钮下载查看
网友评论0