Skip to content

Commit

Permalink
Created initial files and some simple messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gtaylor997 committed Nov 6, 2016
0 parents commit f184e6e
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Creature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.awt.Graphics;

public class Creature extends Entity{

public Creature(int size) {
super(size);
// TODO Auto-generated constructor stub
}

@Override
public void draw(Graphics g) {
// TODO Auto-generated method stub

}

}
51 changes: 51 additions & 0 deletions src/Entity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.awt.Graphics;
import java.awt.geom.Point2D;

public abstract class Entity {

private Point2D pos;
private int size;

public Entity(int size){
this.size = size;
}

/**
* Get the entities position
* @return The position of the entity
*/
public Point2D getPos() {
return pos;
}

/**
* Set the position of the entity
* @param pos The new position of the entity
*/
public void setPos(Point2D pos) {
this.pos = pos;
}

/**
* Get the size of the entity
* @return The entities size
*/
public int getSize() {
return size;
}

/**
* Set the size of the entity
* @param size THe new size of the entity
*/
public void setSize(int size) {
this.size = size;
}

/**
* Draw the entity
* @param g The graphics component
*/
public abstract void draw(Graphics g);

}
16 changes: 16 additions & 0 deletions src/Food.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.awt.Graphics;

public class Food extends Entity{

public Food(int size) {
super(size);
// TODO Auto-generated constructor stub
}

@Override
public void draw(Graphics g) {
// TODO Auto-generated method stub

}

}
18 changes: 18 additions & 0 deletions src/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.awt.geom.Point2D;
import java.util.Random;

public class Utils {

public static Random rand;

public static double getDistance(Point2D pos, Point2D pos2) {
double dx = Math.abs(pos.getX() - pos2.getX());
double dy = Math.abs(pos.getY() - pos2.getY());
double dx2 = Math.pow(dx, 2);
double dy2 = Math.pow(dy, 2);
double d = Math.sqrt(dx2 + dy2);
return d;
}

}

0 comments on commit f184e6e

Please sign in to comment.