Getting all of a class into another w/o extra
in
Programming Questions
•
1 years ago
Hey, everyone...I wondering how to get more than one of a class into a main one. Here's some pseudo-code to show what I mean:
Thanks,
Blake
- jump j1,j2
- character c1;
- void setup(){
- size(200,200);
- c1=new character(100,100,j1);
- j1=new jump(200,100);
- j2=new jump(400,100);
- }
- void draw(){
- j1.display();
- j2.display();
- c1.display(); c1.move(); c1.jump();
- class character{
- int x,y;
- jump j1;
- character(int ix,int iy,jump ij1){
- x=ix;
- y=iy;
- j1=ij1;
- }
- void display(){
- rect(x,y,20,20);
- }
- void move(){
- //code for moving
- }
- void jump(){
- //code for jumping over j1.
- }
- class jump{
- int x,y;
- jump(int ix, int iy){
- x=ix;
- y=iy;
- }
- void display(){
- rect(x,y,50,20);
- }
Thanks,
Blake
1