def __init__(self, pos=mymath.Vector2(0, 0), health=100, debug=False): self.pos = pos self.name = "Hero" self.health = health self.speed = 0.4 self.equipment = [-1, -1, -1, -1, -1, -1, [], []] self.direction = IDLE self.invincibility_period = 0 self.attack_delay = 1000 self.cur_delay = 0 self.sub_entities = [] self.particles = [] self.anim = Animate(self, Imgload().getlist()) self.tmp_key_list = [] #if debug: self.equipment[EQUIP_WEAPON] = Equipment() self.equipment[EQUIP_WEAPON].equipPrimary("Longsword") self.stats = [ self.health, self.equipment[EQUIP_WEAPON].primary['damage'], self.speed, self.equipment[EQUIP_WEAPON].primary['knockback'] ]
def __init__(self, name, pos, velocity=mymath.Vector2(0, 0), physical=True, background=False): self.name = name self.pos = pos self.velocity = velocity self.physical = physical self.background = background
def __init__(self, name, pos, texture, physical=True, background=True): EntityBase.__init__(self, name, pos, mymath.Vector2(0, 0), physical, background) self.texture = pygame.transform.scale(pygame.image.load(texture), (32, 32))
def hit(self, damage, knockback=mymath.Vector2(0, 0)): self.health -= damage self.pos += knockback self.show_health = 10
def hit(self, x, k=mymath.Vector2(0, 0)): pass
ITEM_EQUIPABLE = 1 EQUIP_HELM = 0 EQUIP_CHEST = 1 EQUIP_LEGS = 2 EQUIP_FOOT = 3 EQUIP_WEAPON = 4 EQUIP_OFFHAND = 5 EQUIP_CONSUMABLE = 6 EQUIP_TRINKET = 7 NONE = 0 CON_HEALTH = 1 CON_POWER = 2 DOWN = mymath.Vector2(0, 1) UP = mymath.Vector2(0, -1) RIGHT = mymath.Vector2(1, 0) LEFT = mymath.Vector2(-1, 0) IDLE = mymath.Vector2(0, 0) class EntityBase(object): def __init__(self, name, pos, velocity=mymath.Vector2(0, 0), physical=True, background=False): self.name = name self.pos = pos
import MapSystem from EntityClasses import * import mymath import equipment pygame.init() resolution = (640, 800) window = pygame.display.set_mode(resolution) clock = pygame.time.Clock() list_of_keys = [] Players = [] Players.append(Player(mymath.Vector2(100, 100), 100, True)) room_size = (640, 640) roomSurface = pygame.Surface((640, 640)) hudSurface = pygame.Surface((640, 160)) Floor = MapSystem.Floor(roomSurface) done = False while not done: dtime = clock.tick() evtList = pygame.event.get() for evt in evtList: if evt.type == pygame.QUIT: