Ejemplo n.º 1
0
class Backend(object):

    def __init__(self, game):
    
        self.game = game
        
        self.current_area = Area(self, TEST_MAP)
        
        self.monster = NPC(self, None)
        self.monster.place(*self.current_area.monster_pos)
                
        self.player = Player(self, None)
        self.player.place(*self.current_area.player_pos)
        
        self.prev_update = datetime.now()
        self.delta = 0
        
        
    def update(self):
        """ TODO: Move the step calculation to the object being updated.
        so... sooo sleepy """
        now = datetime.now()
        delta_micro = (now - self.prev_update).microseconds
        self.delta += (delta_micro / 100000000.0)
        step = 0.5 # of a sec
        while self.delta > step:
            self.delta -= step
            self.prev_update = now
            self.monster.update(step)
        
   
                
    def current_area(self):
        """ TODO: return an Area object? """
        return self.current_area
Ejemplo n.º 2
0
class Backend(object):
    def __init__(self, game):

        self.game = game

        self.current_area = Area(self, TEST_MAP)

        self.monster = NPC(self, None)
        self.monster.place(*self.current_area.monster_pos)

        self.player = Player(self, None)
        self.player.place(*self.current_area.player_pos)

        self.prev_update = datetime.now()
        self.delta = 0

    def update(self):
        """ TODO: Move the step calculation to the object being updated.
        so... sooo sleepy """
        now = datetime.now()
        delta_micro = (now - self.prev_update).microseconds
        self.delta += (delta_micro / 100000000.0)
        step = 0.5  # of a sec
        while self.delta > step:
            self.delta -= step
            self.prev_update = now
            self.monster.update(step)

    def current_area(self):
        """ TODO: return an Area object? """
        return self.current_area
Ejemplo n.º 3
0
    def __init__(self, game):

        self.game = game

        self.current_area = Area(self, TEST_MAP)

        self.monster = NPC(self, None)
        self.monster.place(*self.current_area.monster_pos)

        self.player = Player(self, None)
        self.player.place(*self.current_area.player_pos)

        self.prev_update = datetime.now()
        self.delta = 0
Ejemplo n.º 4
0
    def __init__(self):
        self._title = True
        self.particles = []
        self.story = misc.RollingText(12, 64, STORY)
        levels = [
            level_1(),
            level_2(),
            level_3(),
        ]
        # level = populate_enemies(level)

        self.state = State(
            levels=levels,
            current_level=-1,
            camera=(0, 0),
            player=Player((0, 0), 9000),
        )
        self.state.visited_by_floor = [
            set() for _ in range(len(self.state.levels))
        ]
        self.state.change_level(1)
        # self.state.player.flags.add("teleport")
        # self.state.player.flags.add("wand")
        # self.state.player.flags.add("thunder")
        # self.state.player.flags.add("armor")
        # self.state.player.flags.add("triA")
        # self.state.player.flags.add("triB")
        # self.state.player.flags.add("tri")

        self._draw = partial(draw, self.state)
        self._draw_debug = partial(debug.draw_debug, self.state)

        self._update = partial(update, self.state)
        self._update_debug = partial(debug.update_debug, self.state)
Ejemplo n.º 5
0
 def __init__(self, game):
 
     self.game = game
     
     self.current_area = Area(self, TEST_MAP)
     
     self.monster = NPC(self, None)
     self.monster.place(*self.current_area.monster_pos)
             
     self.player = Player(self, None)
     self.player.place(*self.current_area.player_pos)
     
     self.prev_update = datetime.now()
     self.delta = 0
Ejemplo n.º 6
0
def player():
    return Player(0, 0)
Ejemplo n.º 7
0
def player():
    return Player(x=100, y=102)