Jump to content
zork269

How do I decrease a variable over time?

Recommended Posts

So the premise of my current project is this: the player begins with a full "mood" bar, but as time goes on and the game is played, the mood bar steadily decreases. Once it hits the bottom, the sprite has become so depressed that he commits suicide in a gruesome and creative fashion. Game over.

 

My intentions were to set a variable, called "mood," at 450 (which is the Y-coordinate of the icon that marks the player's level on the meter) and then set a conditional branch, so that every 1 second (or some interval of time) the variable decreases by 4.5 and makes the icon fall steadily lower on the meter. But it isn't working. The conditional branch will end as soon as the second is over, but if I set it to loop, the game crashes immediately upon starting.

 

How do I accomplish this?

 

Thanks for your help.

Share this post


Link to post
Share on other sites

1) Set this event to parallel process if you have set it to something else

2) Set two things in that event:

           - Wait: ## frame(s)

           - decrease variable

3) You can put conditionals and stuff if needed~

4) profit

Share this post


Link to post
Share on other sites

You have to practice and use the theory of frames. When you want to decrease a variable over time, you have to get a wait counter, that when it reaches a certain range it decreases the variable. Through eventing this is possible. Just make sure that while you do the waiting it does not affect your character's overall movement.

Share this post


Link to post
Share on other sites

Great! I set the counter as a common event, running as a parallel process, and it works like a charm! Thanks everyone.

Share this post


Link to post
Share on other sites

Glad you got it solved! (=

9RWO0dm.pngThis thread is closed, due to being solved. If for some reason you would like to re-open this thread, just send me a PM. (=

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted