Hi everyone im a beginner and im not sure how to approach this question. The hint part of the question is confusing me and everything ive tried hasn’t given me a dotted line. Does it want us to draw two different lines or change the color of the same line upon keyPressed? It seems like something simple that I’m overcomplicating tbh but I can’t tell what.
Either way how would you go about solving this question? You can only use if statements and booleans to solve it, not loops.
But that would just change the stroke color to black and draw a black line instead of a line with alternating color.
with the if statement set up that way^ and the line command like
line(mouseX, mouseY, pmouseX, pmouseY);
a solid line is drawn that changes colour and becomes dotted on keyPressed, it doesn’t draw small sectional lines of black and white like the question wants.
im sorry if I didn’t apply your input correctly but that’s what I got from it.
I think the task presumes that your background color is white.
When you then draw a line that alternates between white and black, it’s a dashed line.
That is also stated clearly in the assignment.
Anyway, post your entire, runable code and let’s work from there.
it alternates between white and black every frame which is rather fast. Did you try it? The idea is that during drawing the color changes so fast, that the lines becomes dashed.
I didn’t add the keyPressed command into the code here cz im not sure if I should use the boolean variable keyPressed or the function keyPressed, neither works with this attempt tho lol :’)