擅长:python、mysql、java
<p>如何将变量(例如p1direction和p2direction)存储在由播放器编号索引的向量(播放器方向)中,并使用循环访问它,例如:</p>
<pre><code>number_of_players = 2
playersXS = function_that_fills_playersXS() # return a vector containing your p1XS and p2XS variables in a vector
for player_number in xrange(number_of_players):
if player_directions[player_number]=='right' and playersXS[player_number]< Attributes[player_number][1]:
playersXS[player_number]+=Attributes[player_number][0]
</code></pre>