Pattern Shooter

FPS with Design patterns

Коя съм аз?

  • софтуерно инженерство във ФМИ
  • .NET developer
  • Python, C++, R, JavaScript, Java, C#
  • github.com/didizlatkova

Димитрина

Златкова

Game Rules

Levels:

  1. Mountain
  2. Factory
  3. Underwater

Characters:

  • Hero
    • move
    • attack
    • equipt tools
    • change weapon
  • Enemies (four)
    • move
    • attack hero
    • capture hero

Items:

  • Tools
  • Weapons

Elements hierarchy

Design Patterns used:

  1. Abstract Factory
  2. Visitor
  3. Command
  4. Strategy
  5. Proxy
  6. Singleton
  7. Chain of resp.
  8. Template method
  9. Memento

Abstract Factory

Visitor

Command

Strategy

Proxy

Singletons

Chain of responsibility

Template method

        public void execute() {
		this.setNewPosition();
                // some code
		if (!isMovePossible()) {
			// some code
		}
		this.moveCharacter();
		// some code
	}

	public boolean isMovePossible() {
                return !this.outsideFieldBorders()
				&& !this.clashesWithNeighborCharacter()
				&& !this.clashesWithTool();
	}

        public boolean clashesWithTool() {
		// some code
	}

        public boolean clashesWithNeighborCharacter() {
		// some code
	}

        public void moveCharacter() {
		this.field.moveCharacter(this.character, newPosition);
	}

        public abstract boolean outsideFieldBorders();

        public abstract void setNewPosition();

MoveCommand.java

Template method (2)

        @Override
	public boolean outsideFieldBorders() {
		if (this.currentPosition.x == this.field.getElements()[0].length - 1) {
			return true;
		}
		
		return false;
	}
	@Override
	public void setNewPosition() {
		this.newPosition = new Position(currentPosition.x + 1,
				currentPosition.y);
	}

DownCommand.java

        @Override
	public boolean outsideFieldBorders() {
		if (this.currentPosition.y == 0) {
			return true;
		}

		return false;
	}
	@Override
	public void setNewPosition() {
		this.newPosition = new Position(currentPosition.x,
				currentPosition.y - 1);
	}

LeftCommand.java

Memento

Накрая:

Благодаря!

Въпроси?

Made with Slides.com