def update(self): #yay for update...
#this is actually surgy's code but i adapted it to my own and rewrote it
#so it uses god damn <s and >s not ==s and !=s... terrible programming.
self.lastrect.move(self.rect.topleft)
print "The last Rect is: %s"%self.lastrect
if self.envel <= 0:
if self.rect.left < self.en_xmax:
self.rect.move_ip(self.enspeed,0)
elif self.rect.left >= self.en_xmax:
self.envel = 1
elif self.envel > 0:
if self.rect.left > self.en_xmin:
self.rect.move_ip((-1)*self.enspeed,0)
elif self.rect.left <= self.en_xmin:
self.envel = 0
if self.en_state>=0 and self.en_state<5:
self.image=globalvars.explosions[self.en_state]
self.en_state+=1
if self.en_state>4:
globalvars.list_enemys.remove(self)
print "The last rect is now: %s, and the first rect is %s"%(self.lastrect, self.rect)
the output is:
The last Rect is: <rect(680, 40, 25, 25)>
The last rect is now: <rect(683, 40, 25, 25)>, and the first rect is <rect(683, 40, 25, 25)>
The last Rect is: <rect(500, 0, 25, 25)>
The last rect is now: <rect(503, 0, 25, 25)>, and the first rect is <rect(503, 0, 25, 25)>
The last Rect is: <rect(545, 0, 25, 25)>
The last rect is now: <rect(548, 0, 25, 25)>, and the first rect is <rect(548, 0, 25, 25)>
The last Rect is: <rect(545, 40, 25, 25)>
The last rect is now: <rect(548, 40, 25, 25)>, and the first rect is <rect(548, 40, 25, 25)>
The last Rect is: <rect(590, 0, 25, 25)>
The last rect is now: <rect(593, 0, 25, 25)>, and the first rect is <rect(593, 0, 25, 25)>
The last Rect is: <rect(590, 40, 25, 25)>
The last rect is now: <rect(593, 40, 25, 25)>, and the first rect is <rect(593, 40, 25, 25)>
The last Rect is: <rect(635, 0, 25, 25)>
The last rect is now: <rect(638, 0, 25, 25)>, and the first rect is <rect(638, 0, 25, 25)>