1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GML Help With Increasing Price

Discussion in 'Programming' started by vRaiir, Mar 15, 2019.

  1. vRaiir

    vRaiir Member

    Joined:
    Mar 15, 2019
    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,969
    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:
    Mar 15, 2019
    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:
    243
    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