Having Classes Do More Than One Composition?
in
Programming Questions
•
1 year ago
Right now I have arrays for a class of jumps and blocks on a map, and a character to jump over them. If have the constructors for them in setup, and the function in draw, like so:
- void setup() {
- m1=new map1();
- p1=new pit(800);
- for(int i=0; i<b1.length; i++){
- b1[i]=new block(bxs[i],300,n1);
- for(int j=0; j<j1.length; j++){
- j1[j]=new jump(jxs[j]);
- n1=new nicolai(j1[j],b1[i],p1);
- }
- }
- }
- void draw{
- background(0);
- if(!keys[1] && !keys[2]){
- xvel=3;
- xacc=0;
- }
- if(keys[1] || keys[2]){
- xacc=.1;
- }
- if(xvel>=10){
- xacc=0;
- }
- m1.display();
- p1.display();
- for(int i=0; i<j1.length; i++){
- j1[i].display();
- }
- n1.block();
- n1.fall();
- n1.jump();
- n1.update();
- n1.display();
- n1.restart();
- for(int i=0; i<b1.length; i++){
- b1[i].display();
- b1[i].coin();
- }
- }
1