Lecture 22: GUI Applications
CS 1110 Introduction to Computing Using Python
[E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White]
http://www.cs.cornell.edu/courses/cs1110/2019sp
Lecture 22: GUI Applications CS 1110 Introduction to Computing - - PowerPoint PPT Presentation
http://www.cs.cornell.edu/courses/cs1110/2019sp Lecture 22: GUI Applications CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White] Relevant modules (see schedule page)
[E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White]
http://www.cs.cornell.edu/courses/cs1110/2019sp
Update display/view No change to objects Check for user input Process user input Update the objects
def update(self,dt): """ Animates the ellipse. Parameter dt: The time since the last animation frame. Precondition: dt is a float. """ # Change the angle self.angle = self.angle+ANIMATION_STEP % (2*math.pi) pos=self._polar_to_coord(ANIMATION_RADIUS,self.angle) self.ellipse.x = pos[0] self.ellipse.y = pos[1]
§ Playing game vs. pausing § Ball countdown vs. serve
§ Method update() checks state § Executes correct helper
§ State is an enumeration;
§ Implemented as an int § Global constants are values
_determineState(self):
§ Has built-in draw method § See documentation in A7
§ Example: rockets in pyro.py § Each rocket is a model § But so is the entire list! § update() will change both
§ Ship to animate the player § Alien to represent an alien