Pattern Shooter
FPS with Design patterns
Коя съм аз?
- софтуерно инженерство във ФМИ
- .NET developer
- Python, C++, R, JavaScript, Java, C#
- github.com/didizlatkova
Димитрина
Златкова
Game Rules
Levels:
- Mountain
- Factory
- Underwater
Characters:
- Hero
- move
- attack
- equipt tools
- change weapon
- Enemies (four)
- move
- attack hero
- capture hero
Items:
- Tools
- Weapons
Elements hierarchy
Design Patterns used:
- Abstract Factory
- Visitor
- Command
- Strategy
- Proxy
- Singleton
- Chain of resp.
- Template method
- 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
Накрая:
Благодаря!
Въпроси?
PatternShooter
By Dimitrina Zlatkova
PatternShooter
- 574