|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?9 h4 x5 C0 \( f, ^2 R
public void spreadmoney(int m){
. B; {/ v3 Q) j) D/ n/ Q# N for(int i=0;i<m;i++){6 w# u# L" Z, m, |* d, _+ _0 z
int x = (int)(Math.random()*(moneyspace.getSizeX()));
: K2 }' Y/ ^. c- P int y = (int)(Math.random()*(moneyspace.getSizeY()));
& d) X5 A4 W. f5 V3 U6 k) @
; F( r: W. e. d& a) |! | int I;
# Y; L0 O$ c& r1 Z6 U/ v if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();2 O0 y+ Q- Z( t; G1 ^3 K
}
2 k- T# o* d, j. z, ^: ]6 f7 B else{0 p" }( C8 N, \/ z1 C' n, u
I = 0;/ s0 ?/ Y9 L+ P+ l% I& g
}6 s+ J' W5 p* S9 X( n4 w6 u) E- K
moneyspace.putObjectAt(x, y, new Integer(I+1)); }1 q j8 T% G z+ s/ R: U+ _( p
} |
|