Search Header Logo
PyGame: Primitives

PyGame: Primitives

Assessment

Presentation

Computers

12th Grade

Practice Problem

Medium

Created by

Аңсар Әкім

Used 41+ times

FREE Resource

7 Slides • 10 Questions

1

Graphic primitives.

Assessment Criteria:

Remember (Knowledge):

  • Identify the Pygame functions for drawing basic graphic primitives.

  • List the parameters required to draw a rectangle or circle.

Understand (Comprehension):

  • Explain the purpose and use of Pygame's drawing functions.

  • Describe how coordinates and dimensions are used to position and size graphic primitives on the window.

Apply (Application):

  • Demonstrate the ability to draw rectangles and circles on the Pygame window.

  • Adjust the parameters to create variations in size, position, and color.

Analyze (Analysis):

  • Analyze the impact of different parameters on the appearance of graphic primitives.

  • Identify and troubleshoot common errors in drawing graphic primitives.

2

Word Cloud

Question image

Pygame library

3

Multiple Choice

What function is used to initialize Pygame?

2

pygame.start()

3

pygame.initialize()

4

pygame.init()

4

Multiple Choice

How do you create a Pygame window of dimensions 800x600 pixels?

1

window = pygame.create_window(800, 600)

2

window = pygame.Window(800, 600)

3

window = pygame.display.create_window(800, 600)

4

window = pygame.display.set_mode((800, 600))

5

Multiple Choice

What is the purpose of the Pygame main loop?

1

To initialize the game

2

To handle user events

3

To draw graphics on the screen

4

All of the above

6

Multiple Choice

How do you handle the quit event in the Pygame main loop?

1

if event.type == pygame.QUIT: pygame.end()

2

if event.type == pygame.EXIT: pygame.quit()

3

if event == pygame.QUIT: sys.exit()

4

d. if event.type == QUIT: pygame.quit()

7

Graphic primitives.

Assessment Criteria:

Remember (Knowledge):

  • Identify the Pygame functions for drawing basic graphic primitives.

  • List the parameters required to draw a rectangle or circle.

Understand (Comprehension):

  • Explain the purpose and use of Pygame's drawing functions.

  • Describe how coordinates and dimensions are used to position and size graphic primitives on the window.

Apply (Application):

  • Demonstrate the ability to draw rectangles and circles on the Pygame window.

  • Adjust the parameters to create variations in size, position, and color.

Analyze (Analysis):

  • Analyze the impact of different parameters on the appearance of graphic primitives.

  • Identify and troubleshoot common errors in drawing graphic primitives.

8

# Draw a red rectangle 

rect_color = (255, 0, 0) 

rect_dimensions = pygame.Rect(50, 50, 100, 75) 

pygame.draw.rect(screen, rect_color, rect_dimensions) 


Rectangle https://trinket.io/pygame/b16a964027
Circle
https://trinket.io/pygame/c770ca8d10

9

Drawing a Polygon Online compiler Trinket


# Define the points for the polygon (vertices)
 

polygon_points = [(200, 100), (300, 50), (400, 100), (300, 200)] 

  

# Set colors 

BLACK = (0, 0, 0) 

GREEN = (0, 255, 0) 


# Draw the polygon 
pygame.draw.polygon(screen, GREEN, polygon_points)
 

https://trinket.io/pygame/6a602a4a52

10

Multiple Choice

How do you draw a rectangle in Pygame?

1

pygame.draw.rect(surface, color, dimensions)

2

pygame.draw.rectangle(surface, color, dimensions)

3

pygame.draw.square(surface, color, dimensions)

4

pygame.draw.rect(surface, dimensions, color)

11

Multiple Choice

What Pygame function is used to draw a polygon?

1

pygame.draw.polygon(surface, color, vertices)

2

pygame.draw.poly(surface, color, vertices)

3

pygame.draw.draw_polygon(surface, color, vertices)

4

pygame.draw.shape(surface, color, vertices)

12

Draw

Let's create some simple drawings.

Be creative, use different colours and graphical primitives: rectangle, line, polygon and circle.

13

It's time to recreate your drawing within Pygame

Create similar drawing as in the previous task programmatically

14

Graphic primitives.

  1. Use the random library to change the colours and parameters of the primitives

  2. Add movement within the main loop.

    Example: https://trinket.io/pygame/0048ec3598

15

Poll

1-2

3-5

6-7

8-9

16

Graphic primitives.

Assessment Criteria:

Remember (Knowledge):

  • Identify the Pygame functions for drawing basic graphic primitives.

  • List the parameters required to draw a rectangle or circle.

Understand (Comprehension):

  • Explain the purpose and use of Pygame's drawing functions.

  • Describe how coordinates and dimensions are used to position and size graphic primitives on the window.

Apply (Application):

  • Demonstrate the ability to draw rectangles and circles on the Pygame window.

  • Adjust the parameters to create variations in size, position, and color.

Analyze (Analysis):

  • Analyze the impact of different parameters on the appearance of graphic primitives.

  • Identify and troubleshoot common errors in drawing graphic primitives.

17

Open Ended

Feedback

Graphic primitives.

Assessment Criteria:

Remember (Knowledge):

  • Identify the Pygame functions for drawing basic graphic primitives.

  • List the parameters required to draw a rectangle or circle.

Understand (Comprehension):

  • Explain the purpose and use of Pygame's drawing functions.

  • Describe how coordinates and dimensions are used to position and size graphic primitives on the window.

Apply (Application):

  • Demonstrate the ability to draw rectangles and circles on the Pygame window.

  • Adjust the parameters to create variations in size, position, and color.

Analyze (Analysis):

  • Analyze the impact of different parameters on the appearance of graphic primitives.

  • Identify and troubleshoot common errors in drawing graphic primitives.

Show answer

Auto Play

Slide 1 / 17

SLIDE