Present present;
Tree tree;
boolean appear;
void setup () {
size (1000, 900);
background (0);
textAlign(CENTER);
present = new Present ();
tree = new Tree ();
}
void draw () {
drawAdvent ();
drawObjects();
}
void drawAdvent () {
float x = 15;
float y = 15;
for (int j = 50; j < height; j += 210) {
for (int i = 20; i < width; i += 165) {
fill(20, 50, 150);
rect(x + i, y + j, 100, 150);
for (int t = 1; t<25; t++) {
fill(70, 220, 240);
textSize(50);
text(t, x+i+50, y+j +85);
}
}
}
}
void drawObjects () {
if (mousePressed) {
appear = true;
} else {
appear = false;
}
if (appear == true) {
present.draw();
}
}
class Present extends christmasObject {
void draw () {
translate (b, h);
drawpresent();
}
void drawpresent() {
scale(0.1);
beginShape();
fill(30, 70, 20);
rect( 150, 400, 500, 400);
rect ( 125, 350, 550, 100);
fill(250, 10, 10);
triangle(400, 340, 300, 200, 225, 300);
triangle(400, 340, 500, 200, 575, 300);
ellipse (400, 340, 70, 50);
rect ( 340, 350, 125, 450);
endShape();
}
}
class Tree extends christmasObject {
void draw () {
drawtree();
}
void drawtree () {
translate(b, h);
scale(0.2);
beginShape();
//stem
rectMode(CENTER);
fill(90, 50, 20);
rect(500, 850, 80, 120);
//Bottom
fill(0, 50, 0);
triangle(500, 500, 200, 800, 800, 800);
//Middle
fill(0, 60, 0);
triangle(500, 300, 300, 600, 700, 600);
//Top
fill(0, 70, 0);
triangle(500, 200, 400, 400, 600, 400);
endShape();
}
}
class christmasObject {
float b;;
float h;
void setup () {
b = mouseX;
h = mouseY;
}
void draw () {
}
}
This is my Code so far but I am so lost right now. Its supposed to be a little Advent Calendar for fun.
But the present Always appears at the same position and I don’t really understand how I should add what you suggested
Also lets not talk about my numbers on the doors I still gotta figure that out too haha