|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?3 g7 X) \ v4 U. j' w% I
public void spreadmoney(int m){
) E: Q. s) \5 [. V u for(int i=0;i<m;i++){
! L9 f) l+ W( n) X. n int x = (int)(Math.random()*(moneyspace.getSizeX())); ^5 n. `! q( f8 U$ u; S8 |& w
int y = (int)(Math.random()*(moneyspace.getSizeY()));
7 f9 P+ I- K4 Z! y' B7 `! C
[6 [3 p0 j7 i+ r2 r& I! s3 Z int I;
% N2 A4 X" P' B( K if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();7 I: v% C8 S+ ?+ w
}
& M* `/ f3 Y3 E6 C+ c else{) s) A, ^2 Q0 N' Z2 V: \1 I
I = 0; ~6 B' |5 B. z6 I( c2 t
}
* z3 z/ T& Q+ s' L0 C! N moneyspace.putObjectAt(x, y, new Integer(I+1)); }- V, d, S/ c2 V: T( ]4 _7 n2 ]) H# w
} |
|