Browse Source

Fixed width problem in terain

jancoow 10 năm trước cách đây
mục cha
commit
9c3efed771
1 tập tin đã thay đổi với 12 bổ sung5 xóa
  1. 12 5
      src/gui/simulator/AccessPoint.java

+ 12 - 5
src/gui/simulator/AccessPoint.java

@@ -1,5 +1,6 @@
 package gui.simulator;
 
+import gui.frames.MainFrame;
 
 public class AccessPoint extends Draw{
 	
@@ -7,6 +8,10 @@ public class AccessPoint extends Draw{
 	private static String facilityName = "Ingang";
 	private Terrain terrain;
 
+    public AccessPoint(Terrain terrain, int x, int y) {
+        super(imageLocation, x, y, 1, 0);
+        this.terrain = terrain;
+    }
 
     public AccessPoint(Terrain terrain, int x, int y, double scale, double distance) {
         super(imageLocation, x, y, scale, distance);
@@ -27,7 +32,7 @@ public class AccessPoint extends Draw{
     	} else if(x>9*terrain.getWidth()/10){
     		this.x = 9*terrain.getWidth()/10;
     		this.setRotation(90);
-    	} else if(x>0 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
+    	} else if(x>0 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getFestivalLength()-150){
     		this.x = oldPosX;
     		this.y = oldPosY;
     	} else {
@@ -37,14 +42,16 @@ public class AccessPoint extends Draw{
 
     @Override
     public void setY(double y){
+    	double oldPosX = this.getX();
     	double oldPosY = this.getY();
     	if(y<50){
-    		this.setRotation(0);
+    		this.setRotation(180);
     		this.y = 50;     
-    	} else if(y>11*terrain.getLength()/12){
+    	} else if(y>terrain.getFestivalLength()-150){
     		this.setRotation(0);
-    		this.y = 11*terrain.getLength()/12; 	
-    	} else if(x>terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getLength()-150){
+    		this.y = terrain.getFestivalLength()-150; 	
+    	} else if(x>1*terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getFestivalLength()-150){
+    		this.x = oldPosX;
     		this.y = oldPosY;
     	} else {
     		this.y = y;