Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import pygame, sys from pygame.locals import QUIT def draw_rectangle(surface, rectangle): pygame.draw.rect(surface, (0, 255, 0), rectangle) def main(): pygame.init() #Intalise DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Rectangles and

import pygame, sys from pygame.locals import QUIT

def draw_rectangle(surface, rectangle): pygame.draw.rect(surface, (0, 255, 0), rectangle)

def main(): pygame.init()

#Intalise DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Rectangles and Squares')

# Game Clock game_clock = pygame.time.Clock()

#Variables x_position = 100

#Game Loop running = True while running: #Update Section

#Update delta_time delta_time = game_clock.tick(60) / 100

#Handle events for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()

#Move the object right x_position += 10 * delta_time

#Draw Section DISPLAYSURF.fill((128, 128, 128))

draw_rectangle(DISPLAYSURF, pygame.Rect(x_position, 0, 50, 50))

pygame.display.flip()

if __name__ == "__main__": main()

Update the code so the square descends down the screen without moving across it!

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

Visualizing Health And Healthcare Data Creating Clear And Compelling Visualizations To See How Youre Doing

Authors: Katherine Rowell ,Lindsay Betzendahl ,Cambria Brown

1st Edition

1119680883, 978-1119680888

More Books

Students also viewed these Databases questions