Answer the question
In order to leave comments, you need to log in
How to make pistol logic?
there is a variable (how much in the store) and (how much in stock). and how to reload what if for exampleint ammo = 15
int ammoLeft = 15
ammo = 10;
ammoLeft = 10;
therefore should beammo = 15;
ammoLeft = 5;
?
Answer the question
In order to leave comments, you need to log in
total = ammo + ammoLeft;
if((float)(total/15.0) == 1.0)
{
ammo = 15;
ammoLeft = 0;
} else if((float)(total/15.0)<1.0)
{
ammo = total;
ammoLeft = 0;
}else {
// total/15 > 1, for example ammoLeft > 15
ammo = 15;
ammoLeft = total - 15;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question