24 Jun PMCA Sunday 14:00 Python Homework 21.06.20.
Posted at 15:06h in Uncategorized 0 Comments
Using pygame try to draw the pattern as below:
In the above picture, the height is 40px and width is 40px but you can choose any height and width you deem possible.
Below is the code to create a simple pygame window and to draw a simple rectangle:
import pygame, sys, random pygame.init() screen_height = 600 screen_width = 600 screen=pygame.display.set_mode([screen_width, screen_height]) screen.fill([150,222,232]) # below is how you draw a simple rectange # note that the position of the rect is 20px and 30px # the width and height of the rect is 100px and 200px pygame.draw.rect(screen, [100,150,200], [20,30,100, 200]) # bottom right corner pygame.display.flip() while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit()
Sorry, the comment form is closed at this time.