From 9d57ae40095b2928672b2f4b23a87b8d5927753e Mon Sep 17 00:00:00 2001 From: flavio Date: Wed, 07 Dec 2011 23:10:50 +0000 Subject: CucaraSims Base --- (limited to 'Interfaz.py') diff --git a/Interfaz.py b/Interfaz.py new file mode 100644 index 0000000..82433ec --- /dev/null +++ b/Interfaz.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Interfaz.py por: +# Flavio Danesse +# CeibalJAM! - Uruguay + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import pygame, gc +from pygame.locals import * + +gc.enable() + +import BiblioJAM +from BiblioJAM.JAMButton import JAMButton +from BiblioJAM.JAMLabel import JAMLabel +import BiblioJAM.JAMGlobals as JAMG + +import Globals as VG + +class Interfaz(pygame.sprite.OrderedUpdates): + def __init__(self): + pygame.sprite.OrderedUpdates.__init__(self) + separador = 10 + self.boton_pan= JAMButton("", VG.PAN) + self.boton_pan.set_imagen(origen= VG.PAN) + ancho_botones= self.boton_pan.get_tamanio()[0] + self.boton_jarra= JAMButton("", VG.JARRA) + self.boton_jarra.set_imagen(origen= VG.JARRA) + + x, y= VG.RESOLUCION[0] - separador - ancho_botones, separador + + self.boton_pan.set_posicion(punto=(x,y)) + y += self.boton_pan.get_tamanio()[1] + separador + self.boton_jarra.set_posicion(punto=(x,y)) + + y += self.boton_jarra.get_tamanio()[1] + separador*2 + self.boton_ciclo= JAMButton("Ciclo Vital", None) + self.boton_ciclo.set_text(tamanio= 20) + self.boton_ciclo.set_tamanios(tamanio= (ancho_botones, 50)) + self.boton_ciclo.set_posicion(punto=(x,y)) + + y += self.boton_ciclo.get_tamanio()[1] + separador + self.boton_muda= JAMButton("Muda", None) + self.boton_muda.set_text(tamanio= 20) + self.boton_muda.set_tamanios(tamanio= (ancho_botones, 50)) + self.boton_muda.set_posicion(punto=(x,y)) + + y += self.boton_muda.get_tamanio()[1] + separador + self.boton_reproduccion= JAMButton("Reproducción", None) + self.boton_reproduccion.set_text(tamanio= 20) + self.boton_reproduccion.set_tamanios(tamanio= (ancho_botones, 50)) + self.boton_reproduccion.set_posicion(punto=(x,y)) + + y += self.boton_reproduccion.get_tamanio()[1] + separador + self.boton_muerte= JAMButton("Muerte", None) + self.boton_muerte.set_text(tamanio= 20) + self.boton_muerte.set_tamanios(tamanio= (ancho_botones, 50)) + self.boton_muerte.set_posicion(punto=(x,y)) + + y += self.boton_reproduccion.get_tamanio()[1] + separador + self.boton_plaga= JAMButton("Plaga", None) + self.boton_plaga.set_text(tamanio= 20) + self.boton_plaga.set_tamanios(tamanio= (ancho_botones, 50)) + self.boton_plaga.set_posicion(punto=(x,y)) + + self.boton_salir= JAMButton("Salir", None) + self.boton_salir.set_text(tamanio= 20) + self.boton_salir.set_tamanios(tamanio= (ancho_botones, 50)) + y = VG.RESOLUCION[1] - separador - self.boton_salir.get_tamanio()[1] + self.boton_salir.set_posicion(punto=(x,y)) + + self.imagenes_audio= VG.ICONOSAUDIO + self.boton_musica= JAMButton("", self.imagenes_audio[0]) + self.boton_musica.set_imagen(origen= self.imagenes_audio[0]) + self.boton_musica.set_tamanios(tamanio= (ancho_botones, 70)) + y -= separador + self.boton_musica.get_tamanio()[1] + self.boton_musica.set_posicion(punto=(x,y)) + self.posicion_boton_audio = (x,y) + + self.boton_extras= JAMButton("Lectura", None) + self.boton_extras.set_text(tamanio= 20) + self.boton_extras.set_tamanios(tamanio= (ancho_botones, 50)) + y -= separador + self.boton_extras.get_tamanio()[1] + self.boton_extras.set_posicion(punto=(x,y)) + + self.add(self.boton_pan) + self.add(self.boton_jarra) + self.add(self.boton_extras) + self.add(self.boton_musica) + self.add(self.boton_salir) + + a,b,c= JAMG.get_estilo_celeste() + self.boton_pan.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_jarra.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_extras.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_musica.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_salir.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_ciclo.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_muda.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_reproduccion.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_muerte.set_colores(colorbas= a, colorbor= b, colorcara= c) + self.boton_plaga.set_colores(colorbas= a, colorbor= b, colorcara= c) + + self.label_pan= JAMLabel("000") + self.label_pan.set_text(tamanio= 25, color= (255,255,255,255)) + self.label_pan.set_imagen(origen= VG.PAN, tamanio= (40, 30)) + self.label_pan.set_contenedor(colorbas= (0,0,0,255)) + self.label_pan.set_posicion( (10,10) ) + self.add(self.label_pan) + + self.label_agua= JAMLabel("000") + self.label_agua.set_text(tamanio= 25, color= (255,255,255,255)) + self.label_agua.set_imagen(origen= VG.AGUA, tamanio= (40, 30)) + self.label_agua.set_contenedor(colorbas= (0,0,0,255)) + x, y= self.label_pan.get_posicion() + w, h= self.label_pan.get_tamanio() + self.label_agua.set_posicion( (x+w+10, y) ) + self.add(self.label_agua) + + self.label_tiempo= JAMLabel("Tiempo de Juego = Años: 0 Dias: 0 Horas: 0") + self.label_tiempo.set_text(tamanio= 25) + x, y= self.label_agua.get_posicion() + w, h= self.label_agua.get_tamanio() + self.label_tiempo.set_posicion( (x+w+10, y) ) + self.add(self.label_tiempo) + + self.informacion_cucas = "Cucarachas: 0, Machos: 0, Hembras: 0, Ootecas: 0, Migración: 0" + self.label_cucas_info= JAMLabel(self.informacion_cucas) + self.label_cucas_info.set_text(tamanio= 25) + x, y= (10, VG.RESOLUCION[1] - 10 - self.label_cucas_info.get_tamanio()[1]) + self.label_cucas_info.set_posicion( (x, y) ) + self.add(self.label_cucas_info) + + def set_pan_en_escenario(self, cantidad): + self.label_pan.set_text(texto= cantidad) + + def set_agua_en_escenario(self, cantidad): + self.label_agua.set_text(texto= cantidad) + + def set_tiempo_de_juego(self, tiempo): + self.label_tiempo.set_text(texto= tiempo) + + def set_informacion_de_habitat(self, bichos): + if self.informacion_cucas != bichos: + self.informacion_cucas= bichos + self.label_cucas_info.set_text(texto= self.informacion_cucas) + -- cgit v0.9.1