-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.pde
130 lines (121 loc) · 6.28 KB
/
Settings.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;
static class Settings {
static final String styleVersion = "1.3.0";
// Jump parameters
boolean showTrail = false; // Show the trail or not.
boolean allowAerialJump = true; // Allow aerial jump or not.
boolean allowAerialWalk = true; // Allow aerial walk or not.
boolean allowAerialTurn = false; // Allow aerial turn or not. (Only affects the visual appearance)
boolean stopAndFall = false; // The horizontal motion is halted when the jumper goes off the foothold.
boolean allowWallJump = false; // Allow wall jump or not.
boolean allowWallSlide = false; // Allow wall slide or not.
float maxVx = 8; // Maximum horizontal velocity of the jumper.
float maxVy = 30; // Maximum vertical velocity of the jumper. Limits only the falling motion.
float jumpVelocity = 13; // Initial vertical velocity of a jump motion.
float jumpVelocityBonus = 0;// The faster run gives an initial jump velocity bonus that allows a higher jump.
float jumpAnticipationFrames = 1; // Duration of the anticipation of jump motion in frames.
float vxAdjustmentAtTakeoff = 0.0; // Horizontal velocity adjustment at the takeoff.
float maxPropellingFrames = 0; // Maximum duration of propelled jump.
float gravity = 0.5; // gravity when rising.
float gravityFalling = 1.2; // gravity when falling.
float verticalSpeedSustainLevel = 1.0; // Sustain level of the vertical speed when the button released.
float axNormal = 0.2; // Horizontal acceleration in normal state.
float axBrake = 1.0; // Horizontal acceleration when braking.
float axJumping = 0.1; // Horizontal acceleration when jumping.
float collisionTolerance = 8; // Tolerance to automatically avoid blocks when jumping (in pixels).
float vCollisionTolerance = 0; // Vertical tolerance to automatically avoid block when falling (in pixels).
float wallJumpSpeedRatio = 1.0; // The velocity raito of the jumping speed of the wall jump to the maxVx.
float maxVxDashing = 12; // Maximum horizontal velocity of the jumper while dashing.
float axNormalDashing = 0.4; // Horizontal acceleration in normal state while dashing.
// Camera parameters
boolean showCameraMarker = false; // Show the center marker or not.
boolean cameraEasing_x = false; // Ease the horizon camera motion or not.
boolean cameraEasing_y = true; // Ease the vertical camera motion or not.
boolean forwardFocus = false; // Shift the focus to the front of the jumper to enable wide forward view.
boolean projectedFocus = false; // Shift the focus to the projeced position of the jumber, which means running faster moves the focal point farther.
boolean platformSnapping = false; // Halt the vertical camera motion when the jumper is jumping.
float cameraEasingNormal_x = 0.1; // Smoothness of the horizontal camera motion in normal state.
float cameraEasingNormal_y = 0.1; // Smoothness of the vertical camera motion in normal state.
float cameraEasingGrounding_y = 0.2; // Smoothness of the camera motion when the jumper grounded.
float cameraWindow_h = 0; // Height of the camera window.
float cameraWindow_w = 0; // Width of the camera window.
float focusDistance = 100; // Distance to the focal point.
float focusingSpeed = 5; // Velocity of the focal point movement.
float bgScrollRatio = 0.5; // Determine the scroll speed of the BG layer.
// Character parameters
String selectedCharacter = "3H"; // Name of the selected character.
// Misc. parameters
boolean showVelocityChart = false; // Show velocity chart in the chart canvas.
boolean showAfterimage = false; // Show afterimage instead of red dots when 'showTrail' is true.
boolean showInputStatus = false; // Show the input status.
static ArrayList<String> booleanVariables;
static ArrayList<String> floatVariables;
static ArrayList<String> listVariables = new ArrayList<String>(Arrays.asList("selectedCharacter"));
static List<String> ignoredVariables = Arrays.asList("showTrail", "showAfterimage", "showCameraMarker", "showVelocityChart", "showInputStatus");
static {
booleanVariables = new ArrayList<String>();
floatVariables = new ArrayList<String>();
Field[] allVariables = Settings.class.getDeclaredFields();
for (Field f : allVariables) {
if (!Modifier.isStatic(f.getModifiers())) {
if (f.getType() == Boolean.TYPE) {
booleanVariables.add(f.getName());
} else if (f.getType() == Float.TYPE) {
floatVariables.add(f.getName());
}
}
}
}
Settings() {
// Nothing to do at this momemnt. Just a placeholder.
}
void load(Style style) {
for (String key : style.keySet()) {
try {
Field variable = this.getClass().getDeclaredField(key);
Object value = style.get(key);
variable.set(this, value);
}
catch (ReflectiveOperationException e) {
System.err.println("Failed to get " + key + " of " + style.getName() + ".");
}
}
}
HashMap<String, Object> toHashMap() {
HashMap<String, Object> map = new HashMap<String, Object>();
for (String variableName : booleanVariables) {
if (ignoredVariables.contains(variableName)) continue;
try {
Field variable = this.getClass().getDeclaredField(variableName);
map.put(variableName, variable.getBoolean(this));
}
catch (ReflectiveOperationException e) {
System.err.println("Failed to get " + variableName + " from the current settings.");
}
}
for (String variableName : floatVariables) {
if (ignoredVariables.contains(variableName)) continue;
try {
Field variable = this.getClass().getDeclaredField(variableName);
map.put(variableName, variable.getFloat(this));
}
catch (ReflectiveOperationException e) {
System.err.println("Failed to get " + variableName + " from the current settings.");
}
}
for (String variableName : listVariables) {
if (ignoredVariables.contains(variableName)) continue;
try {
Field variable = this.getClass().getDeclaredField(variableName);
map.put(variableName, (String)variable.get(this));
}
catch (ReflectiveOperationException e) {
System.err.println("Failed to get " + variableName + " from the current settings.");
}
}
return map;
}
}