Ejemplo n.º 1
0
    def __init__(self):
        """
        Main game class initialization. All other class references point to this class as "game"
        """
        # window setup
        pygame.display.set_caption('Necromonster')
        pygame.display.set_icon(
            pygame.image.load(os.path.join('rec', 'misc', 'icon.png')))
        self.main_path = os.getcwd()

        # initiate the clock and screen object
        self.clock = pygame.time.Clock()
        self.FPS = 50
        self.last_tick = pygame.time.get_ticks()
        self.screen_res = [900, 650]
        self.center_point = [470, 350]
        self.screen = pygame.display.set_mode(self.screen_res,
                                              pygame.HWSURFACE, 32)

        #DEBUG values
        self.DEBUG = 1
        self.RECT_DEBUG = 0
        self.angle = 0

        #Init and assign custom game class(es)
        self.EntityHandler = EntityHandler(self)
        self.ParticleManager = ParticleManager(self)
        self.Scheduler = Schedule(self)
        self.Entity = Entity
        self.Projectile = Projectile
        self.Monster = Monster
        self.NPC = NPC
        self.NPCText = NPCText
        self.Item = Item
        self.Inventory = Invent
        self.Invent = self.Inventory(self)
        self.Weapon = Weapon
        self.Garment = Garment
        self.Player = Player(self)
        self.HUD = HUD(self)

        # Init entity manager vars
        self.entities = []
        self.shadows = []

        # load fonts, create font list
        # do not use pygame.font.SysFont!
        self.text_list = []
        self.default_font = pygame.font.Font(
            os.path.join('rec', 'font', 'freesansbold.ttf'), 15)
        self.speak_font = pygame.font.Font(
            os.path.join('rec', 'font', 'freesansbold.ttf'), 30)

        # load the map that player is on
        self.INSIDE = 0
        self.blit_list = mapLoader.load('home', self)

        # spawn initial map items/entities
        self.Item(self, 'Mythril', [350, 400], world=1)
        self.NPC(self, "blacksmith", [400, 400], 100, 'still')
        for i in xrange(4):
            self.Monster(self, 'chicken', [200 + (i * 50), 650], 1, 'neutral')
        self.Monster(self, "goop", [100, 100], 1, 'aggressive')

        # begin main game loop
        while 1:
            self.Loop()