本文整理汇总了Python中Character.Character.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Character.__init__方法的具体用法?Python Character.__init__怎么用?Python Character.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character.Character
的用法示例。
在下文中一共展示了Character.__init__方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self):
""" Constructor function """
Character.__init__(self)
#Load images and rectangles
self.jump_l_image, self.jump_l_image_rect = routines.load_png('hero_3/jump_l.png')
self.jump_r_image, self.jump_r_image_rect = routines.load_png('hero_3/jump_r.png')
self.idle_l_image, self.idle_l_image_rect = routines.load_png('hero_3/idle_l.png')
self.idle_r_image, self.idle_r_image_rect = routines.load_png('hero_3/idle_r.png')
self.move_1_r_image, self.move_1_r_image_rect = routines.load_png('hero_3/move_1_r.png')
self.move_1_l_image, self.move_1_l_image_rect = routines.load_png('hero_3/move_1_l.png')
self.move_2_r_image, self.move_2_r_image_rect = routines.load_png('hero_3/move_2_r.png')
self.move_2_l_image, self.move_2_l_image_rect = routines.load_png('hero_3/move_2_l.png')
self.dead_image, self.dead_image_rect = routines.load_png('hero_3/death.png')
#load sounds
self.sounds={}
self.sounds['jump']=pygame.mixer.Sound('data/sound/jump.wav')
self.image = self.idle_l_image
self.rect = self.idle_l_image_rect
# Set a referance to the image rect.
#Setup status
self.status = 'idle_r' #idle,move,jump,
self.location = 'ground' #ground,air,block
Character.set_options(self, 13, 0, 1)
示例2: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x, y):
self.health = Survivor.START_HEALTH
self.current_weapon = 0 # 0 -> pistol, 1 -> shotgun, 2 -> automatic
self.direction = Direction.WEST
self.img = pygame.image.load('images/survivor/survivor_w.png')
Character.__init__(self, x, y)
示例3: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self,level, pName = None, pStr = None, pDex = None, pMnd = None, pLck = None, pWeapon = None, pArmor = None, pInventory = None, pHp = None,
pLevel = None, pAp = None, pDescription = None, pAge = None, pMp = None, pPp = None, pManaEnabled = None):
if (pName == None and pStr == None and pDex == None and pMnd == None and pLck == None and
pWeapon == None and pArmor == None and pInventory == None and pHp == None and pLevel == None and
pAp == None and pDescription == None and pAge == None and pMp == None and pPp == None and pManaEnabled == None):
self.createEnemy(level)
else:
Character.__init__(self, pName, pStr, pDex, pMnd, pLck, pWeapon, pArmor, pInventory, pHp, pLevel, pAp, pDescription, pAge, pMp, pPp, pManaEnabled)
示例4: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x, y):
self.direction = Direction.WEST
self.health = Zombie.START_HEALTH
self.img = Zombie.ORIGINAL_ZOMBIE_IMAGE
Character.__init__(self, x, y)
Zombie.list_.append(self)
示例5: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x, y):
self.health = Survivor.START_HEALTH
self.current_weapon = Weapon(Weapon.PISTOL)
self.direction = Direction.WEST
self.img = pygame.image.load('images/survivor/survivor_w.png')
Character.__init__(self, x, y)
示例6: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x):
idle = SpriteSheet("art/pl_cid.png").images_at(
[(0,0,300,400)],colourkey=(0,255,0))
walk = SpriteSheet("art/pl_cid_walk.png").images_at(
[(0,0,300,400),
(300,0,300,400)],colourkey=(0,255,0))
attack = SpriteSheet("art/pl_cid_attack1.png").images_at(
[(0,0,250,400),
(250,0,250,400),
(500,0,250,400),
(750,0,250,400)],colourkey=(0,255,0))
Character.__init__(self, x, idle, walk, attack)
self.attack_time = -1
示例7: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self,model,run,walk,startPoint,scale):
"""Initialise the character.
Initialises private fields used to control the character's behaviour.
Also see Character.__init__().
Arguments:
See Character.__init__().
"""
Character.__init__(self, model, run, walk, startPoint, scale)
self.prevTurnTime = 0
self.setControl('up',1)
示例8: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x, y, director):
Character.__init__(self, x, y, "player-alt.png", -1,
"coordPlayerAlt2.txt", [3, 3, 3, 3], director, (-4, 10, 4, 6, -2, 4, 2, 8))
self.controller = PlayerController(self, director)
self.posIndex = POS_DOWN
self.posImageIndex = 1
self.hp = 100
self.atk = 20
self.director = director
self.mask = pygame.mask.from_surface(self.sheet.subsurface(self.sheetCoord[self.posIndex][self.posImageIndex]))
# Better collisions this way
self.rect.inflate_ip(-4, -6)
self.atk_speed = PLAYER_ATTACK_SPEED
self.selectedWpnNum = 0
self.totalWpns = 0
self.weapons = []
示例9: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x):
idle = SpriteSheet("art/pl_shana.png").images_at([(0, 0, 300, 400)], colourkey=(0, 255, 0))
walk = SpriteSheet("art/pl_shana_walk.png").images_at(
[(0, 0, 300, 400), (300, 0, 300, 400), (600, 0, 300, 400), (900, 0, 300, 400)], colourkey=(0, 255, 0)
)
attack = SpriteSheet("art/pl_shana_attack1.png").images_at(
[
(0, 0, 400, 400),
(400, 0, 400, 400),
(800, 0, 400, 400),
(1200, 0, 400, 400),
(1600, 0, 400, 400),
(2000, 0, 400, 400),
],
colourkey=(0, 255, 0),
)
Character.__init__(self, x, idle, walk, attack)
self.attacking = False
self.attack_time = 0
self.time_till_attack = 60
self.damage = 20
示例10: createEnemy
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def createEnemy(self, level):
name = getGnoblinName(level)
statsFlag = False
while statsFlag == False:
STR = randint(1,8)-randint(1,6)
DEX = randint(1,8)-randint(1,6)
MND = randint(1,8)-randint(1,6)
LCK = randint(1,8)-randint(1,6)
if STR+DEX+MND >= 0:
statsFlag = True
armor = ["armor","Unarmored",0,0,0,None]
weapon = ["weapon","melee","Unarmed",6,0]
inventory = []
hp = [0,0,0,0,0]
hp[2] = 6
hp[1] = randint(1,hp[2])+STR
hp[0] = hp[1]
hp[3] = 1
ap = level*100 + (randint(0,99))
description = "A depressingly small gnoblinoid."
age = [randint(8,19),19+randint(1,30)]
if MND >=5:
manaEnabled = True
mpTemp = randint(1,4)+MND
mp = [mpTemp,mpTemp,4,1,0]
ppTemp = randint(1,4)+MND
pp = [ppTemp,ppTemp,4,1,0]
else:
manaEnabled = False
mp = [0,0,0,0,0]
pp = [0,0,0,0,0]
#Create the foe.
Character.__init__(self, name,STR,DEX,MND,LCK,weapon, armor, inventory, hp, level, ap, description, age, mp, pp, manaEnabled)
#Stat Assignment
for i in range(level):
levelSelect = randint(1,5)
self.levelUp(levelSelect)
示例11: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, x, y, imageName, colorkey, coordsName, numImages, player, magicNumbers=(0, 0, 0, 0, 0, 0, 0, 0), director=None, *args):
Character.__init__(self, x, y, imageName, colorkey, coordsName, numImages, magicNumbers, director)
self.controller = MeleeController(self, player, director)
self.rect = pygame.Rect(x, y, 10, 10)
self.atk_speed = ENEMY_ATTACK_SPEED
self.damageCooldown = 0
示例12: charCreate
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
#.........这里部分代码省略.........
else:
attributes = ["Strength", "Dexterity", "Mind"]
statsChosen = [0,0,0]
print("There are three stats: " + attributes[0] + ", " + attributes[1] + ", and " + attributes[2] + ".")
for i in range(0, len(attributes)-1, 1):
flag = False
rerollFlag = False
while flag == False:
print("Your rolls are as follows: ", end="")
for j in range(0, len(rolls)-1, 1):
print(str(rolls[j]) + ", ", end="")
if len(rolls) != 1:
print("and ", end="")
print(rolls[len(rolls)-1])
statChoiceString = "Which stat would you like to assign to " + attributes[i] + "?"
if rerolled == False:
statChoiceString = statChoiceString + "\nPress 'r' to reroll your stats.(This can be done only once!)\n>"
else:
statChoiceString = statChoiceString + "\n>"
statChoice = input(statChoiceString)
if "r" in statChoice and rerolled == False:
rerollFlag = True
break
else:
rerollFlag = False
try:
statChoice = int(statChoice)
except:
print("Try again.")
continue
if statChoice in rolls:
rolls.remove(statChoice)
statsChosen[i] = statChoice
flag = True
else:
print("That's not one of your stats!")
if rerollFlag == True and rerolled == False:
break
if rerollFlag == True and rerolled == False:
rerolled = True
continue
statsChosen[2] = rolls[0]
rolls = None
rollFlag = True
age = [0,30+randint(1,20)+randint(1,20)+randint(1,20)+randint(1,20)]
ageFlag = False
while ageFlag ==False:
age[0] = input("Your maximum age is "+str(age[1])+". How old are you currently?\n>")
try:
age[0] = int(age[0])
if age[0]>age[1]:
print("You would have died of old age!")
elif age[0] < 0:
print("I'm not entirely sure you understand how age works.")
elif age[0] < 8:
print("I'm not giving a sword to a child.\nWell, I'm not giving you a sword anyways, but you get the point.")
else:
ageFlag = True
except:
print("An integer, please!")
#name already set
STR = statsChosen[0]
DEX = statsChosen[1]
MND = statsChosen[2]
#LCK already set
#inv type, weap type, name, damage die, to-hit
weapon = ["weapon","melee","Unarmed",6,0]
#inv type, name, AS, RR, RT, Max Dex
armor = ["armor","Unarmored",0,0,0,None]
inventory = [None]
#Create an HP function here.
#Temp,Max,Die,Rolls,Bonus
hp = [0,0,0,0,0]
hp[2] = 6
hp[1] = randint(1,hp[2])+STR
hp[0] = hp[1]
hp[3] = 1
level = 1
ap = 0
description = input("How would you describe your character?\n>")
#Base attack stat: Default STR
BAS = "STR"
#Base defense stat: Default DEX
BDS = "DEX"
dodge = DEX+armor[2]
if MND >=5:
mpTemp = randint(1,4)+MND
#Temp,Max,Die,Rolls,Bonus
mp = [mpTemp,mpTemp,4,1,0]
ppTemp = randint(1,4)+MND
pp = [ppTemp,ppTemp,4,1,0]
manaEnabled = True
else:
mp = [0,0,0,0,0]
pp = [0,0,0,0,0]
manaEnabled = False
global player
Character.__init__(self, name,STR,DEX,MND,LCK,weapon, armor, inventory, hp, level, ap, description, age, mp, pp, manaEnabled)
print("A hero has risen!")
gameState = "Running"
示例13: __init__
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import __init__ [as 别名]
def __init__(self, unique_id, nickname):
Character.__init__(self, unique_id, nickname, 'NWBCTY')