Page 1 of 1

how to limit ammo & how to save score

PostPosted: Fri Jul 22, 2011 5:44 am
by raminjoon
Hi i was wondering to know if anyone knows how I can save my scores after I am finished with level 1 and moved on level 2 in my game and also how can I limit the ammo I can use to attack my enemies?

Re: how to limit ammo & how to save score

PostPosted: Fri Jul 22, 2011 6:18 am
by skydereign
Both of these involve variables. For the ammo, all you need to do is create the variable, in this case ammo. When you create the player set it equal to the number of bullets the player has (you can increase it to whatever when you get more ammo).
player -> Create Actor -> Script Editor
Code: Select all
ammo=10;


Now whenever you shoot, check if the player still has ammo, and if so fire (reducing ammo by 1 each time).
player -> Key Down Space (repeat disabled) -> Script Editor
Code: Select all
if(ammo>0)
{
    CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false);
    ammo--;
}


There are lots of tutorials on saving, and in fact I even answered one of your questions about it on another topic... So, if there was something that you didn't understand about my explanation or any of the others, it would help to know what you don't know. All it really is, is learning saveVars and loadVars.