Jump to content


Photo

Variables reset? Unsolved


  • Please log in to reply
4 replies to this topic

#1 tari_minyatur_dw

tari_minyatur_dw

    GMC Member

  • GMC Member
  • 85 posts
  • Version:GM8

Posted 23 February 2012 - 08:58 PM

GM7 Pro.

Is there a way to make a Ver reset it's self.? I wanna make it so when HP reaches 0 it take's off 1 life, takes you home & put's hp back to 100. When all lives are gone the game would be over. but I don't know how.

Control Object-create event
global.playerhealth=100;

global.playerlives=3;

global.gamescore=0;

Player Object-Step event
if global.playerhealth<1
    global.playerlives-=1
    room_goto(yard)


I have no idea what to put to make the player health reset. I don't just wanna use Add 100 if I don't have to cause at higher level's I may want a higher max health.


Edit: right now it just keep's taking the lives off till you die since HP stay's @ 0

Edited by tari_minyatur_dw, 23 February 2012 - 09:08 PM.

  • 0

#2 troido

troido

    GMC Member

  • GMC Member
  • 150 posts
  • Version:GM8

Posted 23 February 2012 - 09:06 PM

just use
if global.playerhealth<1{
    global.playerlives-=1;
    room_goto(yard);
    global.playerhealth=global.maxhealth}
in the game start event you can assing a value to global.maxhealth
when going to higher levels, you can change global.maxhealth

Edited by troido, 23 February 2012 - 09:09 PM.

  • 0

#3 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 23 February 2012 - 09:08 PM

Basically, give your character a "maxhealth" variable. Then whenever you want to fully refill it, do

global.playerhealth = global.maxhealth.

Edit: bah, ninja :ninja:

Edited by greep, 23 February 2012 - 09:08 PM.

  • 0

#4 tari_minyatur_dw

tari_minyatur_dw

    GMC Member

  • GMC Member
  • 85 posts
  • Version:GM8

Posted 23 February 2012 - 09:18 PM

Basically, give your character a "maxhealth" variable. Then whenever you want to fully refill it, do

global.playerhealth = global.maxhealth.

Edit: bah, ninja :ninja:

right now yo set my max I have this
if global.playerhealth>100 (
    global.playerhealth) = 100;
Also in the Player Object-Step event. (before the other part I showed.

How do I make a var that set's max?

EDIT: hi Greep! glad to have you helping! I know your good at it.

Edited by tari_minyatur_dw, 23 February 2012 - 09:19 PM.

  • 0

#5 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 23 February 2012 - 09:36 PM

Well, just do what troido said, whenever you set your global.playerhealth at the start of the game, just also set global.maxhealth to 100. Unless you meant something else.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users