processing_sim/logs.pde
2023-12-11 00:03:26 +01:00

56 lines
1.2 KiB
Plaintext

class Log {
float x, y, logwidth, logheight;
boolean sawed = false;
boolean is_tree = false;
color logcolor;
color strokecolor = logcolor;
Log (float xpos, float ypos, float logw, float logh, boolean ist) {
x = xpos;
y = ypos;
logwidth = logw;
logheight = logh;
is_tree = ist;
}
void drawLog(int logtext) {
if (sawed) {
logcolor = color(128, 88, 60);
} else {
logcolor = color(133, 79, 51);
}
stroke(strokecolor); // Set stroke color for the log
strokeWeight(1); // Set stroke weight for the log
fill(logcolor); // Set fill color for the log
// rectMode(CENTER);
rect(x, y, logwidth, logheight); // Draw the log as a rectangle
text(logtext, x, y);
// rectMode(CORNER);
strokeWeight(1);
stroke(0);
if(is_tree) {
color bushes = color(107, 117, 48);
fill(bushes);
ellipse(x+logwidth/2, y+5, 170*0.3, 160*0.3);
}
}
}
class Tree extends Log {
Tree (float x, float y, float logw, float logh, boolean hasC) {
super(x, y, logw, logh, hasC);
}
void draw() {
color treecolor = color(133, 79, 51);
// rectMode(CENTER);
drawLog(1);
}
}