GML - Making points add health

From Global Programming Syntax

Jump to: navigation, search

Sometimes in a game you don't want health packs but instead want the player to earn health by gaining score. The following scripts will just do that.

Example Code

In this script, you will learn how to make it so when a player has 10 score, 20 score, 30 score, 40 score, 50 score etc, the player will gain one health.

Put the following GML into the create event.

globalvar points, calscore;
points=0;
calscore=0;

In the step event put the following.

calscore=score-(points*10);
if calscore>1 then
{
points+=1;
health+=1;
if health>100 then
{
health=100;
}
}
Personal tools
languages
page stats
Toolbox