refactor: gl2 & shader

This commit is contained in:
AncTe committed 2024-11-18 22:16:29 +08:00
1 parent 83a60c5018
commit 711c4c2264
7 files changed
+2237 -1924

No files matched your search

+1 -3
View File
@@ -28,6 +28,7 @@ Mota.require('var', 'loading').once('coreInit', () => {
const shader = new Shader();
shader.size(480, 480);
shader.setHD(true);
shader.setZIndex(120);
TowerBoss.shader = shader;
TowerBoss.effect.create(shader, 40);
});
@@ -151,8 +152,6 @@ export class TowerBoss extends BarrageBoss {
override start() {
super.start();
this.group.remove();
this.group.append(TowerBoss.shader);
TowerBoss.shader.append(this.mapDraw);
this.healthBar.append(this.group);
this.word.append(this.group);
@@ -177,7 +176,6 @@ export class TowerBoss extends BarrageBoss {
override end() {
super.end();
TowerBoss.shader.remove();
this.group.append(this.mapDraw);
this.healthBar.remove();
this.word.remove();
this.main.remove();
+3 -3
View File
@@ -1,5 +1,6 @@
import { logger } from '@/core/common/logger';
import { Shader, ShaderProgram, UniformType } from '@/core/render/shader';
import { UniformType } from '@/core/render/gl2';
import { Shader, ShaderProgram } from '@/core/render/shader';
import { Transform } from '@/core/render/transform';
export const enum PointEffectType {
@@ -118,8 +119,7 @@ export class PointEffect {
*/
create(shader: Shader, itemCount: number) {
if (this.program || this.shader || this.started) return;
const program = shader.createProgram();
program.setVersion(shader.VERSION_ES_300);
const program = shader.createProgram(ShaderProgram);
program.fs(generateFragment(itemCount));
program.requestCompile();
+28 -19
View File
@@ -7,7 +7,12 @@ import type {
import type { HeroRenderer } from '@/core/render/preset/hero';
import type { Layer, LayerGroup } from '@/core/render/preset/layer';
import type { TimingFn } from 'mutate-animate';
import { BlockMover, heroMoveCollection, MoveStep } from '@/game/state/move';
import {
BlockMover,
heroMoveCollection,
IMoveController,
MoveStep
} from '@/game/state/move';
import type { FloorViewport } from '@/core/render/preset/viewport';
// 向后兼容用,会充当两个版本间过渡的作用
@@ -647,26 +652,30 @@ export function init() {
}
});
const moveAction = new Set<string>(['up', 'down', 'left', 'right']);
let controller: IMoveController | null = null;
// 复写录像的移动
core.registerReplayAction('move', action => {
if (
action === 'up' ||
action === 'down' ||
action === 'left' ||
action === 'right'
) {
// const { noPass, canMove } = checkCanMove();
// const { nx, ny } = getNextLoc();
// if (noPass || !canMove) {
// if (canMove) core.trigger(nx, ny);
// } else {
// core.setHeroLoc('x', nx);
// core.setHeroLoc('y', ny);
// core.setHeroLoc('direction', action);
// }
// setTimeout(core.replay, 100);
if (moveAction.has(action)) {
const next = core.status.replay.toReplay[1];
if (!heroMover.moving) {
controller = heroMover.startMove();
}
if (!controller) {
return false;
}
controller.push({
type: 'dir',
value: action as Dir
});
if (moveAction.has(next)) {
core.replay();
} else {
controller.onEnd.then(() => {
core.replay();
controller = null;
});
}
return true;
} else {
return false;