def on_show(self): travel_trail_button = ActionButton(self.button_handler, self.center_x, self.center_y, 300, 40, 'Travel the trail', name='travel_trail_button', font_color=arcade.color.WHITE) learn_more = ActionButton(self.button_handler, self.center_x, self.center_y - 55, 300, 40, 'learn more', name='learn_more', font_color=arcade.color.WHITE) quit_button = ActionButton(self.button_handler, self.center_x, self.center_y - 110, 100, 40, 'Quit', name='quit', font_color=arcade.color.WHITE) self.button_list.append(travel_trail_button) self.button_list.append(learn_more) self.button_list.append(quit_button)
def on_show(self): #like setup def travel(btn): self.done_handler({"id": "main_menu", "action": "travel"}) def check(): print('check') def look(): print('Look') def pace(): print('Pace') def rations(): print('rations') def rest(): print('rest') def trade(): print('trade') def hunt(btn): self.done_handler({"id": "main_menu", "action": "hunt"}) def buy(): print('buy') menu_actions = [ travel, check, look, pace, rations, rest, trade, hunt, buy ] menu_items = [ "Travel the Trail", "Check Supplies", "Look at map", "Change Pace", "Change Rations", "Stop to Rest", "Attempt to trade", "Hunt", "Buy Supplies" ] l = len(menu_actions) shift = 40 for i in range(l - 5): button = ActionButton(menu_actions[l - i - 1], 900 + shift, (180 + 80 * i), 300, 50, menu_items[l - i - 1], 30, "Arial", arcade.color.WHITE) self.button_list.append(button) for i in range(l - 5, l - 1): button = ActionButton(menu_actions[l - i - 1], 450 + shift, (-140 + 80 * i), 300, 50, menu_items[l - i - 1], 30, "Arial", arcade.color.WHITE) self.button_list.append(button) button = ActionButton(menu_actions[0], 675 + shift, (500), 300, 50, menu_items[0], 30, "Arial", arcade.color.WHITE) self.button_list.append(button)
def on_show(self): #to set up view def banker(btn): self.done_handler({ "id": "char_creation", "action": "banker", "starting_funds": 1600 }) def carpenter(btn): self.done_handler({ "id": "char_creation", "action": "carpenter", "starting_funds": 800 }) def farmer(btn): self.done_handler({ "id": "char_creation", "action": "farmer", "starting_funds": 400 }) menu_actions = [banker, carpenter, farmer] menu_items = ["Banker", "Carpenter", "Farmer"] shift = 200 #px that each button is shifted for i in range(len(menu_actions)): button = ActionButton(menu_actions[i], 150, 600 - shift * i, 200, 50, menu_items[i], 20, "Arial", arcade.color.WHITE) self.button_list.append(button)
def on_show(self): """Sets up the continue button for the page before draw""" def proceed(btn): self.done_handler({"id": "general_store", "action": "go_to_store"}) button = ActionButton(proceed, 600, 200, 200, 50, "Continue", 20, "Arial", arcade.color.WHITE) self.button_list.append(button)
def on_show(self): def leaving(btn): self.done_handler({ "id": "general_store", "action": "head_to_trail" }) def oxen(btn): self.done_handler({"id": "general_store", "action": "buy_oxen"}) def food(btn): self.done_handler({"id": "general_store", "action": "buy_food"}) def clothing(btn): self.done_handler({ "id": "general_store", "action": "buy_clothing" }) def ammunition(btn): self.done_handler({"id": "general_store", "action": "buy_ammo"}) def wheel(btn): self.done_handler({"id": "general_store", "action": "buy_wheel"}) def axle(btn): self.done_handler({"id": "general_store", "action": "buy_axle"}) def tongue(btn): self.done_handler({"id": "general_store", "action": "buy_tongue"}) action_array = [oxen, food, clothing, ammunition, wheel, axle, tongue] l = len(self.store_items) for i in range(l): button = ActionButton(action_array[l - i - 1], 450, (180 + 80 * i), 200, 50, self.store_items[l - i - 1], 20, "Arial", arcade.color.WHITE) self.button_list.append(button) button = ActionButton(leaving, 700, 100, 400, 50, "Exit Store", 30, "Arial", arcade.color.WHITE) self.button_list.append(button)
def on_show(self): """Updating the view 60/sec with the string that user types""" def buying(btn): substring = self.ss[-10:] self.quantity = int(re.sub('[^0-9]', '', substring)) print( f"buying {self.quantity} {self.item_to_buy} for {self.quantity * self.cost}" ) self.done_handler({ "id": "general_store", "action": "finish_transaction", "item": self.item_to_buy, "quantity": self.quantity, "cost": (self.quantity * self.cost) }) button = ActionButton(buying, 700, 250, 500, 50, f"Purchase Entered Quantity", 30, "Arial", arcade.color.WHITE) self.button_list.append(button)
def on_show(self): # def leaving(btn): # exit() def march(btn): self.done_handler({ "id": "opening_menu", "action": "decide_month", "month": "March" }) def april(btn): self.done_handler({ "id": "opening_menu", "action": "decide_month", "month": "April" }) def may(btn): self.done_handler({ "id": "opening_menu", "action": "decide_month", "month": "May" }) def june(btn): self.done_handler({ "id": "opening_menu", "action": "decide_month", "month": "June" }) action_array = [march, april, may, june] months = ["March", "April", "May", "June"] for i in range(4): button = ActionButton(action_array[i], 700, (180 + 80 * i), 200, 50, months[i], 30, "Arial", arcade.color.WHITE) self.button_list.append(button)