|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
4 _1 c! O& d6 a9 @ public void spreadmoney(int m){( M4 i4 U4 x& h- s) |( B; g6 Y/ _* r$ i
for(int i=0;i<m;i++){/ u" U4 J) l3 E- R; g" N( I, @% H
int x = (int)(Math.random()*(moneyspace.getSizeX()));. D$ u: T3 n) B5 Q
int y = (int)(Math.random()*(moneyspace.getSizeY()));
" L: m: M. J: q: o9 I5 j; b4 a, \3 T9 @/ B; a* e9 z% I
int I;
/ d6 T8 \9 ]- v& T$ ~) C if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
+ ^; k, y/ l( E! Q0 ^! G3 d }; G8 a5 ?8 O( [+ u/ s
else{- [9 s2 m7 `3 ]3 n% l' r* K# Z. K' q
I = 0;! l$ o R0 |- u$ ~/ K
}
4 t, j% }4 K6 C moneyspace.putObjectAt(x, y, new Integer(I+1)); }1 a& ?2 j! \1 }( X
} |
|