Elementary stuff I suppose
in
Programming Questions
•
2 years ago
I have this wonderful job teaching this kid math. We do it with processing and he made some code today. It doesnt work I cant figure out why.
I kno that there are better ways of doing it, but he's 11 and this way is understandable for him.
All help warmly welcome.
- float fk1=random(600);
- float fk1s=fk1+20;
- float fk2=random(600);
- float fk2s=fk2+20;
- float fk3=random(600);
- float fk3s=fk3+20;
- float fk4=random(600);
- float fk4s=fk4+20;
- float fk5=random(600);
- float fk5s=fk5+20;
- void setup() {
- size(600, 600);
- }
- void draw() {
- rect(fk1,fk1,20,20);
- println(fk1);
- println(fk2);
- println(fk3);
- println(fk4);
- println(fk5);
- noLoop();
- }
- void mousePressed() {
- println(mouseX);
- println(mouseY);
- if(mouseX>fk1 && mouseX<fk1s && mouseY>fk1 && mouseY<fk1s) {
- rect(fk2,fk2,20,20);
- }
- if(mouseX>fk2 && mouseX<fk2s && mouseY>fk2 && mouseY<fk2s) {
- rect(fk3,fk3,20,20);
- }
- if(mouseX>fk3 && mouseX<fk3s && mouseY>fk3 && mouseY<fk3s) {
- rect(fk4,fk4,20,20);
- }
- if(mouseX>fk4 && mouseX<fk4s && mouseY>fk4 && mouseY<fk4s) {
- rect(fk5,fk5,20,20);
- }
- }
1