What I want to do is be able to constrict an objec to within a circle. Doing it inside a sqaure is easy, but I'm finding the Circle to be a bit of a challenge :-)
If anyone can help, I would greatly appreciate it!
Here is some sample code to demo what I am looking for.
If anyone can help, I would greatly appreciate it!
Here is some sample code to demo what I am looking for.
Graphics 800, 600 Local cX# = 400 Local cY# = 300 Local cW# = 100 Local cH# = 100 Local x# Local y# Local r% Local pX# = cX# Local pY# = cY# While Not KeyHit(KEY_ESCAPE) Cls() DrawText "I want the WHITE cricle to be constricted to the inside of the Green Circle", 0,0 DrawText "It should be able to travel smoothly around the inside of the Green Circle", 0,18 SetColor(0,255,0) For r% = 0 To 360 x# = cX# + (sin(r%) * cW) y# = cY# + (cos(r%) * cH) Plot x#, y# Next SetColor(255,255,255) DrawOval pX, pY, 5,5 If KeyDown(KEY_LEFT) Then pX :- 1 EndIf If KeyDown(KEY_RIGHT) Then pX :+ 1 EndIf If KeyDown(KEY_UP) Then pY :- 1 EndIf If KeyDown(KEY_DOWN) Then pY :+ 1 EndIf ' How do I do this... ' IF pX on the edge of the Circle pX = the Edge of the circle ' IF pY on the edge of the Circle pY = the Edge of the circle Flip() Wend