I'm trying to make a clicker game, and I'm having trouble calculating the position of upgrade buttons. I have a system that kind of works, but gets a little weird once more than two buttons are on screen at once. The buttons start clipping into each other once I click the first one.
if keter_total >= 1 and has_heart == False: #Upgrade Script
if heart_check == False:
amount_of_upgrades += 1
current_amount_of_passive_heart = amount_of_upgrades
heart_check = True
if current_amount_of_passive_heart == amount_of_upgrades:
placement_heart = 825 + (51 * amount_of_upgrades)
if current_amount_of_passive_heart - amount_of_upgrades == 1:
placement_heart -= 51
if placement_heart < 876:
placement_heart = 876
current_amount_of_passive_heart = amount_of_upgrades
heart_upgrade = Button(placement_heart, 0, keter_passive_1, 1)
if heart_upgrade.draw() and lob >= 100 and cooldown == False:
has_heart = True
amount_of_upgrades -= 1
health_per_minute += 1
lob -= 100
cooldown = True
cooldowntime = time.time()
if keter_total >= 1 and has_soft_clicks == False:
if soft_check == False:
amount_of_upgrades += 1
current_amount_of_passive_soft = amount_of_upgrades
soft_check = True
if current_amount_of_passive_soft == amount_of_upgrades:
placement_soft = 825 + (51 * amount_of_upgrades)
if current_amount_of_passive_soft - amount_of_upgrades == 1:
placement_soft -= 51
if placement_soft < 876:
placement_soft = 876
current_amount_of_passive_soft = amount_of_upgrades
soft_upgrade = Button(placement_soft, 0, keter_passive_2, 1)
if soft_upgrade.draw() and lob >= 500 and cooldown == False:
has_soft_clicks = True
amount_of_upgrades -= 1
lob_per_click *= 2
lob -= 500
cooldown = True
cooldowntime = time.time()
if keter_cutscene_3 == 2 and has_poem == False:
if poem_check == False:
amount_of_upgrades += 1
current_amount_of_passive_poem = amount_of_upgrades
poem_check = True
if current_amount_of_passive_poem == amount_of_upgrades:
placement_poem = 825 + (51 * amount_of_upgrades)
if current_amount_of_passive_poem - amount_of_upgrades == 1:
placement_poem -= 51
if placement_poem < 876:
placement_poem = 876
current_amount_of_passive_poem = amount_of_upgrades
poem_upgrade = Button(placement_poem, 0, keter_passive_3, 1)
if poem_upgrade.draw() and cooldown == False:
has_poem = True
amount_of_upgrades -= 1
cooldown = True
cooldowntime = time.time()