-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmappane.py
More file actions
38 lines (28 loc) · 1.16 KB
/
mappane.py
File metadata and controls
38 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" The pane in wihcih the main map for the game is generated.
"""
from pane import *
from level import *
# NOTE: this isn't high priority, but later on we might want to store the map
# pane dimensions someplace where it's easier to see the values that they are relative to.
# (i.e., total screen size and whatnot.)
MAP_PANE_X = 40
MAP_PANE_Y = 80
MAP_PANE_WIDTH = 450
MAP_PANE_HEIGHT = 450
class MapPane(Pane):
""" MapPane ( Player ) -> MapPane
A mappane is a GUI component showing the dungeon from the player's point of view (more or less).
Attributes:
player is the player that the map pane is usually centered around.
"""
def __init__(self, player):
Pane.__init__(self, MAP_PANE_X, MAP_PANE_Y, MAP_PANE_WIDTH, MAP_PANE_HEIGHT)
self.player = player
def update(self):
coords = self.player.coordinates()
center_x, center_y = coords[0], coords[1]
half_width, half_height = MAP_PANE_WIDTH/(2 * TILE_WIDTH), MAP_PANE_HEIGHT/(2 * TILE_HEIGHT)
x1, y1 = center_x - half_width, center_y - half_height
x2, y2 = center_x + half_width, center_y + half_height
level_map = self.player.current_level.level_map_section(x1, y1, x2, y2)
Pane.update(self, level_map)