コード例 #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))
コード例 #2
0
    def update_player_inventory_gui(self, player_inventory):
        radios = []
        for item in player_inventory: 
            name     = item
            newDesc  = item + " x " + str(player_inventory[item][0])
            radios.append(InventoryRadio(group="player", label=newDesc, item_name=name, item_object=player_inventory[item][1], stats_label=self.stats))
        
        if self.player_radio_box: 
            self.player_radio_box.remove()

        self.player_radios = radios
        if radios != []: # if inventory is empty, do nothing
            self.player_radio_box = sgc.VBox(widgets=radios, pos=(40,40+40))       
            self.player_radio_box.add(order=2) 
コード例 #3
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))
コード例 #4
0
 def update_stats(self):
     self.health_label.config(text="Current Health: " + str(self.player.player_model.current_health) + " / " + str(self.player.player_model.health_capacity), font=pg.font.SysFont("Arial", 20))
     self.strength_label.config(text="Strength: " + str(self.player.player_model.strength),font=pg.font.SysFont("Arial", 20))
     self.money_label.config(text="Money: " + str(self.player.player_model.money), font=pg.font.SysFont("Arial", 20))
     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))
コード例 #5
0

btn_dialog = BtnDialog(label="Dialog", pos=(460, 200))
btn_dialog.add()

box_btn = sgc.HBox(widgets=[button, btn_menu, btn_dialog], spacing=70)

scroll_box = sgc.ScrollBox((300, box_btn.rect.h), widget=box_btn)
scroll_box.rect.center = screen.rect.center
scroll_box.add(order=1)

# Radio Buttons
radio1 = sgc.Radio(group="group1", label="Option 1", active=True)
radio2 = sgc.Radio(group="group1", label="Option 2")
radio3 = sgc.Radio(group="group1", label="Option 3")
radio_box = sgc.VBox(widgets=(radio1, radio2, radio3), pos=(40, 320))
radio_box.add(order=2)

# Toggle Button
switch = sgc.Switch(label="Switch", pos=(200, 320))
switch.add(order=3)

# Scale widget
scale = sgc.Scale(pos=(50, 400), show_value=4)
scale.add(order=4)

# Combo box
combo = sgc.Combo(pos=(400, 400), values=("Option 1", "Option 2", "Another"))
combo.add(order=5)

# Selectable Label
コード例 #6
0
                  label="weapons",
                  values=weapons,
                  label_side="bottom",
                  selection=0,
                  label_font=font3,
                  label_col=(0, 255, 255))

btn2.gun_type = "pistol"

### Radio Box
radio1 = sgc.Radio(label="Forest", group="Map", active=True)
radio2 = sgc.Radio(label="Ocean", group="Map")
radio3 = sgc.Radio(label="Castle", group="Map")
radio_box = sgc.VBox(pos=(10, 100),
                     widgets=[radio1, radio2, radio3],
                     label="Map",
                     label_side="top",
                     label_font=font3,
                     label_col=(0, 255, 0))

### Switch Button
switch = sgc.Switch(pos=(250, 150),
                    label="limit bullets",
                    label_side="top",
                    label_font=font3,
                    label_col=(255, 50, 0))

btn.add(0)
combo.add(1)
btn2.add(2)
radio_box.add(3)
switch.add(4)
コード例 #7
0
ファイル: main.py プロジェクト: KaiyoteSoft/GUI-Practice
combo = MapBox(pos = (250, 100), values = ("Forest", "Ocean", "Castle"),
               selection = 0)

#### radio button
radio_1 = sgc.Radio(label = "Pistol",
                    group = "weapon", active = True,
                    label_side = "right")

radio_2 = sgc.Radio(label = "Shotgun",
                    group = "weapon")

radio_3 = sgc.Radio(label = "Sniper",
                    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))