EditorView.js 658 B

123456789101112131415161718192021
  1. import { FiniteStateMachine } from "../libraries/FiniteStateMachine.js";
  2. import { LevelEditorState } from "./states/LevelEditorState.js";
  3. export class EditorView {
  4. constructor() {
  5. this.stateMachine = new FiniteStateMachine();
  6. this.stateMachine.registerState("leveleditor", new LevelEditorState(this))
  7. }
  8. async init() {
  9. this.stateMachine.setCurrentState("leveleditor");
  10. this.stateMachine.getCurrentState().enter();
  11. }
  12. draw(ctx, scaledCanvas) {
  13. this.stateMachine.getCurrentState().draw(ctx, scaledCanvas);
  14. }
  15. update(delta) {
  16. this.stateMachine.getCurrentState().update(delta);
  17. }
  18. }