Ask coding questions

← Back to all posts
How to add shields in python
rockfantic (0)

I am working on a rpg using the python coding language. I just started adding weapons and health items. I want to add shields but I don't know how to make defense. Can anybody help me with this.

Answered by QuantumCodes (24) [earned 5 cycles]
View Answer
Comments
hotnewtop
QuantumCodes (24)

Is this pygame? Did you try making a variable named shield? Do something like:

shield = 0
if <however u get a shield>:
  shield = 30 #suppose u want 30% protection
health = health - damage*shield/100
QuantumCodes (24)

@rockfantic do you see the checkmark below the upvote button on my comment? That marks the answer as correct. If you feel this is correctly answered then you may click on that so others know that you dont need more help