Creating an FPS ammo counter.

Hi,

For the text part, you don’t seem to be calling change_text() anywhere. Try adding it in _on_player_player_shoot() and _on_player_player_reload(), at the end of both functions.


For the can_shoot not being set to false there are two problems.

1/ I believe there’s a minor flaw in your algorithm:

if clipammo > 0:
    clipammo =- 1
    ammo_changed.emit(clipammo, totalammo)
else:
    player.can_shoot = false

That code basically says “if there’s ammo, shoot, else, you cannot shoot”. The problem is, you have to check if the player can still shoot after firing a bullet. Like this:

if clipammo > 0:
    clipammo =- 1
    ammo_changed.emit(clipammo, totalammo)
    
    if clipammo == 0:
        player.can_shoot = false

2/ Second, you wrote clipammo =- 1 which will assign -1 to your variable. What you want to do is clipammo -= 1 to decrement the value. I guess that’s a typing mistake.


Let me know if that helps.
If not, please share your code with a proper formatting (I’ll leave a link for some tips).