TORONTO KIDS COMPUTER CLUB | PMCA Sunday 14:00 Python Homework 21.06.20.
19649
post-template-default,single,single-post,postid-19649,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

PMCA Sunday 14:00 Python Homework 21.06.20.

24 Jun PMCA Sunday 14:00 Python Homework 21.06.20.

Question 1:

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()
No Comments

Sorry, the comment form is closed at this time.