Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: johanbrook/medioqre
base: d63b10ea7c
...
head fork: johanbrook/medioqre
compare: d5e8de3557
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
3  src/event/Event.java
@@ -37,7 +37,8 @@
DID_STOP,
WAS_DAMAGED,
DID_ATTACK,
- PICKED_UP_ITEM;
+ PICKED_UP_ITEM,
+ INIT_MODEL;
}
private final Property name;
View
1  src/gui/animation/Actor.java
@@ -105,7 +105,6 @@ public void setDirection(Direction direction)
: animations.get("standNorthWest");
break;
}
- System.out.println(currentAnimation.getName());
}
public void update(double dt)
View
29 src/model/GameModel.java
@@ -11,6 +11,8 @@
import model.character.*;
import model.character.Character;
import constants.Direction;
+import event.Event;
+import event.EventBus;
/**
* Model for a game.
@@ -25,11 +27,9 @@
private Random rand = new Random();
private List<Entity> entities;
- private List<Enemy> enemies;
public GameModel() {
this.entities = new ArrayList<Entity>();
- this.enemies = new ArrayList<Enemy>();
initEntities();
}
@@ -41,12 +41,13 @@ public void newWave() {
private void initEntities() {
this.player = new Player();
- this.enemy = new Enemy(20, 10);
- this.enemy.setPosition(100, 100);
- this.enemy.setDirection(Direction.NORTH);
this.entities.add(this.player);
- this.entities.add(this.enemy);
+ this.entities.add(new Enemy(20, 10, 100, 100));
+ this.entities.add(new Enemy(20, 10, 200, 200));
+
+
+ EventBus.INSTANCE.publish(new Event(Event.Property.INIT_MODEL, this));
}
/**
@@ -95,16 +96,8 @@ public void update(double dt) {
for(int j = 0; j < this.entities.size(); j++) {
Entity w = this.entities.get(j);
- if(t != w) {
- System.out.println("T: "+t.getPosition());
- System.out.println("W: "+w.getPosition());
-
- if(!t.isColliding(w)) {
- t.move(dt);
- }
- else {
- System.out.println("** COLLISION **");
- }
+ if(!t.isColliding(w) && t != w) {
+ t.move(dt);
}
}
@@ -127,4 +120,8 @@ public void stopPlayer(){
}
+ public List<Entity> getEntities() {
+ return this.entities;
+ }
+
}
View
4 src/model/character/Character.java
@@ -3,6 +3,8 @@
import java.awt.Dimension;
import java.awt.Rectangle;
+import constants.Direction;
+
import event.Event;
import event.EventBus;
import event.Event.Property;
@@ -34,7 +36,7 @@
public Character(int movementSpeed, Rectangle collBox, Dimension size, int xoffset, int yoffset) {
super(collBox, size, xoffset, yoffset, movementSpeed);
this.health = 100;
-
+ this.setDirection(Direction.SOUTH);
}
View
7 src/model/character/Enemy.java
@@ -7,6 +7,7 @@
package model.character;
import java.awt.Dimension;
+import java.awt.Point;
import java.awt.Rectangle;
import event.Event;
@@ -21,7 +22,11 @@
private AbstractWeapon melee;
public Enemy(int movementSpeed, int damage) {
- super(movementSpeed, new Rectangle(10, 10), new Dimension(20,20), 0, 0);
+ this(movementSpeed, damage, 0, 0);
+ }
+
+ public Enemy(int movementSpeed, int damage, int x, int y) {
+ super(movementSpeed, new Rectangle(x, y, 10, 10), new Dimension(20,20), 0, 0);
this.melee = new Melee();
}

No commit comments for this range

Something went wrong with that request. Please try again.