5import java.awt.event.KeyEvent;
6import java.lang.reflect.Field;
22 double scfa = newscale / (old+0.0);
23 scale = newscale.intValue();
62 public void walk(
int steps) {
63 super.move(steps *
scale);
76 int dir2 = (int) olddir;
83 double change = (dir - olddir + 540) % 360 - 180;
86 double timm = time / change;
87 int tim = (int) (timm * 1000);
88 for (
int i = 0; i < change; i++) {
92 }
catch (InterruptedException e) {
100 double timm = time / p;
101 int tim = (int) (timm * 1000);
102 for (
int i = 0; i < p; i++) {
106 }
catch (InterruptedException e) {
115 double change = (dir - olddir + 540) % 360 - 180;
118 if (change == 0)
return;
121 int steps = (int) Math.abs(change);
122 boolean right = change > 0;
124 for (
int i = 0; i < steps; i++) {
125 double t1 = (double) i / steps;
126 double t2 = (double) (i + 1) / steps;
132 double delta = (c2 - c1) * time;
143 Thread.sleep((
int)(delta * 1000));
144 }
catch (InterruptedException e) {
153 case "easeIn":
return t * t;
154 case "easeOut":
return 1 - Math.pow(1 - t, 2);
158 : 1 - Math.pow(-2 * t + 2, 2) / 2;
164 double halfW =
width() / 2.0;
165 halfW /=
scale + 0.0;
166 double halfH =
height() / 2.0;
167 halfH /=
scale + 0.0;
170 double left =
xx - halfW;
171 double right =
xx + halfW;
172 double bottom =
yy - halfH;
173 double top =
yy + halfH;
175 return right >= -240 &&
181 @SuppressWarnings(
"unchecked")
185 Field costumesField =
Sprite.class.getDeclaredField(
"costumes");
186 costumesField.setAccessible(
true);
187 List<?>
costumes = (List<?>) costumesField.get(
this);
191 Field indexField =
Sprite.class.getDeclaredField(
"costumeIndex");
192 indexField.setAccessible(
true);
193 indexField.setInt(
this, 0);
195 }
catch (NoSuchFieldException | IllegalAccessException e) {
196 throw new RuntimeException(
"Failed to reset costumes via reflection", e);
void turnRight(double deg)
void setScaleY(double sy)
void whenScaleChanged(java.util.function.BiConsumer< Double, Double > action)
void setScaleX(double sx)
Object getVariable(String name)
void turnLeft(double deg)
static Stage getInstance()
void animateTurn(int dir, double time, String curveType)
void animateTurn(int dir, double time)
boolean isDirEqualTo(int dir)
double applyCurve(double t, String type)