Exemple #1
0
 def __init__(self, pos, sheet, frame_width):
     SpriteBase.__init__(self, pos)
     self._sheet = pygame.image.load(resource_path(sheet)).convert_alpha()
     self._frame_width = frame_width
     self._frame = 0
     self._angle = 0
     self._update_image()
Exemple #2
0
 def __init__(self,
              pos,
              text,
              size,
              onclick,
              image_path=None,
              label=None,
              icon=None,
              color=PICO_BLUE,
              asset_border=False,
              fixed_width=None):
     SpriteBase.__init__(self, pos)
     self.color = color
     self.text = text
     self.size = size
     self.fixed_width = fixed_width
     self.onclick_callback = onclick
     self.selectable = True
     self.image_path = image_path
     self.label = label
     self.icon = icon
     self.joy_button = None
     self.radius = 15
     self.asset_border = asset_border
     self.disabled = False
     self._generate_image()
Exemple #3
0
 def __init__(self, pos, text, size, onclick):
     SpriteBase.__init__(self, pos)
     self.color = PICO_WHITE
     self.text = text
     self.size = size
     self.onclick = onclick
     self.selectable = True
     self._generate_image()
Exemple #4
0
 def __init__(self, pos, meter_width, min, max):
     SpriteBase.__init__(self, pos)
     self.meter_width = meter_width
     self.min = min
     self.max = max
     self.value = self.min
     self.selectable = True
     self._generate_image()
Exemple #5
0
 def __init__(self, pos, gridsize=20, size=None):
     SpriteBase.__init__(self, pos)
     self.gridsize = gridsize
     self.time = 0
     self.stars = []
     self.size = size or game.RES
     for i in range(90):
         self.stars.append(
             (random.randint(0,
                             game.RES[0]), random.randint(0, game.RES[1])))
     self._generate_image()
Exemple #6
0
    def __init__(self, pos, width, height, color, max_value):
        SpriteBase.__init__(self, pos)
        self.stay = False
        self.stay_time = 0

        self.meter_width = width
        self.meter_height = height
        self.color = color
        self.max_value = max_value

        self._value = 0
        self._generate_image()
Exemple #7
0
 def __init__(self, pos, icon, text, color):
     SpriteBase.__init__(self, pos)
     if icon:
         self.icon = pygame.image.load(resource_path(icon)).convert_alpha()
     else:
         self.icon = None
     self.text = text
     self.color = color
     self.offset = (0.5,0.5)
     self._generate_image()
     self.time = 0
     self.layer = -1
Exemple #8
0
 def __init__(self, pos, target, shooter, vel=None, mods=None):
     SpriteBase.__init__(self, pos)
     self.target = target
     self.shooter = shooter
     self.owning_civ = self.shooter.owning_civ
     self.collidable = True
     self.collision_radius = 2
     self.mods = mods or {}
     if vel:
         self.vel = vel
     else:
         self.vel = (self.get_target_pos() - self.pos).normalized() * VEL
     self.offset = (0.5, 0.5)
     self.time = 0
     self._generate_image()
Exemple #9
0
    def __init__(self, pos, width, height, color, max_value, tick_x=None):
        SpriteBase.__init__(self, pos)
        self.stay = False
        self.stay_time = 0

        self.flash_time = 0

        self.meter_width = width
        self.meter_height = height
        self.color = color
        self.max_value = max_value

        self._value = 0
        self._apparent_value = 0
        self.tick_x = tick_x
        self._generate_image()
Exemple #10
0
 def __init__(self, pos, icon, text, color):
     SpriteBase.__init__(self, pos + V2(0, -2))
     if icon:
         try:
             self.icon = pygame.image.load(
                 resource_path(icon)).convert_alpha()
         except:
             print("BAD ICON: %s" % icon)
             self.icon = None
     else:
         self.icon = None
     self.text = text
     self.color = color
     self.offset = (0.5, 0.5)
     self._generate_image()
     self.time = 0
     self.layer = -1
Exemple #11
0
 def __init__(self,
              pos,
              meter_width,
              min,
              max,
              onchange=None,
              value=None,
              disabled=False,
              disable_nums=None):
     SpriteBase.__init__(self, pos)
     self.meter_width = meter_width
     self.min = min
     self.max = max
     self.disabled = disabled
     if value is None: self.value = self.min
     else: self.value = value
     self.selectable = True
     self.onchange = onchange
     self.disable_nums = []
     if disable_nums:
         self.disable_nums = disable_nums
     self._generate_image()
Exemple #12
0
 def __init__(self, pos, data):
     SpriteBase.__init__(self, pos)
     self.data = data
     self._generate_image()
Exemple #13
0
 def __init__(self):
     SpriteBase.__init__(self, V2(0, 0))
     self._layer = -1
Exemple #14
0
 def __init__(self, pos):
     SpriteBase.__init__(self, pos)
     self._generate_image()
Exemple #15
0
 def __init__(self, object):
     self.object = object
     SpriteBase.__init__(self, object.pos)
     self.offset = (0.5, 0.5)
     self._generate_image()
Exemple #16
0
 def __init__(self, a, b):
     SpriteBase.__init__(self, a.pos)
     self.obj_a = a
     self.obj_b = b
     self._timers['off'] = 0
     self._generate_image()
Exemple #17
0
 def __init__(self, start, end, color):
     self.pt1 = ptmin(start, end)
     self.pt2 = ptmax(start, end)
     self.color = color
     SpriteBase.__init__(self, self.pt1)
     self._generate_image()
Exemple #18
0
    def __init__(self,
                 pos,
                 offered_upgrades,
                 resource,
                 on_select,
                 on_reroll,
                 is_new_roll=False):
        Panel.__init__(self, pos, None)
        self.resource = resource
        self.padding = 15
        self.tab = {
            "text": "Upgrade: %s" % self.resource.title(),
            "color": economy.RESOURCE_COLORS[self.resource],
            "icon": "assets/i-upgrade.png"
        }
        self.tree_children = []

        self.iron_border = pygame.image.load(
            resource_path("assets/upgrade-border-iron.png")).convert_alpha()
        self.ice_border = pygame.image.load(
            resource_path("assets/upgrade-border-ice.png")).convert_alpha()
        self.gas_border = pygame.image.load(
            resource_path("assets/upgrade-border-gas.png")).convert_alpha()

        self.add(
            Text("Pick Your Upgrade", "big", V2(0, 0), multiline_width=250),
            V2(0, 0))
        self.header_ys = []
        self.header_xs = []

        is_new_roll = is_new_roll

        y = 30

        # need fn for closure
        def add_button(uname, button_id):
            u = upgrades.UPGRADE_CLASSES[uname]
            time = -button_id * 0.3 - 0.75
            if not is_new_roll:
                time = 0
            b = UpgradeButton(V2(0, 0),
                              u,
                              lambda: on_select(u),
                              self.hover_update,
                              time=time)
            self.add(b, V2(0, y + 12))
            return b

        cts = {
            'ships': 'Order Ships',
            'buildings': 'Construct Building',
            'tech': 'Research Technology'
        }

        order = ['ships', 'buildings', 'tech']

        for i, category in enumerate(order):
            uname = offered_upgrades[category]
            self.header_ys.append(y + 7)
            t = Text(cts[category],
                     "small",
                     V2(0, 0),
                     upgrades.UPGRADE_CATEGORY_COLORS[category],
                     multiline_width=150)
            self.add(t, V2(10, y))

            self.header_xs.append(t.width + 10 + 2)
            if uname:
                b = add_button(uname, i)

                if category in ['buildings', 'tech']:
                    r = Rectangle(V2(0, 0), (40, 10), PICO_YELLOW)
                    self.add(r, V2(194, y + 8))
                    t2 = Text("+1 Supply", "tiny", V2(0, 0), PICO_BLACK)
                    self.add(t2, V2(196, y + 5))

                y += 25 + b.height
                if i == 0:
                    y += 10
            else:
                y += 20

        box = SpriteBase(V2(0, 0))
        box._width = 80
        box.visible = False
        self.add(box, V2(250, 0))

        self.joystick_controls = []
        self.joystick_controls.extend(
            [[c] for c in self.get_controls_of_type(UpgradeButton)])

        if game.Game.inst.run_info.rerolls > 0:  # or game.DEV:
            self.add(
                Button(V2(0, 0),
                       "%d left" % game.Game.inst.run_info.rerolls,
                       "small",
                       on_reroll,
                       icon="assets/die.png",
                       label="REROLL"), V2(0, y + 10))
            self.joystick_controls.append([self.get_control_of_type(Button)])

        self.redraw()
Exemple #19
0
 def __init__(self):
     SpriteBase.__init__(self, V2(0, 0))
     self._layer = -1
     self.last_end = None
     sound.play("short3")