Learn the "father and child Programming Journey" Chapter 16, with the example of the book to learn, learned to draw a circle, I found a way to draw the line, so you can draw the Japanese flag on screen:
Hand animation is not good to see, you can also do not manually draw, directly draw lines:
The code is as follows:
1 Import Pygame,sys2 fromPygame.locals Import *3 Print Pygame.ver4 Pygame.init ()5Screen = Pygame.display.set_mode ([640,480])6Color= ( $,156, -) 7points=[] 8Screen.fill ([255,255,255])9Pygame.draw.circle (screen,[255,0,0],[ $, $], -,0)TenPygame.draw.line (Screen,color, ( -, -),( -, -),1) OnePygame.draw.line (Screen,color, ( -, -),( -, -),1) APygame.draw.line (Screen,color, ( -, -),( -, -),1) -Pygame.draw.line (Screen,color, ( -, -),( -, -),1) - Pygame.display.flip () therunning =True - whileRunning: - for Event inchPygame.Event.Get(): - if Event. Type = =Pygame. QUIT: +running =False -##if Event. type==Mousebuttondown: +# # Points.append (Event. Pos) A##ifLen (points) >1: at# # Pygame.draw.lines (Screen,color, False, points,5) - # # pygame.display.update () -Pygame.quit ()
The first drawing experience in Python