0
\$\begingroup\$

I'm using this code to make a square that orbits a circle . When I use it however the rect(); is quite far away from the circumference of the circle, I would like to make it closer. All variables are floats. YPos and XPos are the x and y of the circles origin.

charx = XPos[0] + cos(angle)*Sizes[0];
chary = YPos[0] + sin(angle)*Sizes[0];
angle += 0.1;
fill(255,255,255);
rect(charx, chary, 10,10);} 

Any idea what I should change? This is probably something very simple, but I'm very new to Java.

\$\endgroup\$
  • \$\begingroup\$ define: is quite far away from the circumference of the circle, i would like to make it closer. more exactly. \$\endgroup\$ – MickLH Jul 2 '16 at 19:09
1
\$\begingroup\$

Two ideas: 1) Make Sizes[0] smaller. 2) Try rect(charx-5, chary-5, 10, 10);

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.