def __init__(self,position,floating=False): super().__init__(position,metal_color,floating=floating) shp = [(-self.size[0]*0.65,-self.size[0]*0.8),(self.size[0]*0.65,-self.size[0]*0.8),(0,-self.size[0]*0.15)] tri = Shape(shp,color = wood_color,line_color = dark_wood_color,line_width = 2) for _ in range(4): tri.rot90() self.shapes.append(copy.deepcopy(tri)) self.fruit = 1
def __init__(self,position,floating=False): super().__init__(position,floating=floating) self.shapes.append(Shape(self.self_shape(protector_size/box_size),protector_line_color,None,line_width = 2)) self.shapes.append(Shape(self.self_shape(0.9*protector_size/box_size),protector_color,None,line_width = 2)) self.shapes.append(Shape(self.self_shape([0.1,0.1]*protector_size/box_size),eye_color,None,line_width = 2)) self.shapes[-1].shift(self.size*[0.3,-0.3]*protector_size/box_size) # eye facing one way self.shapes.append(Shape(self.self_shape([0.1,0.1]*protector_size/box_size),eye_color,None,line_width = 2)) self.shapes[-1].shift(self.size*[-0.3,-0.3]*protector_size/box_size) # eye facing the other way self.fruit = 0 # no fruit inside
def __init__(self,position,floating=False): Box.__init__(self,position,metal_color,floating=floating) shp = Shape(self.self_shape(),color=None,line_color = (0,0,0),line_width = 2) shp.transform([[0.02,0],[0,0.02]]) for i in [-self.size[0]*.7, self.size[0]*.7]: for j in [-self.size[0]*.7, self.size[0]*.7]: shp2 = copy.deepcopy(shp) shp2.shift([i,j]) self.shapes.append(shp2) # add corner dots
def __init__(self,position,floating=False): Box.__init__(self,position,wood_color,floating=floating) shp = [(-self.size[0]*0.65,-self.size[0]*0.8),(self.size[0]*0.65,-self.size[0]*0.8),(0,-self.size[0]*0.15)] tri = Shape(shp,color = dark_wood_color,line_color = dark_wood_color,line_width = 2) for _ in range(4): tri.rot90() self.shapes.append(copy.deepcopy(tri)) self.bounces = 1 # regular wooden boxes can take exactly one bounce self.fruit = 1
def __init__(self, position): super().__init__(position) self.shapes.append( Shape(self.self_shape(), protector_line_color, None, line_width=2)) self.shapes.append( Shape(self.self_shape([0.9, 0.9]), character_color, None, line_width=2)) self.shapes.append( Shape(self.self_shape([0.1, 0.1]), eye_color, None, line_width=2)) self.shapes[-1].shift(self.size * [0.3, -0.3]) # eye facing one way self.shapes.append( Shape(self.self_shape([0.1, 0.1]), eye_color, None, line_width=2)) self.shapes[-1].shift(self.size * [-0.3, -0.3]) # eye facing the other way
def __init__(self,position,floating=False): super().__init__(position,floating) self.shapes = self.shapes[0:1] for k in range(-2,3): self.shapes.append(Shape(rect([self.size[0]*0.08,self.size[1]*0.8],[self.size[0]*k/3,0]),color = dark_wood_color,line_color = dark_wood_color,line_width = 2)) self.bounces = 10 # regular wooden boxes can take exactly one bounce, these do 10 self.fruit = 1
def __init__(self,position,color,line_color = (0,0,0),line_width = 2,floating=False): Body.__init__(self,position,self.size,True,True,[0,0]) self.shapes.append(Shape(self.self_shape(),color,line_color = line_color,line_width = line_width)) # add visible shape for box self.destruct_counter = -1 self.floating = floating self.fruit = 0 self.lives = 0 self.bounces = -1 self.hit_box = None # no hit box unless boom_box and exploding
def __init__(self, size, path, color=(50, 50, 50), line_color=None, line_width=2): super().__init__(size, path, corporeal=True, solid=True) self.shapes.append( Shape(self.self_shape(), color, line_color, line_width)) # add visible shape for box
def __init__(self, position): super().__init__(position) N = 10 nodes = [(0, -gettable_size * 3 / 5)] + [ (gettable_size * math.sin(2 * math.pi * (i + int(N / 10)) / N), -gettable_size * math.cos(2 * math.pi * (i + int(N / 10)) / N)) for i in range(N + 1 - 2 * int(N / 10)) ] self.shapes.append( Shape(nodes, color=(255, 0, 0), line_color=(150, 0, 0), line_width=2)) # add visible shape for box
def __init__(self, path_pts): Flier.__init__(self, path_pts, owl_speed, owl_size) self.shapes.append( Shape(self.self_shape(), color=owl_color, line_color=(0, 0, 0), line_width=2)) self.shapes.append( Shape(rect([S * 2, S * 2]), color=(0, 0, 0), line_color=(0, 0, 0), line_width=2)) self.shapes[-1].shift(self.size * [-0.7, -0.55]) self.shapes.append( Shape(rect([S * 2, S * 2]), color=(0, 0, 0), line_color=(0, 0, 0), line_width=2)) self.shapes[-1].shift(self.size * [0.7, -0.55]) self.shapes.append( Shape(spikey_box([2 * box_size / 3, box_size / 5], [0, 0, 0, 1]), color=owl_color, line_color=(0, 0, 0), line_width=2)) self.shapes[-1].shift(self.size * [0.7, -0.55]) self.shapes.append( Shape(spikey_box([2 * box_size / 3, box_size / 5], [0, 1, 0, 0]), color=owl_color, line_color=(0, 0, 0), line_width=2)) self.shapes[-1].shift(self.size * [-0.7, -0.55]) self.switchers = [self.shapes[1:3], self.shapes[3:5]] self.animators = self.shapes[3:5] self.shift_path = animate_path([0, S * 3], [0, 2], 150)
def __init__(self, position, size, color=platform_color, line_color=None, line_width=2): super().__init__(position, size, corporeal=True, solid=True, velocity=[0, 0]) self.shapes.append( Shape(self.self_shape(), color, line_color, line_width)) # add visible shape for box
def __init__(self, position): Body.__init__(self, position, protector_size, False, False, [0, 0]) self.shapes.append( Shape(self.self_shape([1.1, 1.1]), protector_color, None, line_width=2, visible=False)) self.shapes.append( Shape(self.self_shape(), protector_line_color, None, line_width=2)) self.shapes.append( Shape(self.self_shape([0.9, 0.9]), protector_color, None, line_width=2)) self.shapes.append( Shape(self.self_shape([0.1, 0.1]), eye_color, None, line_width=2)) self.shapes[-1].shift(self.size * [0.3, -0.3]) # eye facing one way self.shapes.append( Shape(self.self_shape([0.1, 0.1]), eye_color, None, line_width=2)) # add visible shape self.shapes[-1].shift(self.size * [-0.3, -0.3]) # eye facing the other way
def c_shape(s=1,shift=[0,0],transform = identitymat,color=(0,0,0),line_color=None): shp = [tuple((i+j) for i,j in zip(shift,node)) for node in [(3*s/4, 3*s/4),(-3*s/4, 3*s/4), (-3*s/4, -3*s/4), (3*s/4, -3*s/4), (3*s/4, -s/4), (-s/4, -s/4), (-s/4, s/4), (3*s/4, s/4)]] n_shp = Shape(shp,color = color,line_color = line_color,z = 1) n_shp.transform(transform) n_shp.shift(shift) return n_shp
from Player import Player from Constants import display_size, spikey_box, attack_color, character_color, eye_color from Level import Level from Make_Sounds import ouch_sound, thud_sound from os import path filepath = path.join(path.dirname(__file__), '') ## Define pause menu shapes and font pause_menu = Body(np.array(display_size) / 2, np.array(display_size) / 4) pause_menu.shapes.append( Shape(spikey_box([ pause_menu.size[0] + display_size[1] / 50, pause_menu.size[1] + display_size[1] / 50 ]), color=attack_color, line_color=(0, 0, 0), line_width=10)) pause_menu.shapes.append( Shape(pause_menu.self_shape(), color=character_color, line_color=None, line_width=10)) font = pygame.font.SysFont(filepath + 'freesansbold.ttf', int(pause_menu.size[1] * 0.8)) text = font.render('PAUSED', True, eye_color, None) textRect = text.get_rect() textRect.center = ([i / 2 for i in display_size]) text2 = font.render('GAME OVER', True, eye_color, None) textRect2 = text2.get_rect()
def __init__(self, position): super().__init__(position, player_size, corporeal=True, solid=True, velocity=[0, 0]) self.crouching = False self.reset() self.shape_dict = { 'body': Shape(self.self_shape([0.95, 0.9]), character_color, line_color=None, line_width=None) } self.shape_dict['body'].shift([0, -self.size[1] * 0.1]) self.shape_dict['legs'] = Shape(self.self_shape([0.9, 0.01]), legs_color, line_color=None, line_width=None) self.shape_dict['legs'].shift([0, self.size[1] * .97]) self.shape_dict['legs'].nodes[-1] = (0, 0) self.shape_dict['crouch_body'] = Shape(self.self_shape(), character_color, line_color=None, line_width=None) self.shape_dict['hand'] = Shape(spikey_box(self.size * [0.2, 0.25], spike_sides=[0, 0, 1, 0]), hand_color, line_color=None, line_width=None) self.shape_dict['hand'].shift([0, self.size[1] * 0.3]) self.shape_dict['eye'] = Shape(self.self_shape([0.1, 0.1]), eye_color, line_color=None, line_width=None) self.shape_dict['eye'].shift([0, -self.size[1] * 0.7]) for i in self.shape_dict.values( ): # create standard list for holding shapes so they can be accessed both ways self.shapes.append(i) self.jump_anticipation = jump_anticipation self.jump_recency = 0 self.animate = 0 self.shift_path = animate_path(player_size[0] * np.array([0.05, 0.1]), [2.0, 4.0], animate_length) # hitbox for attack self.attack_box = Body([0, 0], player_size * attack_fraction, solid=False) # self.attack_box.shapes.append(Shape(self.attack_box.self_shape(),color = (255,0,0),line_color = None)) self.attack_box.shapes.append( Shape(spikey_box(self.attack_box.size, [1, 1, 1, 1]), color=attack_color, line_color=None)) # self.attack_box.shapes[-1].shift(self.attack_box.size*[0,-attack_fraction[1]+1.0]) # hitbox for slide self.slide_box = Body( [0, 0], player_size * np.array([slide_fraction, crouch_fraction * 0.9], dtype='float'), solid=False) self.slide_box.shapes.append( Shape(spikey_box(self.slide_box.size, [0, 1, 0, 1]), color=attack_color, line_color=None)) # add outline # hitbox for flop self.flop_box = Body( [0, 0], player_size * np.array([flop_width, crouch_fraction], dtype='float'), solid=False) self.flop_box.shapes.append( Shape(spikey_box(self.flop_box.size, [0, 0, 1, 0]), color=attack_color, line_color=None)) # add outline self.protector = Protector(self.pos - self.size * [self.direction, 1.0]) Box.player = self # all boxes are now linked to this player!