GML Help With Increasing Price

Discussion in 'Programming' started by vRaiir, Mar 15, 2019 at 3:36 AM.

  1. vRaiir

    vRaiir Member

    Joined:
    Friday
    Posts:
    2
    Hello, I recently created a clicker game and was wondering when you purchase one upgrade the price goes up every time you upgrade it.

    Here is the code for the bit I wanted the price to go up each time you buy it:


    //Add PS
    if(global.money >= 200) {
    global.PS+=5
    global.money-=200
    }
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    3,691
    Replace the 200 with a global variable.
    Code:
    if (global.money >= global.ps_price) {
      global.PS += 5;
      global.money -= global.ps_price;
      global.ps_price += 100;
    }
    
     
  3. vRaiir

    vRaiir Member

    Joined:
    Friday
    Posts:
    2
    Sorry I’m kind of noob how would I go about changing it to a global var
     
  4. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    213
    FrostyCat just showed you exactly how. The only thing you'd need left is to initialize global.ps_price by writing "global.ps_price = 200;" in a creation or game start event.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice