Difference between revisions of "Drawing shapes"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "==Rectangle== You can declare some variables to use for your rectangle, they require the x coordinate, the y coordinate, the width and the height: <syntaxhighlight lang=pytho...")
(No difference)

Revision as of 21:22, 21 February 2018

Rectangle

You can declare some variables to use for your rectangle, they require the x coordinate, the y coordinate, the width and the height:

LEFT = 100
TOP = 100
LENGTH = 20
WIDTH = 20
RECTCOORD = [LEFT, TOP, LENGTH, WIDTH]
rect1 = pygame.Rect(RECTCOORD)

This is the same as writing:

rect1 = pygame.Rect([100,100,20,20])

Before we can draw your rectangle to the screen we will need to define a colour to use:

RED = 255
YELLOW = 230
BLUE = 200
COLOR = (RED, YELLOW, BLUE)

Again this is the same as writing just:

COLOR = (255, 230, 200)