Well, I started by filling in some details. We can have placeholder code to draw each of these things for a start. That means that each of these things is going to need a size and position - just so we can draw them! Then I added constructors for all the objects, and threw in some code to generate a few example objects:
class Block {
float x,y,w,h;
Block(float ix, float iy){
x = ix;
y = iy;
w = 20;
h = 20;
}
void draw() {
fill(0,0,200);
stroke(0);
rect(x,y,w,h);
}
}
class Foe {
float x,y,w,h;
Foe(){
x = width/2;
y = width/2;
w = 20;
h = 20;
}
void draw() {
fill(0,200,0);
stroke(0);
ellipse(x+10,y+10,w,h);
}
}
class Mario {
float x,y,w,h;
Mario(float ix, float iy){
x = ix;
y = iy;
w = 20;
h = 20;
}
void draw() {
fill(200,0,0);
stroke(0);
ellipse(x+10,y+10,w,h);
}
}
ArrayList<Block> blocks = new ArrayList();
ArrayList<Foe> foes = new ArrayList();
ArrayList<Mario> marios = new ArrayList();
void setup() {
size(600, 600);
for( int i = 0; i < 30; i++){
blocks.add( new Block( 20*i, 580 ) );
if( i > 10 && i < 15 ){
blocks.add( new Block( 20*i, 480 ) );
}
}
foes.add( new Foe() );
marios.add( new Mario( 20, 560) );
}
void draw() {
background(255);
for (int i = 0; i < blocks.size(); blocks.get(i++).draw());
for (int i = 0; i < foes.size(); foes.get(i++).draw());
for (int i = 0; i < marios.size(); marios.get(i++).draw());
}
Now it is a scene, and you can start adding logic that deals with each of the types of things.
I’d start by making the enemies fall down if there are no blocks under them… Once that works, can you apply the same logic to Mario and Blocks?