Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i wrote a code that prints the blue rectangle in the following image below in pygame using python. I need the blue square to loop

i wrote a code that prints the blue rectangle in the following image below in pygame using python. I need the blue square to loop throughout the whole screen like the second image. Im stuck and cant seem to figure it out.

image text in transcribed-----image text in transcribed

MY CODE SO FAR.

import pygame,sys

#initializes video pygame.init()

#sets the screen size screen=pygame.display.set_mode((400,400))

while(1): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit()

#draws a rectangle on screen with color (r,g,b) at loc(x,y) of width w, height h

#this statement draws a blue rectangle at (10,10) width=30, height=20 pygame.draw.rect(screen,(0,0,255),pygame.Rect(10,10,10,6))

pygame.display.flip()

pygame window

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

Students also viewed these Databases questions