summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java index a2616e5..f859739 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/AbstractEvent.java
@@ -8,6 +8,7 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event;
8import com.fourisland.fourpuzzle.Direction; 8import com.fourisland.fourpuzzle.Direction;
9import com.fourisland.fourpuzzle.gamestate.mapview.Map; 9import com.fourisland.fourpuzzle.gamestate.mapview.Map;
10import com.fourisland.fourpuzzle.util.Functions; 10import com.fourisland.fourpuzzle.util.Functions;
11import com.fourisland.fourpuzzle.util.Interval;
11import java.awt.Point; 12import java.awt.Point;
12import java.util.ArrayList; 13import java.util.ArrayList;
13import java.util.List; 14import java.util.List;
@@ -60,7 +61,7 @@ public abstract class AbstractEvent implements Event {
60 if (!getParentMap().checkForCollision(this, toMove)) 61 if (!getParentMap().checkForCollision(this, toMove))
61 { 62 {
62 setAnimationStep(2); 63 setAnimationStep(2);
63 moveTimer = 4; 64 moveTimer = getMoveSpeed().getSpeed();
64 setMoving(true); 65 setMoving(true);
65 66
66 return true; 67 return true;
@@ -69,19 +70,23 @@ public abstract class AbstractEvent implements Event {
69 } 70 }
70 } 71 }
71 72
73 Interval in = Interval.createTickInterval(0.5F);
72 public void processMoving() 74 public void processMoving()
73 { 75 {
74 if (isMoving()) 76 if (isMoving())
75 { 77 {
76 moveTimer--; 78 if (in.isElapsed())
77 if (moveTimer == 2)
78 { 79 {
79 setAnimationStep(0); 80 moveTimer--;
80 } else if (moveTimer == 0) 81 if (moveTimer <= 0)
81 { 82 {
82 setAnimationStep(1); 83 setAnimationStep(1);
83 setMoving(false); 84 setMoving(false);
84 setLocation(getDirection().to(getLocation())); 85 setLocation(getDirection().to(getLocation()));
86 } else if (moveTimer <= (getMoveSpeed().getSpeed() / 2))
87 {
88 setAnimationStep(0);
89 }
85 } 90 }
86 } 91 }
87 } 92 }
@@ -146,10 +151,10 @@ public abstract class AbstractEvent implements Event {
146 { 151 {
147 if (getDirection() == Direction.West) 152 if (getDirection() == Direction.West)
148 { 153 {
149 return -((4 - moveTimer) * 4); 154 return -(Math.round((getMoveSpeed().getSpeed() - moveTimer) * (16F / getMoveSpeed().getSpeed())));
150 } else if (getDirection() == Direction.East) 155 } else if (getDirection() == Direction.East)
151 { 156 {
152 return (4 - moveTimer) * 4; 157 return Math.round((getMoveSpeed().getSpeed() - moveTimer) * (16F / getMoveSpeed().getSpeed()));
153 } 158 }
154 } 159 }
155 160
@@ -162,13 +167,24 @@ public abstract class AbstractEvent implements Event {
162 { 167 {
163 if (getDirection() == Direction.North) 168 if (getDirection() == Direction.North)
164 { 169 {
165 return -((4 - moveTimer) * 4); 170 return -(Math.round((getMoveSpeed().getSpeed() - moveTimer) * (16F / getMoveSpeed().getSpeed())));
166 } else if (getDirection() == Direction.South) 171 } else if (getDirection() == Direction.South)
167 { 172 {
168 return (4 - moveTimer) * 4; 173 return Math.round((getMoveSpeed().getSpeed() - moveTimer) * (16F / getMoveSpeed().getSpeed()));
169 } 174 }
170 } 175 }
171 176
172 return 0; 177 return 0;
173 } 178 }
179
180 private MoveSpeed moveSpeed;
181 public void setMoveSpeed(MoveSpeed moveSpeed)
182 {
183 this.moveSpeed = moveSpeed;
184 }
185
186 public MoveSpeed getMoveSpeed()
187 {
188 return moveSpeed;
189 }
174} 190}