PygameFeedback — PygameFeedback Base Class

This module contains the PygameFeedback baseclass.

class FeedbackBase.PygameFeedback.PygameFeedback(port_num=None)

Baseclass for Pygame based Feedbacks.

This class is derived from MainloopFeedback and brings some common functinality shared by most Feedbacks using Pygame.

Upon start it initializes pygame and calls initialize_graphics which can be overwritten by derived classes.

It also takes care of shutting down pygame automatically upon stop, quit or crash of the feedback.

After initialization of the feedback, it has some object variables which influence the Feedback’s behaviour:

  • FPS: (frames per second) influencees how much the Feedback advances in time during a tick call.
  • screenPos: List of integers holding the initial position of the pygame window.
  • screenSize: List of intigers holding the initial size of the pygame window.
  • fullscreen: Boolean
  • caption: String holding the initial value of the window caption.
  • elapsed: Fload holding the elapsed second since the last tick
  • backgroundColor: List of three integers holding the initial background colour
  • keypressed: Boolean holding if a key was pressed
  • lastkey: Last key
init()
Set some PygameFeedback variables to default values.
init_graphics()

Called after init_pygame.

Derived Classes overwrite this method.

init_pygame()
Set up pygame and the screen and the clock.
post_mainloop()
Quit pygame.
pre_mainloop()
Initialize pygame and graphics.
process_pygame_event(event)
Process a signle pygame event.
process_pygame_events()
Process the the pygame event queue and react on VIDEORESIZE.
tick()
Process pygame events and advance time for 1/FPS seconds.
wait_for_pygame_event()
Wait until a pygame event orcurs and process it.

Module author: Bastian Venthur <venthur@cs.tu-berlin.de>

Previous topic

MainloopFeedback — Base Class for Feedbacks with a Mainloop

This Page