本文整理汇总了Python中Character.Character类的典型用法代码示例。如果您正苦于以下问题:Python Character类的具体用法?Python Character怎么用?Python Character使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Character类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self, data):
try:
self.playerId = data.getString()
self.type = data.getUint16()
self.x = data.getFloat32()
self.y = data.getFloat32()
self.z = data.getFloat32()
#print "q"
char = Character(self.world, self.type)
char.actor.setPos(self.x,self.y,0)
char.setPlayerId(self.playerId)
charPresent = False
for charTemp in self.world.characters:
if charTemp.getPlayerId() == char.playerId:
charPresent = True
break
if not charPresent:
self.world.characters.append(char)
print "ResponseCreateCharacter - ", self.playerId, " x:", self.x, " y:", self.y," z:", self.z
#self.log('Received [' + str(Constants.RAND_STRING) + '] String Response')
except:
self.log('Bad [' + str(Constants.RAND_STRING) + '] String Response')
print_exc()
示例2: Game
class Game(object):
def __init__(self):
self.TITLE = "TEST (by zeeisl)"
self.WIDTH = 800
self.HEIGHT = 600
self.controller = Controller()
# game things
self.char = Player("res//hero.png")
self.map = Map()
self.char1 = Character("res//hero.png", 100, 100, 32, 32)
def key_input(self, event):
self.controller.getButtonStates(event)
self.char.key_input(event)
def update(self, delta):
self.map.update()
self.char.update(self.char1)
self.char1.update()
def render(self, screen):
self.map.render(screen)
self.char.render(screen)
self.char1.render(screen)
示例3: update
def update(self):
Character.update(self)
if self.attack_time > 0:
self.image = self.attack_anim[self.attack_time//12]
self.rect.x += 23
self.attack_time -= 1
示例4: assign_to_taskgroup
def assign_to_taskgroup(self, Character):
self.__task_group.append(Character)
if self.__req_skills.count == 0:
pass
else:
for i in range(0, len(self.__req_skills)):
Character.get_skill(self.__req_skills[i])
示例5: dummyCharacters
def dummyCharacters ( self ):
print ("Dummy Characters")
#A dummy character created
#This can be switched out with user control of some kind
#This works because the Jade Runner is waiting for CharacterCreationCompletedEvent ()
#Send out Event that we are making a new Group called 0
#This will be the main group on screen.
ev = Events.NewGroupEvent ( 0 )
self.mediator.post ( ev )
#Dummy Character
char = Character ( self.mediator )
char.setName ( "Name" + str(self.count) )
print (char.getName ( ))
ev = Events.NewCharacterEvent ( char )
self.mediator.post ( ev )
self.mediator.post ( Events.ClusterAddCharacterEvent ( 0 , char.getName ( ) ) )
self.count += 1
#Dummy Character
char = Character ( self.mediator )
char.setName ( "Name" + str(self.count) )
print (char.getName ( ))
ev = Events.NewCharacterEvent ( char )
self.mediator.post ( ev )
self.mediator.post ( Events.ClusterAddCharacterEvent ( 0 , char.getName ( ) ) )
self.count += 1
self.completedSelection ( )
示例6: load_characters
def load_characters(neighbours, blur_scale, verbose=0):
chars_file = 'characters_%s_%s.dat' % (blur_scale, neighbours)
if exists(chars_file):
print 'Loading characters...'
chars = fload(chars_file)
else:
print 'Going to generate character objects...'
chars = []
for char in sorted(listdir(IMAGES_FOLDER)):
count = 0
for image in sorted(listdir(IMAGES_FOLDER + char)):
image = GrayscaleImage(IMAGES_FOLDER + char + '/' + image)
norm = NormalizedCharacterImage(image, blur=blur_scale, \
height=NORMALIZED_HEIGHT)
character = Character(char, [], norm)
character.get_single_cell_feature_vector(neighbours)
chars.append(character)
count += 1
if verbose:
print 'Loaded character %s %d times' % (char, count)
if verbose:
print 'Saving characters...'
fdump(chars, chars_file)
return chars
示例7: __init__
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)
示例8: __init__
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)
示例9: __init__
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)
示例10: __init__
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)
示例11: __init__
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)
示例12: apply_def_buff
def apply_def_buff(self):
if not self._is_dead:
health = Character.get_health(self)
if self._def_buff==1:
Character.set_health(self, health*1.1)
Swordsman.MAX_HEALTH = Swordsman.MAX_HEALTH*1.1
elif self._def_buff==2:
Character.set_health(self, health*1.25)
Swordsman.MAX_HEALTH = Swordsman.MAX_HEALTH*1.25
示例13: setUp
def setUp(self):
"""Create a character for us to test with."""
c = Character()
self.char = c
# Some stat values.
c.body = 6
c.mind = 8
c.soul = 7
示例14: __init__
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
示例15: __init__
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)