Compare commits

..

1 Commits

Author SHA1 Message Date
AncTe
67e021ecd2
Merge 206bed7dc0 into 820dc5bf4c 2025-09-28 08:31:28 +00:00
4 changed files with 14 additions and 22 deletions

View File

@ -19,7 +19,6 @@ import {
Layer, Layer,
calNeedRenderOf calNeedRenderOf
} from './layer'; } from './layer';
import { MAP_BLOCK_WIDTH, MAP_HEIGHT, MAP_WIDTH } from '../shared';
/** /**
* *
@ -168,9 +167,9 @@ export class Damage extends RenderItem<EDamageEvent> {
constructor() { constructor() {
super('absolute', false, true); super('absolute', false, true);
this.block = new BlockCacher(0, 0, MAP_BLOCK_WIDTH, 1); this.block = new BlockCacher(0, 0, core._WIDTH_, 1);
this.type = 'absolute'; this.type = 'absolute';
this.size(MAP_WIDTH, MAP_HEIGHT); this.size(core._PX_, core._PY_);
this.setHD(true); this.setHD(true);
this.setAntiAliasing(true); this.setAntiAliasing(true);
} }

View File

@ -3,12 +3,6 @@ import { HeroRenderer } from './hero';
import { ILayerGroupRenderExtends, LayerGroup } from './layer'; import { ILayerGroupRenderExtends, LayerGroup } from './layer';
import { LayerGroupFloorBinder } from './layer'; import { LayerGroupFloorBinder } from './layer';
import { hyper, TimingFn } from 'mutate-animate'; import { hyper, TimingFn } from 'mutate-animate';
import {
MAP_BLOCK_HEIGHT,
MAP_BLOCK_WIDTH,
MAP_HEIGHT,
MAP_WIDTH
} from '../shared';
export class FloorViewport implements ILayerGroupRenderExtends { export class FloorViewport implements ILayerGroupRenderExtends {
id: string = 'viewport'; id: string = 'viewport';
@ -68,8 +62,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
this.enabled = true; this.enabled = true;
const { x, y } = core.status.hero.loc; const { x, y } = core.status.hero.loc;
const { x: nx, y: ny } = this.group.camera; const { x: nx, y: ny } = this.group.camera;
const halfWidth = MAP_WIDTH / 2; const halfWidth = core._PX_ / 2;
const halfHeight = MAP_HEIGHT / 2; const halfHeight = core._PY_ / 2;
const cell = this.group.cellSize; const cell = this.group.cellSize;
const half = cell / 2; const half = cell / 2;
this.applyPosition( this.applyPosition(
@ -100,8 +94,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
getBoundedPosition(x: number, y: number) { getBoundedPosition(x: number, y: number) {
if (!this.checkDependency()) return { x, y }; if (!this.checkDependency()) return { x, y };
if (!this.boundX && !this.boundY) return { x, y }; if (!this.boundX && !this.boundY) return { x, y };
const width = MAP_BLOCK_WIDTH; const width = core._WIDTH_;
const height = MAP_BLOCK_HEIGHT; const height = core._HEIGHT_;
const minX = (width - 1) / 2; const minX = (width - 1) / 2;
const minY = (height - 1) / 2; const minY = (height - 1) / 2;
const floor = core.status.maps[this.binder!.getFloor()]; const floor = core.status.maps[this.binder!.getFloor()];
@ -207,7 +201,7 @@ export class FloorViewport implements ILayerGroupRenderExtends {
this.applyPosition(nx, ny); this.applyPosition(nx, ny);
if (ending) { if (ending) {
if (this.ox === xTarget && this.oy === yTarget) { if (this.ox === xTarget && this.oy == yTarget) {
this.hero!.off('moveTick', this.movingFramer); this.hero!.off('moveTick', this.movingFramer);
return; return;
} }
@ -282,8 +276,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
private applyPosition(x: number, y: number) { private applyPosition(x: number, y: number) {
if (!this.enabled) return; if (!this.enabled) return;
if (x === this.nx && y === this.ny) return; if (x === this.nx && y === this.ny) return;
const halfWidth = MAP_WIDTH / 2; const halfWidth = core._PX_ / 2;
const halfHeight = MAP_HEIGHT / 2; const halfHeight = core._PY_ / 2;
const cell = this.group.cellSize; const cell = this.group.cellSize;
const half = cell / 2; const half = cell / 2;
this.nx = x; this.nx = x;

View File

@ -9,7 +9,6 @@ import {
LayerGroupFloorBinder, LayerGroupFloorBinder,
FloorViewport FloorViewport
} from './elements'; } from './elements';
import { MAP_WIDTH } from './shared';
const loopMaps = MiscData.loopMaps; const loopMaps = MiscData.loopMaps;
@ -72,13 +71,13 @@ function enableLoopMapElement(floorId: FloorIds) {
// 这个是计算循环地图应该显示在哪 // 这个是计算循环地图应该显示在哪
const [, y2] = transform.transformed(x1 - testPos, 0); const [, y2] = transform.transformed(x1 - testPos, 0);
camera.reset(); camera.reset();
camera.translate(MAP_WIDTH - testPos, y2); camera.translate(core._PX_ - testPos, y2);
loopLayer.pos(transform.x - MAP_WIDTH, 0); loopLayer.pos(transform.x - core._PX_, 0);
loopLayer.show(); loopLayer.show();
loopLayer.update(loopLayer); loopLayer.update(loopLayer);
} else { } else {
const [x2, y2] = transform.transformed(testPos, 0); const [x2, y2] = transform.transformed(testPos, 0);
if (x2 < MAP_WIDTH) { if (x2 < core._PX_) {
// 这个不用做其他运算,可以直接显示 // 这个不用做其他运算,可以直接显示
camera.reset(); camera.reset();
camera.translate(0, y2); camera.translate(0, y2);

View File

@ -7,9 +7,9 @@ import { Font } from '@motajs/render-style';
/** 每个格子的宽高 */ /** 每个格子的宽高 */
export const CELL_SIZE = 32; export const CELL_SIZE = 32;
/** 地图格子宽度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ /** 地图格子宽度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
export const MAP_BLOCK_WIDTH = 15; export const MAP_BLOCK_WIDTH = 15;
/** 地图格子高度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */ /** 地图格子高度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
export const MAP_BLOCK_HEIGHT = 15; export const MAP_BLOCK_HEIGHT = 15;
/** 地图像素宽度 */ /** 地图像素宽度 */
export const MAP_WIDTH = CELL_SIZE * MAP_BLOCK_WIDTH; export const MAP_WIDTH = CELL_SIZE * MAP_BLOCK_WIDTH;