|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?( x- z5 _& F# T
public void spreadmoney(int m){
9 s7 ?& O0 @7 W) V: q9 X& t6 h7 ?, C for(int i=0;i<m;i++){% q9 J8 U, z6 Y0 ^
int x = (int)(Math.random()*(moneyspace.getSizeX()));5 J- U2 @, V" Q+ P `: ]& A
int y = (int)(Math.random()*(moneyspace.getSizeY()));
* K$ L$ y1 Y6 A
$ N0 Q' W |6 Y% O# w& Y* k int I;0 \" a+ N; j# g( s, F
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();/ X5 @1 K6 c1 p
}
" U5 ?( n8 U2 p& W& Q5 \ else{
6 y. a4 f! _) l* o8 M& t |- m. w# Z I = 0;: x5 O6 u4 U" o) i
}5 Y8 V1 ~5 X9 u0 C% o* z5 g/ L
moneyspace.putObjectAt(x, y, new Integer(I+1)); }& w& d- |& t# ~; @* j3 R, Q
} |
|