Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmiliano <emiliano@emiliano-lap.(none)>2010-09-26 04:23:47 (GMT)
committer Emiliano <emiliano@emiliano-lap.(none)>2010-09-26 04:23:47 (GMT)
commit947a5a2b6bafc973eed1bea50191a1e7d90bb314 (patch)
treeed1513140c767f8f4e258a27d3491d3bb5b49f37
parentfcf8e5fb50cae5b8ca2050b2113edc492f7c94e0 (diff)
Cambios:
*renombre menucretor -> menuCreator * statusbar -> statusBars *Se agrego una BarWindow a la MainWindow Agregados: *BarWindo, ventana con un conjunto de BarSection *BarSection, clase que representa el área donde se muestra un conjunto de barras. *ScoreSection, sección donde se muestra la barra de puntaje y el nivel actual. *BarDisplay, representa visualmente a una barra de estado.
-rwxr-xr-xSaludame.activity/menuCreator.py (renamed from Saludame.activity/menucreator.py)0
-rwxr-xr-xSaludame.activity/statusBars.py (renamed from Saludame.activity/statusbars.py)78
-rwxr-xr-xSaludame.activity/window.py18
3 files changed, 76 insertions, 20 deletions
diff --git a/Saludame.activity/menucreator.py b/Saludame.activity/menuCreator.py
index 428a9db..428a9db 100755
--- a/Saludame.activity/menucreator.py
+++ b/Saludame.activity/menuCreator.py
diff --git a/Saludame.activity/statusbars.py b/Saludame.activity/statusBars.py
index 4d54df6..4271a30 100755
--- a/Saludame.activity/statusbars.py
+++ b/Saludame.activity/statusBars.py
@@ -1,30 +1,37 @@
# -*- coding: utf-8 -*-
import pygame
-import window
-from window import StatusBar
"""
****************** VISUALES ******************
"""
-class BarsWindow(window.Window):
+class BarsWindow():
- def __init__(self, rect, frame_rate, background_color):
- self.rect = pygame.Rect((0, 0), (400, 450))
+ def __init__(self, position, frame_rate, background_color):
+
self.frame_rate = frame_rate
+
+ #rect and surface:
+ self.rect = pygame.Rect(position, (400, 501))
self.surface = pygame.Surface(self.rect.size)
self.background_color = background_color
self.surface.fill(self.background_color)
+ #bars
loader = BarsLoader()
-
self.bars = loader.create_bars(Bar("main_bar", "overall", None, [], 100, 50))
- self.physica_section = BarSection("physica", self.bars[0], self.bars[0].children_list, (398, 68), (1, 39))
- self.fun_section = BarSection("fun", self.bars[3], self.bars[3].children_list, (398, 73), (1, 108))
- self.hygiene_section = BarSection("hygiene", self.bars[1], self.bars[1].children_list, (398, 94), (1, 182))
- self.nutrition_section = BarSection("nutrition", self.bars[2], self.bars[2].children_list, (398, 172), (1, 277))
- self.main_section = BarSection("overall", self.bars[4], [] , (398, 37), (1, 1))
+ #sections:
+ self.physica_section = BarSection("physica", self.bars[0], self.bars[0].children_list, (398, 68), (1, 90))
+ self.fun_section = BarSection("fun", self.bars[3], self.bars[3].children_list, (398, 73), (1, 159))
+ self.hygiene_section = BarSection("hygiene", self.bars[1], self.bars[1].children_list, (398, 94), (1, 233))
+ self.nutrition_section = BarSection("nutrition", self.bars[2], self.bars[2].children_list, (398, 172), (1, 328))
+ self.overall_section = BarSection("Estado general", self.bars[4], [] , (398, 37), (1, 52))
+ self.score_section = ScoreSection(Bar("score_bar", "score", None, self.bars[4], 100, 15), (398, 50), (1, 1), 1)
+
+ self.sections_list = [self.score_section, self.physica_section, self.fun_section, self.hygiene_section, self.nutrition_section, self.overall_section]
+
+
def draw(self, screen):
self.surface.fill(self.background_color)
@@ -35,12 +42,52 @@ class BarsWindow(window.Window):
changes += self.hygiene_section.draw(self.surface)
changes += self.fun_section.draw(self.surface)
changes += self.nutrition_section.draw(self.surface)
- changes += self.main_section.draw(self.surface)
+ changes += self.overall_section.draw(self.surface)
+ changes += self.score_section.draw(self.surface)
changes += [self.rect]
screen.blit(self.surface, self.rect)
return changes
+
+ def on_mouse_over(self):
+ return
+
+ def on_mouse_out(self):
+ return
+
+ def on_mouse_click(self, (x, y)):
+ for section in self.sections_list:
+ if(section.rect.collidepoint((x, y))):
+ section.on_mouse_click((x, y))
+
+class ScoreSection:
+
+ def __init__(self, bar, size, position, level):
+ self.name = "score section"
+ self.score_bar = bar
+ self.score_bar_display = BarDisplay(26, (size[0] - 2), (1, (size[1] / 2) - 3), self.score_bar)
+ self.rect = pygame.Rect(position, size)
+ self.surface = pygame.Surface(self.rect.size)
+ self.surface.fill((2, 45, 126))
+ #level:
+ self.level = level
+ self.font = pygame.font.Font(None, 20)
+
+
+
+ def draw(self, screen):
+ #draw bar:
+ self.score_bar_display.draw(self.surface)
+
+ #write actual level:
+ level_text = "Nivel: " + str(self.level)
+
+ self.surface.blit(self.font.render(level_text, 1, (255, 0, 0)), (2, 5))
+
+ screen.blit(self.surface, self.rect)
+ return [self.rect]
+
class BarSection:
@@ -73,7 +120,6 @@ class BarSection:
bar_height = int((self.rect.height / qty) - 2)
bar_width = int(self.rect.width - 2)
display_list = []
- print bar_height
y = int(self.rect.height / bar_height) # margen vertical
for status_bar in children_bar:
@@ -83,6 +129,9 @@ class BarSection:
return display_list
+ def on_mouse_click(self, (x, y)):
+ self.selected = not self.selected
+
class BarDisplay:
def __init__(self, height, width, position, status_bar):
@@ -121,7 +170,7 @@ class BarsController:
a una barra especifica
"""
def __init__(self):
- self.main_bar = StatusBar("main_bar", None, [], 100, 50)
+ #self.main_bar = StatusBar("main_bar", None, [], 100, 50)
self.second_level_bar = BarsLoader.create_bars()
self.main_bar.children_list = self.second_level_bar
third_level_bar = []
@@ -222,3 +271,4 @@ class BarsLoader:
#displays_list = [BarDisplay(pygame.Rect((0 , 0), (200, 26)), pygame.Color(255, 0, 0, 1), bar) for bar in bars_list]
return bars_list
+
diff --git a/Saludame.activity/window.py b/Saludame.activity/window.py
index aad9aaa..033b919 100755
--- a/Saludame.activity/window.py
+++ b/Saludame.activity/window.py
@@ -2,8 +2,9 @@
import pygame
import os
-import menucreator
+import menuCreator
import animation
+import statusBars
BLACK = pygame.Color("black")
BACKGROUND_PATH = os.path.normpath("assets/background/background.png")
@@ -139,20 +140,25 @@ class MainWindow():
self.name = "main"
self.clock = clock
self.windows = [] # Lista de ventanas que 'componen' la ventana principal
- self.windows.append(BlinkWindow(pygame.Rect((700, 0), (500, 140)), 5, pygame.Color("red")))
- self.windows.append(BlinkWindow(pygame.Rect((700, 150), (500, 140)), 5, pygame.Color("blue")))
- self.windows.append(StatusWindow(pygame.Rect((700, 300), (500, 140)), 2, pygame.Color("gray")))
+ #self.windows.append(BlinkWindow(pygame.Rect((700, 0), (500, 140)), 5, pygame.Color("red")))
+ #self.windows.append(BlinkWindow(pygame.Rect((700, 150), (500, 140)), 5, pygame.Color("blue")))
+ #self.windows.append(StatusWindow(pygame.Rect((700, 300), (500, 140)), 2, pygame.Color("gray")))
self.windows.append(KidWindow(pygame.Rect((0, 0), (600, 500)), 1))
self.windows.append(animation.Apple(pygame.Rect((150, 500), (150, 172)), 10))
- self.windows.append(menucreator.load_menu())
+ self.windows.append(menuCreator.load_menu())
self.windows.append(animation.FPS(pygame.Rect((650, 80), (50, 20)), 15, self.clock))
+ self.windows.append(statusBars.BarsWindow((700, 90), 1, pygame.Color("gray")))
def handle_mouse_down(self, (x, y), windows_controller):
# Temporal para probar el manejo de ventanas entre 'challenges' y 'main'
- windows_controller.set_active_window("challenges")
+ #windows_controller.set_active_window("challenges")
+
+ # Temporal para probar BarsWindow
+ self.windows[-1].on_mouse_click((x,y))
def handle_mouse_over(self, (x, y)):
None
def get_windows(self):
return self.windows
+