-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplanet.py
61 lines (48 loc) · 1.72 KB
/
planet.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# KIVY
from kivy.uix.image import Image
from kivy.properties import *
from kivy.uix.floatlayout import FloatLayout
from kivy.app import App
'''
this widget is used to show planets in the gamezone
'''
class Planet(FloatLayout):
base_image = ObjectProperty(None)
select_overlay = ObjectProperty(None)
# TODO: complete this!?
shadow_overlay = ObjectProperty(None)
# LOGIC
logic = ObjectProperty(None)
def __init__(self, **kwargs):
super(Planet, self).__init__(**kwargs)
self.logic = App.get_running_app().logic
self.size = (100, 100)
# TODO: better way to acquire default textures paths
self.base_image = Image(
size_hint=(1, 1),
pos_hint={'x': 0, 'y': 0},
source='./media/textures/planets/sandyone.png',
allow_stretch=True
)
self.select_overlay = Image(
size_hint=(1.25, 1.25),
pos_hint={'x': -0.125, 'y': -0.125},
source='./media/textures/picked/scope.png',
allow_stretch=True
)
self.add_widget(self.base_image)
def on_size(self, instance, value):
if self.base_image:
self.base_image.size = value
if self.select_overlay:
newsize = (self.base_image.size[0] * 1.5, self.base_image.size[1] * 1.5)
self.select_overlay.size = newsize
self.select_overlay.center = self.center
def select(self):
self.select_overlay.center = self.center
self.add_widget(self.select_overlay)
def unselect(self):
self.remove_widget(self.select_overlay)
def set_base_image(self, source):
self.base_image.source = source
self.base_image.reload()