Example #1
0
    def __init__(self, screen, font, player):
        self.active = False

        self.player = player
        self.screen = screen
        self.font   = font
        
        big_image = pg.transform.rotozoom(player.image, 0, 3)
        self.char_img = sgc.Simple(surf=big_image, pos=(self.screen.rect.centerx-160,25))

        self.title = sgc.Label(text="Stats", font=self.font)
        self.title.rect.center = (self.screen.rect.centerx, 40)

        self.name_label = sgc.Label(text="Name: " + player.player_model.name, font=pg.font.SysFont("Arial", 20))
        self.name_label.rect.center = (self.screen.rect.centerx, 80)

        self.health_label = sgc.Label(text="Current Health: " + str(player.player_model.current_health) + " / " + str(player.player_model.health_capacity), font=pg.font.SysFont("Arial", 20))
        self.health_label.rect.center = (self.screen.rect.centerx, 120)

        self.strength_label = sgc.Label(text="Strength: " + str(player.player_model.strength), font=pg.font.SysFont("Arial", 20))
        self.strength_label.rect.center = (self.screen.rect.centerx, 160)

        self.money_label = sgc.Label(text="Money: " + str(player.player_model.money), font=pg.font.SysFont("Arial", 20))
        self.money_label.rect.center = (self.screen.rect.centerx, 200)

        self.stats_box = sgc.VBox(widgets =[self.name_label, self.health_label, self.strength_label, self.money_label], pos=(self.screen.rect.centerx-120, 80))
Example #2
0
    def __init__(self,screen,font, player, trader):
        self.active = False
        self.player = player
        self.trader = trader
        self.screen = screen 
        self.font   = font         
        self.playerTitle = sgc.Label(text="Player Inventory", font=self.font)
        self.playerTitle.rect.center = (self.screen.rect.centerx-100, 40)

        self.traderTitle = sgc.Label(text="Trader Inventory", font=self.font)
        self.traderTitle.rect.center = (self.screen.rect.centerx+100, 40)
        
        self.sell_button = sgc.Button(label="Sell\nItem", pos=(self.screen.rect.centerx-160,300))

        self.buy_button = sgc.Button(label="Buy\nItem", pos=(self.screen.rect.centerx,300))

        self.money_label = sgc.Label(text="Money: " + str(player.player_model.money), font=self.font)
        self.money_label.rect.center = (self.screen.rect.centerx-30, 275)

        self.stats = sgc.Label(text="", font=pg.font.SysFont("Arial", 15))
        self.stats.rect.center = (self.screen.rect.centerx-160, 375)
        self.stats.config(text="")
        self.stats.add()

        self.player_radio_box = None
        self.player_radios    = []

        self.trader_radio_box = None
        self.trader_radios    = []
Example #3
0
    def interactive_mouse_callback(self):
        # note: no collide check is applied at present
        #       it is possible that a new vehicle is chosen to be spawned at a
        #       place where a previous vehicle has been spawned
        while True:

            event = pygame.event.wait()

            if event.type == pygame.MOUSEBUTTONDOWN:
                if pygame.mouse.get_pressed()[0]:
                    mouse = event.pos
                    if mouse[0] > self.left_width and self.map_height > mouse[
                            1] > 0:
                        spawn_point_world_pos = self.local_pixel_to_world(
                            (mouse[0], mouse[1]))
                        self.spawn_x_text.text = str(spawn_point_world_pos[0])
                        self.spawn_y_text.text = str(spawn_point_world_pos[1])
                        # show the position on the map
                        if self.spawn_label != None:
                            self.spawn_label.remove(fade=False)

                        self.spawn_label = sgc.Label(
                            pos=(mouse[0], mouse[1]),
                            text="x: " + str(spawn_point_world_pos[0]) +
                            " y: " + str(spawn_point_world_pos[1]))
                    break
Example #4
0
    def __init__(self, screen, font, player):
        self.active = False
        self.player = player
        self.screen = screen
        self.font   = font
        self.radio_box = None
        self.radios    = []

        self.title = sgc.Label(text="Inventory", font=self.font)
        self.title.rect.center = (self.screen.rect.centerx, 40)

        self.drop_button = sgc.Button(label="Drop\nItem", pos=(self.screen.rect.centerx-160,300))
        self.quit_button = sgc.Button(label="Quit", pos=(self.screen.rect.centerx,300))
        
        self.stats = sgc.Label(text="", font=pg.font.SysFont("Arial", 15))
        self.stats.rect.center = (self.screen.rect.centerx-160, 375)
        self.stats.config(text="")
Example #5
0
 def create_vehicle_panel(self):
     self.vehicle_name_text = sgc.Label(pos=(int(self.left_width / 2), 100))
     self.vehicle_position_x_text = sgc.InputBox(label="x:  ",
                                                 pos=(50, 200),
                                                 label_side="left")
     self.vehicle_position_y_text = sgc.InputBox(label="y:  ",
                                                 pos=(50, 300),
                                                 label_side="left")
     self.vehicle_to_intersection_button = sgc.Button(label="Back",
                                                      pos=(0, 0))
     self.vehicle_to_intersection_button.on_click = self.vehicle_to_intersection_callback
Example #6
0
    def __init__(self, theme):
        self.tags = []
        self.theme = theme
        self.description = sgc.Label(font=sgc.Font["title"])
        self.tag_list = sgc.HBox(theme.footer_size,
                                 border=theme.tag_border,
                                 spacing=theme.tag_padding)

        sgc.VBox.__init__(self,
                          theme.footer_size,
                          pos=theme.footer_pos,
                          col=theme.footer_colour,
                          border=theme.footer_border,
                          widgets=[self.description, self.tag_list])
Example #7
0
    def __init__(self, screen, font, player, enemy):
        self.active = False
        self.player = player
        self.enemy  = enemy
        self.screen = screen
        self.font   = font
        self.title = sgc.Label(text="Battle", font=self.font)

        self.title.rect.center = (self.screen.rect.centerx, 40)

        player_image_zoomed = pg.transform.rotozoom(player.image, 0, 3)
        self.player_img = sgc.Simple(surf=player_image_zoomed, pos=(self.screen.rect.centerx-160,75))

        enemy_image_zoomed = pg.transform.rotozoom(enemy.image, 0, 3)
        self.enemy_img = sgc.Simple(surf=enemy_image_zoomed, pos=(self.screen.rect.centerx+120,75))

        self.player_hp_label = sgc.Label(text="HP: " + str(self.player.player_model.current_health) + " / " + str(self.player.player_model.health_capacity), font=pg.font.SysFont("Arial", 15), pos=(35,130)) 
        self.enemy_hp_label  = sgc.Label(text="HP: " + str(self.enemy.enemy_model.current_health) + " / " + str(self.enemy.enemy_model.health_capacity), font=pg.font.SysFont("Arial", 15), pos=(300,130))
       
        self.attack_option = sgc.Button(label="Attack")
        self.item_option = sgc.Button(label="Item")
        self.retreat_option = sgc.Button(label="Retreat")

        self.attack_options_box = sgc.VBox(widgets =[self.attack_option, self.item_option, self.retreat_option], pos=(10, 180))
Example #8
0
    def __init__(self, text, theme):
        self.label = sgc.Label(text=text, col=theme.tag_text_colour)
        height = self.label.rect.h

        surf = pygame.Surface((height / 2, height), flags=pygame.SRCALPHA)
        pygame.draw.circle(surf, theme.tag_colour, (height / 2, height / 2),
                           height / 2)
        left = sgc.Simple(surf)

        surf = pygame.Surface((height / 2, height), flags=pygame.SRCALPHA)
        pygame.draw.circle(surf, theme.tag_colour, (0, height / 2), height / 2)
        right = sgc.Simple(surf)

        coloured_label = sgc.HBox(widgets=[self.label],
                                  col=theme.tag_colour,
                                  border=0,
                                  spacing=0)

        sgc.HBox.__init__(self,
                          widgets=[left, coloured_label, right],
                          border=0,
                          spacing=0)
Example #9
0
 def update_stats(self):        
     self.money_label.remove()
     self.money_label = sgc.Label(text="Money: " + str(self.player.player_model.money), font=self.font)
     self.money_label.rect.center = (self.screen.rect.centerx-30, 275)
     self.money_label.add()
Example #10
0
screen = sgc.surface.Screen((WINDOWWIDTH, WINDOWHEIGHT), pygame.DOUBLEBUF|0, 32)
pygame.display.set_caption((u"植物大战僵尸学习版").encode('utf-8'))
pygame.display.set_icon(pygame.image.load("images/interface/icon.png"))
background = pygame.image.load(background_image_filename[0]).convert()
yardBackground = pygame.image.load(background_image_filename[1]).convert_alpha()
welcome = pygame.image.load(welcome_image_filename).convert_alpha()
font = pygame.font.Font("other/simsun.ttc",16)
gameOverFont = pygame.font.Font("other/simsun.ttc",60)
text_userName = font.render(u"游客", True, WHITE)
#循环播放背景音乐
pygame.mixer.music.play(-1)
loseSound = pygame.mixer.Sound(music_filenames[1])
evillaughSound = pygame.mixer.Sound(music_filenames[2])

# 以下是自定义对话框中label和button设置
label = sgc.Label(text="unlock!",pos=(160,120),col=WHITE,font=font)
def print_pass():
    dialogs[-1].remove()
btn_ok = sgc.Button("images/interface/LongButton.png",label="ok", pos=(80,210))
btn_ok.on_click = print_pass
dialog_container = sgc.Container(widgets=(label,btn_ok), border=10)
dialogs = []



#开始标志
startflag = False
#添加对话框

startGameButton = sgc.Button(startGame_image_filename,label="", pos=(startGameX,startGameY))
startGameButton.add()
Example #11
0
pygame.display.init()
pygame.font.init()
sys.path.insert(0, "..")
import sgc
from sgc.locals import *
from sgc.__init__ import __version__ as ver_no
######################################################

#screen size, creating clock
screen = sgc.surface.Screen((1280, 720))
clock = pygame.time.Clock()

#elements
# Title
title = sgc.Label(text="Sistema Restaurante ",
                  font=sgc.Font["title"],
                  col=sgc.Font.col)
title.rect.center = (screen.rect.centerx, 40)
title.add()

#buttons
button = sgc.Button(label="Video", pos=(360, 100))
button.add(order=1)

button2 = sgc.Button(label="Cliente", pos=(40, 100))
button2.add(order=1)

button3 = sgc.Button(label="Admin", pos=(200, 100))
button3.add(order=1)

#main
fontOhio = pygame.font.Font("fnt/ohio.ttf", 30)
fontAbove = pygame.font.Font("fnt/above.ttf", 20)
fontLarge = pygame.font.Font("fnt/ohio.ttf", 52)
fontTitle = pygame.font.Font("fnt/painter.ttf", 84)

btn = RestaurantButton(label="Capitola",
                       label_font=fontAbove,
                       label_col=MINT,
                       col=PURPLE,
                       pos=(100, 150))

btn.gameInit()

label = sgc.Label(pos=(20, 240),
                  col=(255, 255, 255),
                  text="",
                  font=fontLarge)

mealChooser = sgc.Combo(
                    pos=(400, 150),
                    label="Meal",
                    label_side="top",
                    values=("breakfast", "lunch", "dinner", "snack"),
                    selection=1)

titleSurface = fontTitle.render("Caitlyn's> Restaurants", True, PURPLE)

btn.add(0)
label.add(1)
mealChooser.add(2)
Example #13
0
    """Create a subclass for custom functions."""

    func_dict = lambda self: {
        "print_input": self.print_input,
        "remove": self.remove
    }

    def print_input(self):
        print self["input"].text


sgc.Font.col = (150, 150, 150)  # TODO Button font colour

# Title
title = sgc.Label(text="Simple Game Code " + ver_no,
                  font=sgc.Font["title"],
                  col=sgc.Font.col)
title.rect.center = (screen.rect.centerx, 40)
title.add()

# Create input_box
input_box = sgc.InputBox(label="Input Box", default="default text...")
input_box.config(pos=(30, 120))
input_box.add()
# Change colour button, on_click event caught in event loop
button = sgc.Button(label="Change\ncolour", pos=(40, 200))
# Create FPS counter
fps = sgc.FPSCounter(clock=clock)
fps.rect.midbottom = (screen.rect.w / 2, screen.rect.h)
fps.add()
# Pass config file as argument, to have Menu parse file
Example #14
0
                    group = "weapon")


radio_box = sgc.VBox(widgets = (radio_1, radio_2, radio_3), pos = (50, 50))

### switch
switch = sgc.Switch(label = "Limit Bullets", pos = (300, 200),
                   label_side = "top")

## slider
slider = sgc.Scale(label = "Number of Monsters", pos = (10, 200),
                   label_side = "top", label_col = (255, 255, 0))

label = sgc.Label(text = "This is a zombie shooter game \n" +
                  "in which you journey through eight \n" +
                  "levels to save a girl from \n" +
                  "monsters. Good Luck!", pos = (10, 10), font = bloody,
                  col = (255, 0, 0))

btn.add(0)
btn2.add(1)
combo.add(2)
radio_box.add(3)
switch.add(4)
slider.add(5)


while True:
    time = clock.tick(30)
    for event in pygame.event.get():
        sgc.event(event)