| @ -2,6 +2,10 @@ package school_project; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * Represent the map with its pieces. | ||||
|  * Every piece has a position element that represent its position on the map | ||||
|  */ | ||||
| public class Map extends Shape{ | ||||
|     private ArrayList<Piece> pieces; | ||||
|  | ||||
| @ -9,11 +13,6 @@ public class Map extends Shape{ | ||||
|         super(matrix); | ||||
|     } | ||||
|  | ||||
|     public Map() { | ||||
|         super(); | ||||
|     } | ||||
|  | ||||
|     // TODO: 2/27/23 Tests for Map  | ||||
|     public void addPiece(Piece piece){ | ||||
|         pieces.add(piece); | ||||
|     } | ||||
|  | ||||
| @ -1,8 +1,15 @@ | ||||
| package school_project; | ||||
|  | ||||
| /** | ||||
|  * Represent a Piece in the game. | ||||
|  * Every Piece should be contained in a Map Object. | ||||
|  * A piece has a position witch is the position of its top-leftest position in its matrix. | ||||
|  * If the piece is not placed in the Map (in a floating state) the position should be null; | ||||
|  */ | ||||
| public class Piece extends Shape{ | ||||
|  | ||||
|     private int x,y; // Position in the Map Object | ||||
|     private Vec2 Position; | ||||
|  | ||||
|     public Piece() { | ||||
|         super(); | ||||
|     } | ||||
| @ -11,6 +18,12 @@ public class Piece extends Shape{ | ||||
|         super(matrix); | ||||
|     } | ||||
|  | ||||
|     public Vec2 getPosition() { | ||||
|         return Position; | ||||
|     } | ||||
|  | ||||
|     public void getPo | ||||
|  | ||||
|     /** | ||||
|      * Rotate the matrix of the piece. Used when the player right click | ||||
|      * | ||||
|  | ||||
							
								
								
									
										19
									
								
								app/src/main/java/school_project/Vec2.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								app/src/main/java/school_project/Vec2.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| package school_project; | ||||
|  | ||||
| /** | ||||
|  * This is used to represent a position/vector/... any ensemble of 2 elements that have to work together in | ||||
|  * a plan. This way we can use some basic operations over them. | ||||
|  */ | ||||
| public class Vec2 { | ||||
|     public int x, y; | ||||
|  | ||||
|     public Vec2() { | ||||
|         x = -1; | ||||
|         y = -1; | ||||
|     } | ||||
|  | ||||
|     public Vec2(int x, int y ){ | ||||
|         this.x = x; | ||||
|         this.y = y; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user