Update TODO.
[tabakrolletjie.git] / tabakrolletjie / cursor.py
1
2 import pygame.mouse
3 import pygame.sprite
4
5 from .loader import loader
6
7
8 class Cursor(pygame.sprite.Sprite):
9
10     def __init__(self):
11         super(Cursor, self).__init__()
12         self._active = False
13
14     def activate(self, name, group, transform=None):
15         if transform:
16             self.image = loader.load_image('cursors', name + '.png',
17                                            transform=transform)
18         else:
19             self.image = loader.load_image('cursors', name + '.png')
20         self.rect = self.image.get_rect()
21         self._active = True
22         group.empty()
23         group.add(self)
24         pygame.mouse.set_visible(0)
25
26     def deactivate(self, group):
27         self._active = False
28         pygame.mouse.set_visible(1)
29         group.empty()
30
31     def update(self):
32         if self._active:
33             self.rect.center = pygame.mouse.get_pos()