« All Events
6 PM – Python Game Development – Sebastian
October 10, 2023 @ 6:00 pm - 7:00 pm
Today We Did
- Finished adding movement to Player class
- Changed Player image direction on movement
- Began understanding hitboxes, groupcollide, and the rect attribute
- You can always find the code we wrote in class in my Gitlab repository here:
https://gitlab.com/gsugiart/tue-6-pm-dragon-birdie/-/tree/TUE-6PM-Sebastian - In case you need anything, feel free to email me at sebastian@ayclogic.com
Homework
- Homework: For both your Player and Bird classes, create a “rect” attribute, and set it to pygame’s “Rect” object:
pygame.Rect(self.x, self.y, self.right_images[0].get_width(), self.right_images[0].get_height())
- In each of their update methods (before you blit their image to screen):
- First check if TESTING is set to True (be sure you added TESTING = True in config.py)
- If it is, draw the “rect” attribute to the screen with:
pygame.draw.rect(self.screen, (255,0,255), self.rect)
- If everything is set up correctly, all birds & players should show their hitbox in red. To disable hitboxes, simply set the “TESTING” global variable (in config.py) to False.