Python Forum
Program to move a dot towards a circle center
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program to move a dot towards a circle center
#10
(Dec-01-2021, 05:45 PM)BashBedlam Wrote: Okay... In this version, when the dot reaches the middle, we usebreakto fall through the firstwhileloop. After that we print to the screen and wait for the user to close the window. That is where you would put any extra code. Does that help?
from pygame import display, QUIT, event, draw, time, font, init
SCREEN = display.set_mode ((500, 500))
init () 
dot_x_position = 30
while True :
	for user_input_event in event.get () :
		if user_input_event.type ==  QUIT :
			exit ()
	SCREEN.fill ((0, 0, 0))
	draw.circle (SCREEN, (200, 0, 0), (249, 249), 220, 4)
	draw.circle (SCREEN, (0, 0, 200), (dot_x_position, 249), 20)
	if dot_x_position < 249 :
		dot_x_position += 1
	else : break
	time.Clock ().tick (100)
	display.update ()

text = font.SysFont ('ariel', 42).render ('Close window to contunue.',
		1, (255, 255, 255), (1, 1, 1))
SCREEN.blit (text, (70, 50))
display.update ()
while True :
	for user_input_event in event.get () :
		if user_input_event.type ==  QUIT :
			exit ()

Many thanks! Now I got it running. Your help is very much appreciated!
Reply


Messages In This Thread
RE: Program to move a dot towards a circle center - by plumberpy - Dec-03-2021, 07:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,455 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  (OpenCV) Help to improve code for object detection and finding center of it saoko 0 1,221 May-14-2022, 05:34 PM
Last Post: saoko
  [S0LVED] [Tkinter] Center dialog? Winfried 8 4,301 Mar-01-2022, 07:17 PM
Last Post: Winfried
  drawing moving circle on line with python barrai 1 3,185 Feb-25-2022, 03:33 PM
Last Post: BashBedlam
  Draw circle from GPS coords, and get GPX file? Winfried 0 2,207 Mar-29-2021, 07:19 PM
Last Post: Winfried
  Center align Kristenl2784 1 1,990 Aug-03-2020, 04:25 PM
Last Post: bowlofred
  Pyplot and circle Reldaing 0 1,509 Apr-01-2020, 10:44 AM
Last Post: Reldaing
  calculate circle sector Bloody_geek 2 2,326 Sep-11-2019, 08:54 PM
Last Post: Larz60+
  How can I move in an external program via Python? Pythoner 0 2,291 Dec-29-2018, 12:43 PM
Last Post: Pythoner
  Help with circle and motion wigigx 4 4,096 Aug-29-2017, 09:49 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020