self._background = Widget(size=self.size, pos=(0, 0))
tiles = self.level_obj.get_tiles()
bx, by = 0, 0
- for tile_line in tiles:
- bx = 0
- for tile in tile_line:
- self.draw_tile((bx, by), tile)
- bx += TILE_SIZE
- by += TILE_SIZE
- self.add_widget(self._background)
-
- def draw_tile(self, pos, tile):
with self._background.canvas:
- Rectangle(pos=pos, size=(TILE_SIZE, TILE_SIZE),
- texture=tile.texture)
+ for tile_line in tiles:
+ bx = 0
+ for tile in tile_line:
+ Rectangle(pos=(bx, by), size=(TILE_SIZE, TILE_SIZE),
+ texture=tile.texture)
+ bx += TILE_SIZE
+ by += TILE_SIZE
+ self.add_widget(self._background)
def fix_scroll_margins(self):
# We need to call this after app.root is set
self.level_obj.trigger_button(self.nemesis.pos)
for map_pos, new_tile in self.level_obj.get_changed_tiles():
pos = (map_pos[0] * TILE_SIZE, map_pos[1] * TILE_SIZE)
- self.draw_tile(pos, new_tile)
+ with self._background.canvas:
+ Rectangle(pos=pos, size=(TILE_SIZE, TILE_SIZE),
+ texture=new_tile.texture)
return False
def _calc_mouse_pos(self, pos):
if self._near_player(pos):
self.mouse_move = True
self.mouse_start = pos
+ return True
def on_touch_up(self, touch):
self.mouse_move = False
pos[1] - self.mouse_start[1])
self.do_move(direction)
self.mouse_start = pos
+ return True
class Screen(Widget):
def on_touch_down(self, touch):
for child in self.children:
- child.on_touch_down(touch)
+ if child.on_touch_down(touch):
+ return True
+ return super(MyScrollView, self).on_touch_up(touch)
def on_touch_up(self, touch):
for child in self.children:
- child.on_touch_up(touch)
+ if child.on_touch_up(touch):
+ return True
+ return super(MyScrollView, self).on_touch_up(touch)
class GameApp(App):