Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2011-10-29 02:41:02 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2011-10-29 02:41:02 (GMT)
commit29d829e7b80c2396061d105a2a03728c9b688789 (patch)
treea984f4ee306022f0b03c8d13686cfa69f8edc372
parent61311ed8cf61deb68f4bd0a3f9aa01580ad4930a (diff)
Standard cursor, clean of debug code
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rwxr-xr-xgame.py54
-rwxr-xr-xmy_cursor.xbm22
-rwxr-xr-xmy_cursor_mask.xbm17
3 files changed, 42 insertions, 51 deletions
diff --git a/game.py b/game.py
index a6bec84..4440f33 100755
--- a/game.py
+++ b/game.py
@@ -309,20 +309,6 @@ class Character(object):
self.direction = 'backward'
-class MouseCross(object):
- def __init__(self):
- self._cross = IMAGE_MANAGER.get_image('cross', set_keycolor=True)
- self._pos = None
-
- def update(self, pos):
- self._pos = pos
-
- def draw(self, surface):
- x = self._pos[0] - (self._cross.get_width() / 2)
- y = self._pos[1] - (self._cross.get_height() / 2)
- return surface.blit(self._cross, (x, y))
-
-
class Game(object):
"""Ingenium Machina game"""
def __init__(self, colors=None):
@@ -331,11 +317,7 @@ class Game(object):
self._clock = pygame.time.Clock()
self._background = None
self._char = None
- self._mouse_cross = None
self._click_x = None
- if DEBUG:
- self._pos_cross = None
- self._rect_cross = None
self._colors = colors
if self._colors is not None:
self._convert_colors()
@@ -363,14 +345,6 @@ class Game(object):
self._char.add_action('walk', walk_ani)
self._char.act('stand')
- self._mouse_cross = MouseCross()
-
- if DEBUG:
- self._pos_cross = MouseCross()
- self._rect_cross = MouseCross()
-
- pygame.mouse.set_visible(False)
-
def run(self):
"""Game loop."""
self.setup()
@@ -387,6 +361,9 @@ class Game(object):
self._dirty_rects = []
while self._running:
+ a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
+ pygame.mouse.set_cursor(a, b, c, d)
+
# try to stay at the given frames per second
self._clock.tick(FRAMES_PER_SECOND)
@@ -414,10 +391,6 @@ class Game(object):
elif event.type == pygame.KEYUP:
self._click_x = None
self._char.act('stand')
- elif event.type == pygame.MOUSEMOTION:
- mouse_pos = pygame.mouse.get_pos()
- self._mouse_cross.update(mouse_pos)
-
elif event.type == pygame.MOUSEBUTTONUP:
mouse_pos = pygame.mouse.get_pos()
self._click_x = mouse_pos[0]
@@ -450,31 +423,10 @@ class Game(object):
self._click_x = None
self._char.update()
- if DEBUG:
- self._pos_cross.update((self._char._pos_x, self._char._pos_y))
- ani = self._char._cur_animation
- if ani._mirror:
- data = ani._frames_data_mirror[ani._cur_frame]
- else:
- data = ani._frames_data[ani._cur_frame]
- rect_x = ani._origin[0] + data['delta'][0] + \
- (data['area'].width / 2.0)
- self._rect_cross.update((rect_x, self._char._pos_y))
-
# draw char
rect = self._char.draw(screen)
self._dirty_rects.append(rect)
- if DEBUG:
- rect = self._pos_cross.draw(screen)
- self._dirty_rects.append(rect)
- rect = self._rect_cross.draw(screen)
- self._dirty_rects.append(rect)
-
- # draw mouse cross
- rect = self._mouse_cross.draw(screen)
- self._dirty_rects.append(rect)
-
# update the display
pygame.display.update(self._dirty_rects + self._old_dirty_rects)
diff --git a/my_cursor.xbm b/my_cursor.xbm
new file mode 100755
index 0000000..2ffac88
--- /dev/null
+++ b/my_cursor.xbm
@@ -0,0 +1,22 @@
+#define standardcursor_width 40
+#define standardcursor_height 40
+#define standardcursor_x_hot 0
+#define standardcursor_y_hot 0
+static unsigned char standardcursor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
+ 0xff, 0x3f, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0xff, 0xff,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0xff,
+ 0x3f, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00,
+ 0xfc, 0xff, 0x03, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff,
+ 0x0f, 0x00, 0x00, 0xfc, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0xfb, 0x3f, 0x00,
+ 0x00, 0xfc, 0xf3, 0x7f, 0x00, 0x00, 0xfc, 0xe3, 0xff, 0x00, 0x00, 0xfc,
+ 0xc3, 0xff, 0x01, 0x00, 0xfc, 0x83, 0xff, 0x03, 0x00, 0xfc, 0x03, 0xff,
+ 0x07, 0x00, 0xfc, 0x03, 0xfe, 0x0f, 0x00, 0xfc, 0x03, 0xfc, 0x1f, 0x00,
+ 0xfc, 0x03, 0xf8, 0x3f, 0x00, 0xfc, 0x03, 0xf0, 0x7f, 0x00, 0xfc, 0x03,
+ 0xe0, 0xff, 0x00, 0xfc, 0x03, 0xc0, 0xff, 0x01, 0xfc, 0x03, 0x80, 0xff,
+ 0x01, 0xfc, 0x03, 0x00, 0xff, 0x01, 0xf8, 0x01, 0x00, 0xfe, 0x03, 0xf0,
+ 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; \ No newline at end of file
diff --git a/my_cursor_mask.xbm b/my_cursor_mask.xbm
new file mode 100755
index 0000000..944cf7d
--- /dev/null
+++ b/my_cursor_mask.xbm
@@ -0,0 +1,17 @@
+#define standardcursor_width 40
+#define standardcursor_height 40
+static unsigned char standardcursor_bits[] = {
+ 0xff,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0xff,0x01,0xff,0xff,0xff,0xff,0x03,
+ 0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0x07,
+ 0xff,0xff,0xff,0xff,0x07,0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0x03,
+ 0xff,0xff,0xff,0xff,0x03,0xff,0xff,0xff,0xff,0x01,0xff,0xff,0xff,0xff,0x00,
+ 0xff,0xff,0x3f,0x00,0x00,0xff,0xff,0x7f,0x00,0x00,0xff,0xff,0xff,0x00,0x00,
+ 0xff,0xff,0xff,0x01,0x00,0xff,0xff,0xff,0x03,0x00,0xff,0xff,0xff,0x07,0x00,
+ 0xff,0xff,0xff,0x0f,0x00,0xff,0xff,0xff,0x1f,0x00,0xff,0xff,0xff,0x3f,0x00,
+ 0xff,0xff,0xff,0x7f,0x00,0xff,0xef,0xff,0xff,0x00,0xff,0xcf,0xff,0xff,0x01,
+ 0xff,0x8f,0xff,0xff,0x03,0xff,0x0f,0xff,0xff,0x07,0xff,0x0f,0xfe,0xff,0x07,
+ 0xff,0x0f,0xfc,0xff,0x0f,0xff,0x0f,0xf8,0xff,0x0f,0xff,0x0f,0xf0,0xff,0x0f,
+ 0xff,0x0f,0xe0,0xff,0x0f,0xff,0x0f,0xc0,0xff,0x0f,0xfe,0x07,0x80,0xff,0x07,
+ 0xfc,0x03,0x00,0xff,0x07,0x60,0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0xf8,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00}; \ No newline at end of file