Plan du cours :
If we have time
type the following command to get access to the pygame module and all its amazing possibilities
import pygame
Then you have to initialize all the things that pygame requires
pygame.init()
Nothing shows up yet, and that’s normal. In order to be able to draw something you have to define a display window, which requires us to specify the width and height of the window
pygame.display.set_mode((400,300))
Now you can close your window
pygame.quit()
You might notice that there is still some pygame stuff running, so to actually close everything, quit the interpreter
quit
Try again, but this time, Use a variable to store the display window object
MY_WINDOW=pygame.display.set_mode((400,300))
Take a look at the variable attributes and methods using
MY_WINDOW. and hit the tabulation key
run it using the command line
python name_of_your_program.py
pygame.time.wait
function and use it in your programNow we will interact a little bit with that display window.
The colors are coded using a triplet of values for its RED, GREEN and BLUE components.
Each component intensity is represented by a number that can take values between 0 and 255 (it is coded on one 8-bit byte).
Thus:
(255,0,0)
(0,255,0)
(0,0,255)
(0,0,0)
(255,255,255)
In order to control the timing of a stimulus appearance on a screen, drawing and displaying are two diferent steps.
pygame.display.flip()
functionprems.py
MY_WINDOW.fill()
method to change the color of the windowpygame.display.flip()
to actually display it