Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-08-24 22:24:32 (GMT)
committer Manuel Kaufmann <humitos@gmail.com>2012-08-25 15:33:22 (GMT)
commit6fe4d2c4217fd547b9729e5461cb7fe831bf8ad1 (patch)
treea52fa1f1485b1f37035824cd8325e243ebd8dc89
parentb5296d47ca1d1d7d75a55472bd7053504c1e5311 (diff)
Use profile colors for the ball
I modified some variable names before pushing the patch sent by Agustin. Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rwxr-xr-xgame.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/game.py b/game.py
index e57926f..26d6108 100755
--- a/game.py
+++ b/game.py
@@ -4,7 +4,19 @@ import pygame
import random
from gi.repository import Gtk
-BALL_COLOR = 255, 255, 255
+from sugar3.graphics.style import Color
+from sugar3 import profile
+
+def get_profile_colors():
+ profile_color = profile.get_color()
+ fill = Color(profile_color.get_fill_color()).get_rgba()
+ stroke = Color(profile_color.get_stroke_color()).get_rgba()
+
+ fill = [i * 255 for i in fill]
+ stroke = [i * 255 for i in stroke]
+ return fill, stroke
+
+BALL_COLOR_FILL, BALL_COLOR_STROKE = get_profile_colors()
GROUND_COLOR = 0, 0, 0
BACKGROUND_COLOR = 180, 180, 180
BALL_SIZE = 20
@@ -55,7 +67,10 @@ class Ball(object):
self._y += vy
def draw(self, surface):
- pygame.draw.circle(surface, BALL_COLOR, (self._x, self._y), BALL_SIZE)
+ pygame.draw.circle(surface, BALL_COLOR_STROKE, (self._x, self._y),
+ BALL_SIZE)
+ pygame.draw.circle(surface, BALL_COLOR_FILL, (self._x, self._y),
+ BALL_SIZE - 3)
class Level(object):
@@ -105,7 +120,8 @@ class Level(object):
pygame.draw.rect(surface, GROUND_COLOR, rect)
# draw hole:
- pygame.draw.circle(surface, BALL_COLOR, self._ball_end, BALL_SIZE, 2)
+ pygame.draw.circle(surface, BALL_COLOR_FILL,
+ self._ball_end, BALL_SIZE, 2)
class TiltGame(object):