~rick-rickspencer3/pygame-template/trunk

« back to all changes in this revision

Viewing changes to crashteroids/guy.py

  • Committer: Rick Spencer
  • Date: 2010-03-07 00:17:48 UTC
  • Revision ID: rick.spencer@canonical.com-20100307001748-dh8grxsuakbu4cu1
lots of renaming of camelCase names, and indented and documented baseSprite.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        self.bigbullets = False
42
42
 
43
43
    def init_position(self):
44
 
        """init_position - resets the Guy's position on screen"""
 
44
        """init_position - resets the Guy's position on screen
 
45
        Will reset the Sprite's image to the starting image.
 
46
        
 
47
        """
 
48
 
45
49
        #start off in the center of screen, still, facing up
46
50
        self.stop()
47
51
        self.x = 400
48
52
        self.y = 240
49
 
        self.masterImage = pygame.image.load(crashteroidsconfig.guy_img)
50
 
        self.updateImage()
 
53
        self.master_image = pygame.image.load(crashteroidsconfig.guy_img)
 
54
        self.update_image()
51
55
        self.visible = True
52
56
        self.alive = True
53
57
  
128
132
        """
129
133
 
130
134
        self.orientation = 0
131
 
        self.rotatingRight = False
132
 
        self.rotatingLeft = False
133
 
        self.velocityX = 0
134
 
        self.velocityY = 0
135
 
        self.accelerating = False
 
135
        self._rotating_right = False
 
136
        self._rotating_left = False
 
137
        self.velocity_x = 0
 
138
        self.velocity_y = 0
 
139
        self._accelerating = False
136
140
  
137
141
    def update(self):
138
142
        """update - Update internal data for a game tick""" 
143
147
        #for frictionless physics like in a space game
144
148
        #you can decrement the velocity or even
145
149
        #delete these lines for asteroids-like physics
146
 
        if not self.accelerating:
147
 
            self.velocityX = 0
148
 
            self.velocityY = 0
 
150
        if not self._accelerating:
 
151
            self.velocity_x = 0
 
152
            self.velocity_y = 0
149
153
  
150
154
        #manage the exploding animation
151
155
        if self.exploding: 
155
159
            if e < 8:#there are 7 explosion images
156
160
                e = str(e)
157
161
                img_name = crashteroidsconfig.guy_explode_stage + e  + ".png"
158
 
                self.masterImage = pygame.image.load(img_name)
159
 
                self.updateImage()
 
162
                self.master_image = pygame.image.load(img_name)
 
163
                self.update_image()
160
164
 
161
165
            else:#explosion is done
162
166
                self.visible = False