-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created initial files and some simple messages
- Loading branch information
0 parents
commit f184e6e
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
|