Example #1
0
 def __init__(self, scr):
     self.scr = scr
     self.choices = {"yes": False, "no": False}
     self.txt = Group()
     self.txt.append(Text(scr, "WARNING", 50, 50, 50, WHITE))
     self.txt.append(
         Text(scr, "Deleted data will not be recoverable", 50, 250, 50,
              WHITE))
     self.txt.append(
         Text(scr, "Are you sure you want to delete the saved data?", 50,
              450, 50, WHITE))
     self.yes = Text_Button(scr,
                            "YES",
                            150,
                            550,
                            100,
                            RED,
                            GREEN,
                            resp=lambda: self.change_bool("yes"))
     self.no = Text_Button(scr,
                           "NO",
                           1050,
                           550,
                           100,
                           RED,
                           GREEN,
                           resp=lambda: self.change_bool("no"))
     return
Example #2
0
	def __init__(self, scr, setting, value_range, value, x, y):
		self.current_value = value
		self.setting = setting
		self.setting_value = Text_Button(scr, f"{self.setting}: {self.current_value}", x, y, 50, WHITE, BLACK, resp=self.update_text)
		self.range = value_range
		self.current_index = value_range.index(value)
		return
Example #3
0
	def __init__(self, *args):
		# unpack the args values because I can't be bothered to write all those parameters
		self.game, self.name, self.price, self.value, index, self.level, self.hidden = args
		self.x, self.y = 150 + index * 150, 400 if index < 8 else 610
		self.button = Text_Button(self.game.scr, str(self.price), self.x, self.y, 50, WHITE, DARK_GREEN, resp=self.buy)
		self.level_button = Text(self.game.scr, f"Level {self.level}", self.x, self.y + 50, 30, WHITE)
		self.ava = self.game.unlocked[self.name]
		self.__lock = False
		return
Example #4
0
class Dis:
    def __init__(self, scr):
        self.scr = scr
        self.choices = {"yes": False, "no": False}
        self.txt = Group()
        self.txt.append(Text(scr, "WARNING", 50, 50, 50, WHITE))
        self.txt.append(
            Text(scr, "Deleted data will not be recoverable", 50, 250, 50,
                 WHITE))
        self.txt.append(
            Text(scr, "Are you sure you want to delete the saved data?", 50,
                 450, 50, WHITE))
        self.yes = Text_Button(scr,
                               "YES",
                               150,
                               550,
                               100,
                               RED,
                               GREEN,
                               resp=lambda: self.change_bool("yes"))
        self.no = Text_Button(scr,
                              "NO",
                              1050,
                              550,
                              100,
                              RED,
                              GREEN,
                              resp=lambda: self.change_bool("no"))
        return

    def __getitem__(self, item):
        return self.choices[item]

    def change_bool(self, booly):
        self.choices[booly] = True
        return

    def blit(self):
        self.txt.blit()
        self.yes.blit()
        self.no.blit()
        return

    pass
Example #5
0
class Setting:
	def __init__(self, scr, setting, value_range, value, x, y):
		self.current_value = value
		self.setting = setting
		self.setting_value = Text_Button(scr, f"{self.setting}: {self.current_value}", x, y, 50, WHITE, BLACK, resp=self.update_text)
		self.range = value_range
		self.current_index = value_range.index(value)
		return

	def update_text(self):
		self.current_index = (self.current_index + 1) % len(self.range)
		self.current_value = self.range[self.current_index]
		self.setting_value.update_text(f"{self.setting}: {self.current_value}")
		return

	def blit(self):
		self.setting_value.blit()
		return

	def get_status(self):
		return self.setting, self.current_value
	pass
Example #6
0
class Buy_Button:
	def __init__(self, *args):
		# unpack the args values because I can't be bothered to write all those parameters
		self.game, self.name, self.price, self.value, index, self.level, self.hidden = args
		self.x, self.y = 150 + index * 150, 400 if index < 8 else 610
		self.button = Text_Button(self.game.scr, str(self.price), self.x, self.y, 50, WHITE, DARK_GREEN, resp=self.buy)
		self.level_button = Text(self.game.scr, f"Level {self.level}", self.x, self.y + 50, 30, WHITE)
		self.ava = self.game.unlocked[self.name]
		self.__lock = False
		return

	def __str__(self):
		return f"level: {self.level}, price: {self.price}"

	def blit(self):
		if self.ava:
			self.button.blit()
			self.level_button.blit()
		else:
			self.hidden.blit(self.x, self.y)
		return

	def __update(self):
		# update the text
		self.button.update_text(str(self.price))
		self.level_button.update_text(f"Level {self.level}")
		return

	def lock(self):
		# locking the button prevents IndexOutOfRange Error
		self.__lock = True
		self.price = "MAX"
		return

	def buy(self):
		# prbbly there is a better way but this is fine
		if not self.__lock:
			self.game.buy(self)
		return

	def update(self, game):
		# update the button upon upgrade
		self.level += 1
		if self.level == len(game.values[self.name]):
			self.lock()
		else:
			self.value = game.values[self.name][self.level]
			self.price = game.prices[self.name][self.level]
			self.button.update_text(str(self.price))
		self.__update()
		return
	pass
Example #7
0
 def __init__(self, scr, game):
     self.money = Rect_Text(scr, "0", 10, 10, 50, BLACK, WHITE)
     self.save = Text_Button(scr,
                             "SAVE",
                             700,
                             10,
                             50,
                             BLACK,
                             WHITE,
                             resp=game.save)
     self.load = Text_Button(scr,
                             "LOAD",
                             900,
                             10,
                             50,
                             BLACK,
                             WHITE,
                             resp=game.load)
     self.buy = Text_Button(scr,
                            "BUY",
                            700,
                            100,
                            50,
                            BLACK,
                            WHITE,
                            resp=game.shop)
     self.main = Text_Button(scr,
                             "MAIN",
                             900,
                             100,
                             50,
                             BLACK,
                             WHITE,
                             resp=game.game)
     self.moneys = 0
     return
Example #8
0
class HUD:
    def __init__(self, scr, game):
        self.money = Rect_Text(scr, "0", 10, 10, 50, BLACK, WHITE)
        self.save = Text_Button(scr,
                                "SAVE",
                                700,
                                10,
                                50,
                                BLACK,
                                WHITE,
                                resp=game.save)
        self.load = Text_Button(scr,
                                "LOAD",
                                900,
                                10,
                                50,
                                BLACK,
                                WHITE,
                                resp=game.load)
        self.buy = Text_Button(scr,
                               "BUY",
                               700,
                               100,
                               50,
                               BLACK,
                               WHITE,
                               resp=game.shop)
        self.main = Text_Button(scr,
                                "MAIN",
                                900,
                                100,
                                50,
                                BLACK,
                                WHITE,
                                resp=game.game)
        self.moneys = 0
        return

    # format the money value to look a bit nicer
    def format(self, num):
        out = ""
        # imma need to reverse the number in order to correctly place the ","
        num = num[::-1]
        for i, digit in enumerate(num):
            if i % 3 == 0:
                if i > 0:
                    out += ","
            out += digit
        # reverse the number back so it makes sense
        return out[::-1]

    def update(self, money):
        # I really wish there was a better way to do this
        # nah for loops would be worse
        if self.moneys != str(money):
            self.moneys = str(money)
            self.money.update_text(self.format(str(money)))
        self.money.blit()
        self.save.blit()
        self.load.blit()
        self.buy.blit()
        self.main.blit()
        return

    pass