def draw(self, surface): test.add_sticky('bee:draw') # for b in self.bullets: # b.draw(surface) # fullname = self.name + str(self.ancestry) super(Bee, self).draw(surface) ixy = self.xy.astype(int) if 0 and settings[SHOW_EYES]: box = self.decoration.get_rect( x=self.xy[0, 0] + self.eyedrawingoffset[0], y=self.xy[0, 1] + self.eyedrawingoffset[1]) surface.blit(self.decoration, box, special_flags=pygame.BLEND_ADD) if settings[SHOW_EYES]: for x, y in self.eyepoints: ixy = self.xy.astype(int) X = ixy[0, 0] + x Y = ixy[0, 1] + y # X %= surface.get_width() # Y %= surface.get_height() # if abs(X - ixy[0, 0]) > 500 or abs(Y - ixy[0, 1]) > 100: # continue # surface.set_at((X, y), graphics.outline) pygame.draw.line( surface, self.color, array(self.xy)[0], (X, Y), 1) start = self.xy end = self.prevpos '''this is here to make things trippy''' if abs(start[0, 0] - end[0, 0]) < 100: if abs(start[0, 1] - end[0, 1]) < 100: if self.madness == 1: '''lines''' w = 10 # pygame.draw.line(self.room.background, [0, 0, 0], array(self.xy)[0], array(self.prevpos)[0], w) pygame.draw.line( self.room.background, self.color, array(self.xy)[0], array(self.prevpos)[0], 1) elif self.madness == 2: '''extra mad''' c = self.color d = int(linalg.norm(self.prevpos - self.xy)) pygame.draw.circle( self.room.background, c, array(self.xy)[0], d / 3, 0) pygame.draw.line( self.room.background, c, array(self.xy)[0], array(self.prevpos)[0], 1) elif self.madness == 3: '''super mad''' w = int(linalg.norm(self.vxy) * 100 + 1) # pygame.draw.line(self.room.background, [255,20,20], array(self.xy)[0], array(self.prevpos)[0], w + 10) pygame.draw.line( self.room.background, self.color, array(self.xy)[0], array(self.prevpos)[0], w) # pygame.draw.line(self.room.background, [0, 0, 0], array(self.xy)[0], array(self.prevpos)[0], 1) elif self.madness == 4: '''lines with shadows''' w = 10 pygame.draw.line( self.room.background, [0, 0, 0], array(self.xy)[0], array(self.prevpos)[0], w) pygame.draw.line( self.room.background, self.color, array(self.xy)[0], array(self.prevpos)[0], 1) for x, y in utils.body_copies(self.xy, self.radius): px = ixy[0, 0] + x * graphics.world_w py = ixy[0, 1] + y * graphics.world_h # c = self.color blood = [255, 0, 0] # pygame.draw.circle(surface, c, (px, py), int(self.radius)) r = int(self.radius * 0.6) draw_blood = 0 if draw_blood: if self.vxy[0, 0] > 0: pygame.draw.line( surface, blood, (px - r, py - r), (px + r, py + r), 1) else: pygame.draw.line( surface, blood, (px + r, py - r), (px - r, py + r), 1) # pygame.draw.circle(surface, [int(p) for p in self.color], (px, py), int(self.radius)) # centercolor = [255-n for n in c] # rad = int(self.radius*(1-self.health)) # rad = max( rad, 0) # pygame.draw.circle(surface, [int(p) for p in centercolor], (px, py), rad) # if self.flash: # pygame.draw.circle(surface, [255, 255, 255], (px, py), self.flash + 1, 1) # self.flash -= 1 regularcolor = self.color r2 = int(self.radius * 0.6 * self.health) if settings[BEE_STYLE] == 1: if self.vxy[0, 0] > 0: pygame.draw.line( surface, regularcolor, (px - r2, py - r2), (px + r2, py + r2), 1) else: pygame.draw.line( surface, regularcolor, (px + r2, py - r2), (px - r2, py + r2), 1) elif settings[BEE_STYLE] == 2: # self.dvxy = matrix([0.0, 0.0]) rotation = self.dvxy[0, 0] * 600 dx = math.cos(rotation) dy = math.sin(rotation) dx, dy = 4 * dx, 4 * dy if self.flash: self.flash -= 1 if self.flash > 25: self.flash = 25 if self.flash < 0: self.flash = 0 c = [255 - 25 * self.flash, 255, 255 - 25 * self.flash] if self.see_bullet: c = [255, 255, 0] try: pygame.draw.line( surface, c, (px + dx, py + dy), (px - dx, py - dy), 3) except TypeError: print "TypeError while drawing bee, position is", print surface, c, (px + dx, py + dy), (px - dx, py - dy), 3 else: radius = 1 + int(self.radius * self.health) if (radius < 1): radius = 1 pygame.draw.circle(surface, regularcolor, (px, py), radius) if settings[SHOW_EYES]: for distance, (x, y) in zip(self.wallproximities, self.sharedeyes): l = (x**2 + y**2)**0.5 '''x0 = x/l*distance*graphics.screen_h/2 y0 = y/l*distance*graphics.screen_h/2 pygame.draw.line(surface, [255,255,255], (px,py), (px+x0, py+y0), 1)''' x1 = int(x / l * 10) y1 = int(y / l * 10) # size represents proximity # pygame.draw.circle(surface, regularcolor, ( px+x1, py+y1), 1 + int( (1 - distance) * 6) ) # color represents proximity # pygame.draw.circle(surface, regularcolor, ( px+x1, py+y1), 1 + int( (1 - distance) * 6) ) intensity = (1 - distance) * 255 if intensity < 0: intensity = 0 if intensity > 255: intensity = 255 # pygame.draw.circle(surface, (intensity, intensity, intensity), ( px+x1, py+y1), 3) scaling = math.sin(22.5) pygame.draw.line(surface, (intensity, intensity, intensity), ( px + x1 - y1 * scaling, py + y1 + x1 * scaling), (px + x1 + y1 * scaling, py + y1 - x1 * scaling)) if settings[SHOW_NAMES]: try: surface.blit(self.tag[1], array(self.xy)[0]) except: self.tag = "blah", "noway" l = self.firstname + " " + self.name if self.tag[0] != l: t = tinyfont.render(l, 0, [255, 255, 255]) self.tag = l, t # My velocity # endxy = ixy+numpy.round_(self.vxy*10) # pygame.draw.line(surface, (255, 255, 0), array(ixy)[0], array(endxy)[0], 1) test.remove_sticky('bee:draw')
def draw(self, surface): test.add_sticky('player') super(Player, self).draw(surface) if self.losinghealth: self.walkingspeed = self.radius / 15 * 0.04 self.displaycolor[0] = 0.9 * self.displaycolor[0] + 0.1 * 255 self.displaycolor[1] = 0.9 * self.displaycolor[1] self.displaycolor[2] = 0.9 * self.displaycolor[2] #self.color[0] = 255 else: self.displaycolor[0] = 0.9 * self.displaycolor[0] + 0.1 * self.color[0] self.displaycolor[1] = 0.9 * self.displaycolor[1] + 0.1 * self.color[1] self.displaycolor[2] = 0.9 * self.displaycolor[2] + 0.1 * self.color[2] color = [int(x) for x in self.displaycolor] #if self.counter >= self.radius - 10: # if self.radius < 20: # color = [255, 200, 0] # if self.counter >= self.radius: # self.counter -= self.radius ixy = self.xy.astype(int) for x,y in utils.body_copies(self.xy, self.radius): px = ixy[0,0] + x*graphics.world_w py = ixy[0,1] + y*graphics.world_h #pygame.draw.circle(surface, [180,255,255], (px, py), int(self.radius), 1) pi = 3.1415926 '''shoulders''' shouldershift = 0#max(min(int(10*self.vxy[0,0]), 10), -10) shoulderx = px + shouldershift shouldery = py - int(self.radius*0.7) if self.losinghealth: if self.beepushes: n = random.choice(self.beepushes) self.offset += n * 0.5 self.offset *= 0.95 for i in range(2): if self.offset[0,i] > 5: self.offset[0,i] = 5 if self.offset[0,i] < -5: self.offset[0,i] = -5 offsetx = int(self.offset[0,0]) offsety = int(self.offset[0,1]) self.beepushes = [] shoulderx += offsetx shouldery += offsety shoulders = (shoulderx, shouldery) '''head''' headx = shoulderx heady = shouldery-int(self.radius*0.1) #headx -= offsetx/2 #heady -= offsety/2 head = int(headx), int(heady) pygame.draw.circle(surface, color, head, int(self.radius*0.2), 0) '''groin''' groinx = px groiny = py+int(self.radius*0.1) groinx += offsetx / 2 groiny += offsety groin = (groinx, groiny) '''neck''' pygame.draw.line(surface, color, head, shoulders, 2) '''torso''' pygame.draw.line(surface, color, shoulders, groin, 2) '''right leg''' rightfootx = px + 0.4*self.radius - 3 * self.vxy[0,0] * self.radius rightfooty = py+int(self.radius) + 0.1*self.radius rightfootx = px + 0.4*self.radius*math.cos(self.walkingspeed*pi*self.xy[0,0]) if abs(self.vxy[0,0]) > 0.01: rightfooty = py+int(self.radius) step = 0.1*self.radius*math.sin(self.walkingspeed*pi*self.xy[0,0]) if step < 0: step *= abs(self.offset[0,1]*5 + 1) rightfooty += step rightfoot = rightfootx, rightfooty pygame.draw.line(surface, color, groin, rightfoot, 2) #pygame.draw.line(surface, color, (px,py+int(self.radius*0.2)), (px + self.radius*math.cos(0.4*pi), py+inself.radius*math.sin(0.4*pi)), 1) '''left leg''' leftfootx = px - 0.4*self.radius - 3 * self.vxy[0,0] * self.radius leftfooty = py+int(self.radius) + 0.1*self.radius leftfootx = px - 0.4*self.radius*math.cos(self.walkingspeed*pi*self.xy[0,0]) if abs(self.vxy[0,0]) > 0.01: leftfooty = py+self.radius step = - 0.1*self.radius*math.sin(self.walkingspeed*pi*self.xy[0,0]) if step < 0: step *= abs(self.offset[0,1]*5 + 1) leftfooty += step leftfooty = int(leftfooty) leftfoot = leftfootx, leftfooty pygame.draw.line(surface, color, groin, leftfoot, 2) rightpoint = px + 0.8 * self.radius, py + 0.8 * self.radius leftpoint = px - 0.8 * self.radius, py + 0.8 * self.radius rightpoint, leftpoint = [int(x) for x in rightpoint], [int(x) for x in leftpoint] #self.feetSupported = self.room.pointcheck(leftfoot) or self.room.pointcheck(rightfoot) or self.room.pointcheck(rightpoint) or self.room.pointcheck(leftpoint) #print "feet supported:", self.feetSupported ''''right arm''' #howfar = 0.3 #if self.vxy[0,0] >= 0: # howfar = 0.3 - 2.3 * (self.vxy[0,0]) #self.righta = 0.9 * self.righta + 0.1 * howfar #pygame.draw.line(surface, color, shoulders, (px + 0.7*self.radius*math.cos(self.righta*pi), py+0.7*self.radius*math.sin(self.righta*pi)), 2) righthandx = shoulderx + 0.4*self.radius * math.cos(self.walkingspeed*pi*self.xy[0,0]) * (0.2+min(abs(self.vxy[0,0]), 0.1))**0.5 * 2 righthandy = shouldery + self.radius righthandy -= abs(int(self.offset[0,1] * 5)) righthand = (righthandx, righthandy) pygame.draw.line(surface, color, shoulders, righthand, 2) '''left arm''' #howfar = 0.7 #if self.vxy[0,0] <= 0: # howfar = 0.7 - 2.3 * (self.vxy[0,0]) #self.lefta = 0.9 * self.lefta + 0.1 * howfar #pygame.draw.line(surface, color, shoulders, (px + 0.7*self.radius*math.cos(self.lefta*pi), py+0.7*self.radius*math.sin(self.lefta*pi)), 2) lefthandx = shoulderx - 0.4*self.radius * math.cos(self.walkingspeed*pi*self.xy[0,0]) * (0.2+min(abs(self.vxy[0,0]), 0.1))**0.5 * 2 lefthandy = shouldery + self.radius lefthandy -= abs(int(self.offset[0,1] * 5)) lefthand = (lefthandx, lefthandy) pygame.draw.line(surface, color, shoulders, lefthand, 2) ffcolor = [255, 255, 255] #if self.losinghealth: # ffcolor = [255, 0, 0] '''force field''' '''if self.losinghealth: pygame.draw.circle(surface, self.displaycolor, (px, py), int(self.forcefield), 1) ''' #pygame.draw.circle(surface, [255,255,0], (px, py), int(self.radius), 1) #centercolor = [0, 0, 0] #if self.losinghealth: # centercolor = [255, 200, 0] #pygame.draw.circle(surface, centercolor, (px, py), int(0.1*self.radius)) # My velocity #endxy = ixy+numpy.round_(self.vxy*10) #pygame.draw.line(surface, (255, 255, 0), array(ixy)[0], array(endxy)[0], 1) test.remove_sticky('player') self.losinghealth = 0