Python Forum
drawing moving circle on line with python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: drawing moving circle on line with python (/thread-36494.html)



drawing moving circle on line with python - barrai - Feb-25-2022

hi how are u
i can draw circle and draw line but i cant how to draw moving circle on line .please help me.


RE: drawing moving circle on line with python - BashBedlam - Feb-25-2022

With pygame it would look something like this:
import pygame

SCREEN = pygame.display.set_mode ((600, 400))
circle_x = 50
step = .4

while True :
	for event in pygame.event.get () :
		if event.type == pygame.QUIT :
			quit ()

	SCREEN.fill ((0, 0, 0))
	pygame.draw.rect (SCREEN, (0, 0, 250), (50, 200, 500, 10))
	circle_x += step
	if circle_x > 500 or circle_x < 50 :
		step = -step 
	pygame.draw.ellipse (SCREEN, (255, 0, 0), (circle_x, 150, 50, 50))
	pygame.display.update ()
Or are you using tkinter or turtle or what ?