100%(1)1 out of 1 people found this document helpful
This preview shows page 1 - 13 out of 50 pages.
Pygame and Computer Graphics
ObjectivesComputer Graphics IntroWhat is PygameInstalling PygameBasics of PygameDrawing on a SurfaceDrawable ObjectsAnimationCollision detection24/22/2019
ReadingReadings from “Making Games with Python & Pygame”Chapters 1 and 234/22/2019
CLI vs. GUICLI: Command Line Interface:User interacts with the program via textDisplayed on the screen / Entered via keyboardNo graphics, colors, or mouse inputGUI: Graphical User Interface:Windows with graphics, colors, images, soundsUser can interact with the program via the mouse, keyboard, and other devices.44/22/2019
Computer GraphicsGoing from a command-line interface (CLI) to a graphical user interface (GUI) is non-trivial!It involves things like:Determining how to render pixels on a screen given primitive representationi.e. How to make the pixels of a line given its endpointsCovered in CS 430How to respond to eventsWhere was a mouse clicked? And on what?And a lot of these things are hardware and software dependentGraphics card capabilitiesOperating System54/22/2019
Computer GraphicsAs computers became more mainstream in the 1980’s, the desire for a more graphical interface became necessaryGraphics APIs (application programming interface) try to take away some of the “under the hood” details of graphics at different levels of abstractionCovered in CS 432 – OpenGL Programming64/22/2019
Computer GraphicsComputer Graphics are a great application of object oriented programming since intrinsically there are various “objects” on the screen.As a sort of case study for this course, we’ll look at making graphic applications using a Python 2D graphics API, Pygame74/22/2019
What is Pygame?Pygame is a Free and Open Source Python library for making multimedia applications like games and animations. Includes several modules with functions for drawing graphics, playing sounds, handling mouse input, etc.84/22/2019
Pygame - InstallationTo install pygame we’ll use the python-supplied pip3program, run from the command line:pip3 install pygameNote: You may have to navigate to where you installed Python to find the pip executable and run the command from in there.94/22/2019
PygameThe following lecture material is based on the online book:In addition the official Pygame website:104/22/2019
The ImportsThe first step to use Pygame will be to importPygame.We could just import sub-packages of Pygame, but for simplicity lets just import everything:import pygame114/22/2019
InitializationOnce we have our imports set, we need to do some initialization.