def __init__(self, pos): """ pos -> position tuple platG -> platform Group """ # initialise parent class pygame.sprite.Sprite.__init__(self) self.x = pos[0] self.y = pos[1] # state varibles self.idle = True self.walk = False self.fall = True # attributes self.speed = 3 self.x_vel =0 self.y_vel = 0 self.jump_power = 10 # animation indices self.walkPos = 0 self.walkFact = 8 # every eigth iteration , fetch next image self.animSpeed = 2 # special attributes self.worldShift = False # shifting the world self.canShift = True # atarimae darou # extract walking images sheet = SpriteSheet(playWalkPath) self.walk_r_list = list() self.walk_l_list = list() # extract left-facing images w = 66 h = 92 self.coords = [(0, 0, w, h), (67, 0, w, h), (134, 0, w, h), \ (0, 93, w, h), (67, 93, 64, h), (132, 93, 72, h), \ (0, 187, 70, h), (71, 187, 70, h), (142, 187, 70,h), \ (0, 279, 70, h), (71, 279, 70, h)] for ind in self.coords: image_r = sheet.get_image(*ind).convert() # expand tuple into arugments self.walk_r_list.append(image_r) image_l = pygame.transform.flip(image_r, True, False) self.walk_l_list.append(image_l) # startup values self.rightIdleImg = self.walk_r_list[0] self.leftIdleImg = self.walk_l_list[0] self.image = self.rightIdleImg self.direction = RIGHT self.rect = self.image.get_rect(topleft=pos) # set correct position self.OUTLIST = [False, 0.00] # isShifting, time
def __init__(self, pos): """ pos -> position tuple platG -> platform Group """ # initialise parent class pygame.sprite.Sprite.__init__(self) self.x = pos[0] self.y = pos[1] #emergency debug vars self.d1 = None self.d2 = None # state varibles self.idle = True self.walk = False self.fall = False self.climb = False # for ladders and such self.climb_mobility = True # moving up and down self.action_contact = False # in contact with a switch or such self.water_contact = False # in contact with water # attributes self.speed = 3 self.x_vel = 0 self.y_vel = 0 self.jump_power = 10 self.health = MAX_PLAYER_HEALTH self.ammo = 50 # No of fireballs self.canShoot = True # can shoot fireball # item-related attributes self.coins = 0 self.keys = 0 # animation indices self.walkPos = 0 self.walkFact = 8 # every eigth iteration, fetch next image self.animSpeed = 2 # special attributes self.worldShift = False # shifting the world self.canShift = True # atarimae darou self.prev_slope = False self.d1 = self.d2 = 0 # for debugging purposes only # extract walking images sheet = SpriteSheet(playWalkPath) # timers for abilities self.timer_fire = 0 self.timer_allstop = 0 self.walk_r_list = list() self.walk_l_list = list() # extract left-facing images w = 66 h = 92 self.coords = [(0, 0, w, h), (67, 0, w, h), (134, 0, w, h), \ (0, 93, w, h), (67, 93, 64, h), (132, 93, 72, h), \ (0, 187, 70, h), (71, 187, 70, h), (142, 187, 70,h), \ (0, 279, 70, h), (71, 279, 70, h)] for ind in self.coords: image_r = sheet.get_image(*ind).convert() # expand tuple into arugments self.walk_r_list.append(image_r) image_l = pygame.transform.flip(image_r, True, False) self.walk_l_list.append(image_l) # startup values self.rightIdleImg = self.walk_r_list[0] self.leftIdleImg = self.walk_l_list[0] self.image = self.rightIdleImg self.direction = RIGHT self.rect = self.image.get_rect(topleft=pos) # set correct position self.OUTLIST = [False, 0.00] # isShifting, time self.powerGroup = pygame.sprite.Group() self.action_obj = None # stores currently-touching action obj # IGNORABLE VARS self.intMousePos = (0, 0)