<p>使用Python。
我想创建一个非常简单的系统,告诉python如果满容量减少1,弹药消耗将为真,当弹药消耗为真时,我会让python知道弹药被消耗了。我的代码的问题是弹药消耗量一直是真的</p>
<p>如果您不理解,以下是代码:</p>
<pre><code># fc means full capacity, and that number will tell the player for an example how much arrows they have
fc1 = 10
fc2 = 20
fc3 = 30
fc4 = 40
fc5 = 50
fc6 = 60
fc7 = 70
# If Wanted to use capacities in a list
full_capacity = [fc1, fc2, fc3, fc4, fc5, fc6, fc7]
# It is false because it did not get consumed yet
ammo_consumption = None
# it means that if r_approval is True then in the defined later reload system it can get reloaded if the player
# of course press a specific button
r_approval = False
# just to clean an error
o_o_o_o_o_o_o_o_o = r_approval
# checking
print(fc1, ammo_consumption)
# here I tell python how it works
if fc1 > 9:
ammo_consumption = True
r_approval = True
if fc2 > 19:
ammo_consumption = True
r_approval = True
if fc3 > 29:
ammo_consumption = True
r_approval = True
if fc4 > 39:
ammo_consumption = True
r_approval = True
if fc5 > 49:
ammo_consumption = True
r_approval = True
if fc6 > 59:
ammo_consumption = True
r_approval = True
if fc7 > 69:
ammo_consumption = True
r_approval = True
shot1 = fc1 - 1
print(shot1, ammo_consumption)
shot2 = fc2 - 1
print(shot2, ammo_consumption)
shot3 = fc3 - 1
print(shot3, ammo_consumption)
shot4 = fc4 - 1
print(shot4, ammo_consumption)
shot5 = fc5 - 1
print(shot5, ammo_consumption)
shot6 = fc6 - 1
print(shot6, ammo_consumption)
shot7 = fc7 - 1
print(shot7, ammo_consumption)
# but here ammo_consumption is still true
print(ammo_consumption)
</code></pre>