Hi. I have this hunting function for my game and it returns a negative hp value to the enemy sprite when the player keeps on shooting. Is there any way wherein I can restrict the user to press any key while ajax is still in progress?
I have no idea what this has to do with AJAX, but you can add a variable ShootingAllowed and do something like this:
AJAX Request ... Set ShootingAllowed to 0 Wait for previous action to complete Set ShootingAllowed to 1
And add "ShootingAllowed=1" condition to the event where player is shooting.
Also, to avoid negative values in health variable, instead of "Subtract damage from health" action, use "Set health to max(0, health-damage)"
Develop games in your browser. Powerful, performant & highly capable.
I'm using ajax to send request to the database to check if the player still has ammo, the hp of the enemy, etc... Anyways, thank you very much for that idea. :)