59 lines
1.3 KiB
Plaintext
59 lines
1.3 KiB
Plaintext
// Tarek
|
|
class Log {
|
|
float x, y, logwidth, logheight;
|
|
boolean sawed = false;
|
|
boolean is_tree = false;
|
|
boolean is_wall = false;
|
|
float a = 0;
|
|
boolean render_log = true;
|
|
|
|
color logcolor;
|
|
color strokecolor = logcolor;
|
|
|
|
Log (float xpos, float ypos, float logw, float logh, boolean ist, boolean isw) {
|
|
x = xpos;
|
|
y = ypos;
|
|
logwidth = logw;
|
|
logheight = logh;
|
|
is_tree = ist;
|
|
is_wall = isw;
|
|
//draw();
|
|
}
|
|
|
|
void drawLog(int logtext) {
|
|
if (sawed) {
|
|
logcolor = color(128, 88, 60);
|
|
if (a > -90) a = a - 1;
|
|
if (a == -90) render_log = false;
|
|
} else if (is_wall) {
|
|
logcolor = color(0, 0, 0);
|
|
} else {
|
|
logcolor = color(133, 79, 51);
|
|
}
|
|
|
|
if (render_log) {
|
|
pushMatrix();
|
|
translate(x, y);
|
|
rotate(radians(a));
|
|
stroke(strokecolor); // Set stroke color for the log
|
|
strokeWeight(1); // Set stroke weight for the log
|
|
fill(logcolor); // Set fill color for the log
|
|
rect(0, 0, logwidth, -logheight); // Draw the log as a rectangle
|
|
// text(logtext, x, y);
|
|
strokeWeight(1);
|
|
stroke(0);
|
|
|
|
// Bush
|
|
if(is_tree) {
|
|
color bushes = color(107, 117, 48);
|
|
fill(bushes);
|
|
ellipse(0 + logwidth/2, 0 - logheight, 170*0.3, 160*0.3);
|
|
}
|
|
|
|
popMatrix();
|
|
}
|
|
|
|
|
|
}
|
|
}
|