|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
1 K: t# u3 e- O1 ^9 B9 _$ R public void spreadmoney(int m){4 A* n n R# Q' W0 Z) ^
for(int i=0;i<m;i++){
s$ \* H4 R0 I6 k; Q0 o" ]1 E5 W+ T int x = (int)(Math.random()*(moneyspace.getSizeX()));
. u* p6 a/ }% t, E0 `+ Y int y = (int)(Math.random()*(moneyspace.getSizeY()));! T& X' z( l% M. ]5 Q/ m, Z
( E- V9 t+ T4 P4 o: H- D& y# E: [ int I; v% A# d$ g5 j1 M' }' _
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();( q, |7 a, Z6 G5 w+ e+ P& A- G. D
}( W- R& f5 j; p/ R. n$ }
else{. f' j+ A6 r! m6 b3 H
I = 0;
9 T$ A5 K: I5 Z; u, L }
' G( _9 {7 i2 F% o moneyspace.putObjectAt(x, y, new Integer(I+1)); }
. [8 O5 ?' n& i5 F } |
|