Repository navigation
Expand file tree
/
Copy pathLayerMovement.java
More file actions
204 lines (179 loc) · 5.88 KB
/
Copy pathLayerMovement.java
File metadata and controls
204 lines (179 loc) · 5.88 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import controlP5.Group;
import controlP5.Tab;
public abstract class LayerMovement extends LayerColor {
public FloatParameter angle = new FloatParameter(this,0f,0f,2f*(float)Math.PI,FloatParameter.WRAP,"angle");
public FloatParameter rotate = new FloatParameter(this,0f,0f,2f*(float)Math.PI,FloatParameter.WRAP,"rotate");
public FloatParameter zoom = new FloatParameter(this,4f,1f,50f,"zoom");
public FloatParameter scrollX = new FloatParameter(this,0f,0f,this.width,FloatParameter.WRAP,"scrollX");
public FloatParameter scrollY = new FloatParameter(this,0f,0f,this.height,FloatParameter.WRAP,"scrollY");
public ListParameter scrollMode = new ListParameter(this,1,LayerNineBlockPattern.scrollModes,LayerNineBlockPattern.scrollModeNames,"scrollMode");
public FloatParameter size = new FloatParameter(this,1f,0f,4f,"size");
//used only for rendering :
//public int foregroundR,foregroundG,foregroundB,backgroundR,backgroundG,backgroundB;
public static String[] scrollModeNames={"0","1","10","50"};
public static int[] scrollModes={0,1,10,50};
public int width,height;
protected LayerMovement(Application parent){
super(parent);
this.width=Config.PATTERN_WIDTH;
this.height=Config.PATTERN_WIDTH;
angle.tcIncPerSec=0;
rotate.tcIncPerSec=0;
zoom.bumpChange=0.02f;
zoom.tcIncPerSec=0;
scrollX.scChange=0.1f;
scrollX.tcIncPerSec=0;
scrollY.scChange=0.1f;
scrollY.tcIncPerSec=0;
scrollX.bumpChange=0.1f;
scrollY.bumpChange=0.1f;
}
public int totalWidth(){return 4*width;}
public int totalHeight(){return 2*height;}
public int buildUI(GUIController controller, int x, int y, Tab tab, Group group) {
String layerType = this.getType();
y+=super.buildUI(controller,x,y,tab,group);
//Gradient
int h=controller.h;
int hMargin = controller.hMargin;
//Moves
controller.addControlNamesMoves(layerType,"names",x,y,tab,group);
y+=h+hMargin;
controller.addControlFloatMoveParameter(layerType,"scrollX",-500,500, x, y, tab,group);
y+=h+hMargin;
controller.addControlFloatMoveParameter(layerType,"scrollY",-500,500, x, y, tab,group);
y+=h+hMargin*2;
controller.addControlFloatMoveParameter(layerType,"angle",-10,10, x, y, tab,group);
y+=h+hMargin*2;
controller.addControlFloatMoveParameter(layerType,"rotate",2,2, x, y, tab,group);
y+=h+hMargin*2;
controller.addControlFloatMoveParameter(layerType,"zoom",-3,3, x, y, tab,group);
y+=h+hMargin;
y+=h+hMargin;
controller.addControlFloatParameter(layerType,"size",0,4, x, y, tab,group);
y+=h+hMargin*2;
controller.addControlFloatMoveParameter(layerType,"number",0,50, x, y, tab,group);
y+=h+hMargin;
y+=h+hMargin;
return(y);
}
public void keyEvent(int key, int keyCode, char ch, boolean a, boolean c, boolean s,boolean win,boolean apl,long[] lastPressedTime) {
super.keyEvent(key,keyCode,ch,a,c,s,win,apl,lastPressedTime);
switch(keyCode){
case 37/*'<-'*/:
if(s){
scrollX.tc=!scrollX.tc;
}
break;
case 39/*'->'*/:
if(!s&&!c&&!a){
//aplayers[apcurrentLayer].scrollX.tcIncPerSec+=parent.layers[parent.currentLayer].scrollY.tcIncPerSec*0.25+0.05;
//parent.layers[parent.currentLayer].scrollX.tc=true;
if(parent.globalController!=null)parent.globalController.incSpeed();
}
if(s){
scrollX.tc=!scrollY.tc;
}
break;
case 38/*'up'*/:
if(!s&&!c&&!a){
//parent.layers[parent.currentLayer].scrollY.tcIncPerSec-=parent.layers[parent.currentLayer].scrollY.tcIncPerSec*0.25+0.05;
//parent.layers[parent.currentLayer].scrollY.tc=true;
if(parent.globalController!=null)parent.globalController.incBump();
}
if(s){
scrollY.tc=!scrollY.tc;
}
break;
case 40/*'down'*/:
if(!s&&!c&&!a){
//parent.layers[parent.currentLayer].scrollY.tcIncPerSec+=parent.layers[parent.currentLayer].scrollY.tcIncPerSec*0.25+0.05;
//parent.layers[parent.currentLayer].scrollY.tc=true;
if(parent.globalController!=null)parent.globalController.decBump();
}
if(s){
scrollY.tc=!scrollY.tc;
}
break;
case 69/*'e'*/:
if(!s&&!c&&!a){
scrollX.tc=!scrollX.tc;
scrollY.tc=!scrollY.tc;
}
if(s&&!c&&!a){
scrollX.tc=false;
scrollY.tc=false;
}
if(!s&&c&&!a){
scrollX.tcIncPerSec+=scrollX.tcIncPerSec*0.25+0.01;
scrollY.tcIncPerSec+=scrollY.tcIncPerSec*0.25+0.01;
}
if(!s&&!c&&a){
scrollX.tcIncPerSec-=scrollX.tcIncPerSec*0.25+0.01;
scrollY.tcIncPerSec-=scrollY.tcIncPerSec*0.25+0.01;
}
if(!s&&c&&a){
scrollX.sc=!scrollX.sc;
scrollY.sc=!scrollY.sc;
}
break;
case 61/*'=' movment sound control*/:
case 47/*MAC '=' movment sound control*/:
if(!s&&!c&&!a){
scrollX.sc=true;
scrollY.sc=true;
angle.sc=true;
zoom.sc=true;
System.out.println("Move Sound control ON for layer "+(parent.currentLayer+1));
}
if(s&&!c&&!a){
scrollX.sc=false;
scrollY.sc=false;
angle.sc=false;
zoom.sc=false;
System.out.println("Move Sound control OFF for layer "+(parent.currentLayer+1));
}
break;
case 82/*'R.otate'*/:
if(!s&&!c&&!a){
angle.tc=!angle.tc;
}
if(s&&!c&&!a){
angle.tc=false;
}
if(!s&&c&&!a){
angle.tc=true;
angle.tcIncPerSec-=angle.tcIncPerSec*0.25+0.001;
}
if(!s&&!c&&a){
angle.tc=true;
angle.tcIncPerSec+=angle.tcIncPerSec*0.25+0.001;
}
if(!s&&c&&a){
angle.sc=!angle.sc;
}
break;
case 90/*'Z.oom'*/:
if(!s&&!c&&!a){
zoom.tc=!zoom.tc;
}
if(s&&!c&&!a){
zoom.tc=false;
}
if(!s&&c&&!a){
zoom.tc=true;
if(zoom.tcIncPerSec>=0)zoom.tcIncPerSec-=zoom.tcIncPerSec*0.25+0.001;
if(zoom.tcIncPerSec<0)zoom.tcIncPerSec+=zoom.tcIncPerSec*0.25+0.001;
}
if(!s&&!c&&a){
zoom.tc=true;
if(zoom.tcIncPerSec>=0)zoom.tcIncPerSec+=zoom.tcIncPerSec*0.25+0.001;
if(zoom.tcIncPerSec<0)zoom.tcIncPerSec-=zoom.tcIncPerSec*0.25+0.001;
}
if(!s&&c&&a){
zoom.sc=!zoom.sc;
}
break;
}
}
}