from kivy.uix.scrollview import ScrollView
from kivy.uix.label import Label
from kivy.uix.popup import Popup
-from kivy.graphics import Color, Rectangle
+from kivy.graphics import Rectangle
from kivy.utils import platform
from kivy.clock import Clock
from kivy.config import Config
self.level_list = level_list
self.level_obj = self.level_list.get_current_level()
self.level_obj.load_tiles()
- self.tiles = {}
self.app = app
cols, rows = self.level_obj.get_size()
self.player.pos = self.level_obj.enter_pos
self.keyboard = None
self._key_bound = False
+ self._background = None
def build(self):
if platform() != 'android' and not self.keyboard:
self._key_bound = True
self.keyboard.bind(on_key_down=self._on_key_down)
self.clear_widgets()
- self.tiles = {}
+ self._background = Widget(size=self.size, pos=(0, 0))
tiles = self.level_obj.get_tiles()
bx, by = 0, 0
for tile_line in tiles:
self.draw_tile((bx, by), tile)
bx += TILE_SIZE
by += TILE_SIZE
+ self.add_widget(self._background)
def draw_tile(self, pos, tile):
- if pos in self.tiles:
- self.remove_widget(self.tiles[pos])
- node = Widget(size=(TILE_SIZE, TILE_SIZE),
- pos=pos, size_hint=(None, None))
- self.add_widget(node)
- with node.canvas:
- Color(1, 1, 1)
- Rectangle(pos=node.pos, size=node.size,
+ with self._background.canvas:
+ Rectangle(pos=pos, size=(TILE_SIZE, TILE_SIZE),
texture=tile.texture)
- self.tiles[pos] = node
def fix_scroll_margins(self):
# We need to call this after app.root is set
self.player_tile = Widget(size=(TILE_SIZE, TILE_SIZE),
pos=sprite_pos)
with self.player_tile.canvas:
- Color(1, 1, 1)
Rectangle(pos=sprite_pos, size=self.player_tile.size,
texture=self.player.get_texture())
self.add_widget(self.player_tile)
self.nemesis_tile = Widget(size=(TILE_SIZE, TILE_SIZE),
pos=sprite_pos)
with self.nemesis_tile.canvas:
- Color(1, 1, 1)
Rectangle(pos=sprite_pos, size=self.nemesis_tile.size,
texture=self.nemesis.get_texture())
self.add_widget(self.nemesis_tile)