- This event has passed.
6 PM – Python Game Development – Sebastian
December 5, 2023 @ 6:00 pm - 7:00 pm
Today We Did
- Blitted coin images to screen
- Created player class
- Added player’s jump functionality using gravity
- Remembered how to use the ASCII table to detect which key the user typed
- You can always find the code we wrote in class in my Gitlab repository here:
https://gitlab.com/gsugiart/tue-6-pm-flappy-bird/-/tree/Sebastian?ref_type=heads - In case you need anything, feel free to email me at sebastian@ayclogic.com
Homework
- Homework: Next class we will begin developing collisions between different sprites, please add the “self.rect” attribute to all classes which will need to handle collisions.
- To create this pygame rectangle for collisions, we use the method:
self.rect = pygame.Rect(x, y, width, height)
The x and y will be simple for every class since they all have attributes for x and y, but you will have to think a bit more to get the width & height.
- The width & height of a rectangle should be based off the image(s) corresponding to the class. We can get an image’s width and height with these methods:
image.get_width() image.get_height()
The tricky part will be to get a singular image, since some classes have lists of images instead of just a single image! Remember how to index inside of a list and grab one image to fix this. Does it matter which image we get from the list, or are they all the same width/height?
- To create this pygame rectangle for collisions, we use the method:
- Once you added this self.rect attribute to 3 classes without any errors, you know you’re done.