-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_map_old.py
42 lines (27 loc) · 944 Bytes
/
game_map_old.py
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
39
40
41
42
'''
Created on 2 okt. 2015
@author: danhe
'''
from kivy.uix.widget import Widget
from game_sprite import Sprite
class World(Widget):
def __init__(self,map_file):
super(World,self).__init__()
self.sprite = Sprite(source=map_file)
self.size = self.sprite.size
self.offset = [0,0]
self.id = 'test'
self.add_widget(self.sprite)
return
def update(self):
self.sprite.x = self.offset[0]
self.sprite.y = self.offset[1]
for child in self.children:
if child.id == 'sprite':
continue
child.update()
def on_touch_move(self, touch):
if touch.button == 'right':
self.offset[0] += touch.dsx*self.size[0]
self.offset[1] += touch.dsy*self.size[1]
return