Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

http://programarcadegames.com/index.php?chapter=lab_classes_and_graphics&lang=en Pygame- I am not sure how to start this.. I have this so far--- import pygame # Define some colors BLACK = (0, 0,

http://programarcadegames.com/index.php?chapter=lab_classes_and_graphics&lang=en

Pygame- I am not sure how to start this.. I have this so far---

import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0)

class Rectangle(): def_init_(self): self.x=0 self.y=0

self.change_x=0 self.change_y=0

self.size=10

self.color=[0,255,0]

def move(self) self.x+=self.change_x self.y+=self.change_y

def draw(self,screen): pygame.draw.rect(screen, GREEN, (0,300,400,100), 0) pygame.init() # Set the width and height of the screen [width, height] size = (700, 500) screen = pygame.display.set_mode(size) pygame.display.set_caption("My Game") # Loop until the user clicks the close button. done = False # Used to manage how fast the screen updates clock = pygame.time.Clock() # -------- Main Program Loop ----------- while not done: # --- Main event loop for event in pygame.event.get(): if event.type == pygame.QUIT: done = True # --- Game logic should go here # --- Screen-clearing code goes here # Here, we clear the screen to white. Don't put other drawing commands # above this, or they will be erased with this command. # If you want a background image, replace this clear with blit'ing the # background image. screen.fill(WHITE) # --- Drawing code should go here # --- Go ahead and update the screen with what we've drawn. pygame.display.flip() # --- Limit to 60 frames per second clock.tick(60) # Close the window and quit. pygame.quit()

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

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions