diff --git a/packages-user/client-modules/src/render/elements/damage.ts b/packages-user/client-modules/src/render/elements/damage.ts index f9fb541..2884cb8 100644 --- a/packages-user/client-modules/src/render/elements/damage.ts +++ b/packages-user/client-modules/src/render/elements/damage.ts @@ -19,6 +19,7 @@ import { Layer, calNeedRenderOf } from './layer'; +import { MAP_BLOCK_WIDTH, MAP_HEIGHT, MAP_WIDTH } from '../shared'; /** * 根据伤害大小获取颜色 @@ -167,9 +168,9 @@ export class Damage extends RenderItem { constructor() { super('absolute', false, true); - this.block = new BlockCacher(0, 0, core._WIDTH_, 1); + this.block = new BlockCacher(0, 0, MAP_BLOCK_WIDTH, 1); this.type = 'absolute'; - this.size(core._PX_, core._PY_); + this.size(MAP_WIDTH, MAP_HEIGHT); this.setHD(true); this.setAntiAliasing(true); } diff --git a/packages-user/client-modules/src/render/elements/viewport.ts b/packages-user/client-modules/src/render/elements/viewport.ts index 80635dd..b38dac0 100644 --- a/packages-user/client-modules/src/render/elements/viewport.ts +++ b/packages-user/client-modules/src/render/elements/viewport.ts @@ -3,6 +3,12 @@ import { HeroRenderer } from './hero'; import { ILayerGroupRenderExtends, LayerGroup } from './layer'; import { LayerGroupFloorBinder } from './layer'; import { hyper, TimingFn } from 'mutate-animate'; +import { + MAP_BLOCK_HEIGHT, + MAP_BLOCK_WIDTH, + MAP_HEIGHT, + MAP_WIDTH +} from '../shared'; export class FloorViewport implements ILayerGroupRenderExtends { id: string = 'viewport'; @@ -62,8 +68,8 @@ export class FloorViewport implements ILayerGroupRenderExtends { this.enabled = true; const { x, y } = core.status.hero.loc; const { x: nx, y: ny } = this.group.camera; - const halfWidth = core._PX_ / 2; - const halfHeight = core._PY_ / 2; + const halfWidth = MAP_WIDTH / 2; + const halfHeight = MAP_HEIGHT / 2; const cell = this.group.cellSize; const half = cell / 2; this.applyPosition( @@ -94,8 +100,8 @@ export class FloorViewport implements ILayerGroupRenderExtends { getBoundedPosition(x: number, y: number) { if (!this.checkDependency()) return { x, y }; if (!this.boundX && !this.boundY) return { x, y }; - const width = core._WIDTH_; - const height = core._HEIGHT_; + const width = MAP_BLOCK_WIDTH; + const height = MAP_BLOCK_HEIGHT; const minX = (width - 1) / 2; const minY = (height - 1) / 2; const floor = core.status.maps[this.binder!.getFloor()]; @@ -201,7 +207,7 @@ export class FloorViewport implements ILayerGroupRenderExtends { this.applyPosition(nx, ny); if (ending) { - if (this.ox === xTarget && this.oy == yTarget) { + if (this.ox === xTarget && this.oy === yTarget) { this.hero!.off('moveTick', this.movingFramer); return; } @@ -276,8 +282,8 @@ export class FloorViewport implements ILayerGroupRenderExtends { private applyPosition(x: number, y: number) { if (!this.enabled) return; if (x === this.nx && y === this.ny) return; - const halfWidth = core._PX_ / 2; - const halfHeight = core._PY_ / 2; + const halfWidth = MAP_WIDTH / 2; + const halfHeight = MAP_HEIGHT / 2; const cell = this.group.cellSize; const half = cell / 2; this.nx = x; diff --git a/packages-user/client-modules/src/render/loopMap.ts b/packages-user/client-modules/src/render/loopMap.ts index 7f173b1..ab25112 100644 --- a/packages-user/client-modules/src/render/loopMap.ts +++ b/packages-user/client-modules/src/render/loopMap.ts @@ -9,6 +9,7 @@ import { LayerGroupFloorBinder, FloorViewport } from './elements'; +import { MAP_WIDTH } from './shared'; const loopMaps = MiscData.loopMaps; @@ -71,13 +72,13 @@ function enableLoopMapElement(floorId: FloorIds) { // 这个是计算循环地图应该显示在哪 const [, y2] = transform.transformed(x1 - testPos, 0); camera.reset(); - camera.translate(core._PX_ - testPos, y2); - loopLayer.pos(transform.x - core._PX_, 0); + camera.translate(MAP_WIDTH - testPos, y2); + loopLayer.pos(transform.x - MAP_WIDTH, 0); loopLayer.show(); loopLayer.update(loopLayer); } else { const [x2, y2] = transform.transformed(testPos, 0); - if (x2 < core._PX_) { + if (x2 < MAP_WIDTH) { // 这个不用做其他运算,可以直接显示 camera.reset(); camera.translate(0, y2); diff --git a/packages-user/client-modules/src/render/shared.ts b/packages-user/client-modules/src/render/shared.ts index e6fe4bc..11b5516 100644 --- a/packages-user/client-modules/src/render/shared.ts +++ b/packages-user/client-modules/src/render/shared.ts @@ -7,9 +7,9 @@ import { Font } from '@motajs/render-style'; /** 每个格子的宽高 */ export const CELL_SIZE = 32; -/** 地图格子宽度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ +/** 地图格子宽度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ export const MAP_BLOCK_WIDTH = 15; -/** 地图格子高度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ +/** 地图格子高度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ export const MAP_BLOCK_HEIGHT = 15; /** 地图像素宽度 */ export const MAP_WIDTH = CELL_SIZE * MAP_BLOCK_WIDTH;