Copy_of_PyGame_Essentials_Fillout - Essential Tasks in...

This preview shows page 1 - 3 out of 4 pages.

Essential Tasks in PyGame Part 1: Drawing Images Shapes and Text Define a Color Set background color of game Display an image Resize an image Define a rectangle Draw a rectangle using rect Draw a rectangle freestyle Draw a circle Delay game loop by 1 second Draw Text Step 1 - make font Step 2 - render text using font Step 3 - blit text on screen Part 2: Listening To The Keyboard Get a list of keys being pressed See if UP key is pressed See if letter ‘d’ is pressed See if spacebar is pressed Part 3: Detecting Mouse Clicks See if mouse button is pressed
Get the x-y position of the mouse Get rectangle around image Assign x of rectangle to image’s x Assign y of rectangle to image’s y See if mouse has clicked image Part 4: Moving Things With The Mouse No new commands to learn, just learning how to combine them 1 - Use hitbox to keep track of x- y location of image 2 - Draw image using x-y 3 - Get mouse x-y 4 - Adjust x-y to middle of image Part 5: Detect Collision Between 2 Things 1 - Get hitbox of image 1

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture