source: rc/puzzlebox_brainstorms_client_interface_button.py @ 19

Last change on this file since 19 was 19, checked in by sc, 12 years ago

configuration:

  • interface settings updates and fixes

client_interface_button:

  • activated button drawing added

client_interface:

  • activated button drawing added
  • background drawing added

client_interface_component:

  • whitespace cleanup
File size: 2.6 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Client Interface - Button
5#
6# Copyright Puzzlebox Productions, LLC (2010)
7#
8# Portions of this code have been previously
9# released under the GNU Pulic License (GPL) version 2
10# and is Copyright Steven M. Castellotti (2010)
11# For more information please refer to http://www.gnu.org/copyleft/gpl.htm
12#
13# Last Update: 2010.02.01
14#
15#####################################################################
16
17import puzzlebox_brainstorms_client_interface_component as component
18
19#####################################################################
20# Classes
21#####################################################################
22
23class puzzlebox_brainstorms_client_interface_button( \
24   component.puzzlebox_brainstorms_client_interface_component):
25       
26        def __init__(self, pygame, screen, \
27                           button_image, \
28                           activated_image, \
29                           x, \
30                           y, \
31                           command, \
32                           DEBUG = 0):
33               
34                self.pygame = pygame
35                self.screen = screen
36                self.button_image = button_image
37                self.DEBUG = DEBUG
38               
39                self.button_image = self.load_image(button_image)
40                self.activated_image = self.load_image(activated_image)
41               
42                self.position = (x, y)
43               
44                self.x = self.button_image.get_rect()[2]
45                self.y = self.button_image.get_rect()[3]
46               
47                self.display_position = self.position
48               
49                # display the button graphic centered over the
50                # coordinates instead of to the lower-right
51                #self.display_position = (self.position[0] - (self.x / 2), \
52                                         #self.position[1] - (self.y / 2))
53               
54                self.rect = self.button_image.get_rect()
55                self.rect[0] = self.position[0]
56                self.rect[1] = self.position[1]
57               
58               
59                self.command = command
60               
61                self.hits = 0
62               
63                self.activated = False
64               
65                self.display()
66       
67       
68        #####################################################################
69       
70        def display(self):
71               
72                if not self.activated:
73                        self.draw_image(self.button_image, self.display_position)
74                       
75                else:
76                        self.draw_image(self.activated_image, self.display_position)
77       
78       
79        #####################################################################
80       
81        def check_collision(self, target_rect):
82               
83                collision = self.rect.colliderect(target_rect)
84               
85                if collision:
86                        self.hits = self.hits + 1
87               
88               
89                return(collision)
90
91
92#####################################################################
93# Functions
94#####################################################################
95
96#####################################################################
97# Main
98#####################################################################
99
100if __name__ == '__main__':
101
102        pass
103
Note: See TracBrowser for help on using the repository browser.