|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
& W8 Y# a8 f ]+ j4 \) r5 k public void spreadmoney(int m){3 y, d* G4 T& J# H9 i( d' o m$ D
for(int i=0;i<m;i++){
) h0 ?6 P# B" c3 ?+ {( ^ int x = (int)(Math.random()*(moneyspace.getSizeX()));
& u: A- u1 D: l* C3 P( G int y = (int)(Math.random()*(moneyspace.getSizeY()));' n0 i3 y3 N+ q; E% w
1 P, t0 d# W2 v5 i, h8 i. z int I;
8 ]( Z4 f1 C4 l if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();; r& o* y! p# I) L0 w
}
0 @% D+ G0 j: b* c. T else{
9 Z& l- M) k4 x; ?4 p% h1 ? I = 0;! N- P) K/ c/ M9 U
}
: u+ c+ H( n1 b" b8 n moneyspace.putObjectAt(x, y, new Integer(I+1)); }
8 a3 A# Y9 D( s3 ?( x m } |
|