how to create Infinite Upgrades in a clicker game

46 views Asked by At

so i am new at coding and im trying to create a Clicker game. To sum it up its supposed to be like Cookie Clicker. Click something to get a point and with those points buy upgrades. But i ran into a little Problem, i want to create Infinite Upgrades. So that i can buy a Click upgrader a infinite amount of times. But I dont know how i can code that.

I havent yet tried anything BUT i have researched. I read allot about Loops but i dont think it would fit because The upgrade part of my Code needs to go up in numbers with the Price of points and the amount of upgrades. Also i would need to somehow Fittingly change the Button Click of the "Cookie" ( cant really explain it well but i basically need to change the code of the thing i click as well ) For now i just did a Max level.

Here is my code




using System.Linq.Expressions;
using System.Printing;
using System.Text;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace wieso
{
    

    public partial class MainWindow : Window
    {

        long Score = 0;
        long Upgrade1 = 1;
        public MainWindow()
        {
            InitializeComponent();
            ClickAnzahl.Content = Score.ToString();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ClickAnzahlTEXT.Content = "du hast so viele Clicks :";
            ClickAnzahl.Content = Score.ToString();

           
            if (Upgrade1 == 1)
            {
                Score = Score + 1;
                ClickAnzahl.Content = Score.ToString();
            }
            if (Upgrade1 == 2)
            {
                Score = Score + 2;
                ClickAnzahl.Content = Score.ToString();
            }
            if (Upgrade1 == 3)
            {
                Score = Score + 3;
                ClickAnzahl.Content = Score.ToString();
            }
        }


        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (Upgrade1 == 1 && Score >= 10) 
            {
                Score -= 10;
                Upgrade1++;
                ClickAnzahl.Content = Score.ToString();
                knopfding.Content = "50 CLICKS FÜR EIN CLICK UPGRADE!";
            }

            if (Upgrade1 == 2 && Score >= 50)
            {
                Score -= 50;
                Upgrade1++;
                ClickAnzahl.Content = Score.ToString();
                knopfding.Content = "Max Level!";
            }






        }
    }
} 
0

There are 0 answers