|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
. X9 Y+ Q# j, Z; { public void spreadmoney(int m){2 l: u; p4 g) z! n
for(int i=0;i<m;i++){
% C, h. ^; S! I% \ int x = (int)(Math.random()*(moneyspace.getSizeX()));7 G: n# C1 \* ?
int y = (int)(Math.random()*(moneyspace.getSizeY()));
% n3 f( p9 i" W3 }/ S1 J7 f' p/ h+ c( L5 R
int I;
- o2 O3 u+ G C; ^! K3 b7 l$ A: C if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
/ N7 Q/ X, q; Q% R }
( @# ]* R I" \4 @$ [: Z else{, a; j! ~9 ?( i* R! `
I = 0;
0 L9 W' G! g; Y( n, W }
2 W F6 d& Q( ^ f( s moneyspace.putObjectAt(x, y, new Integer(I+1)); }
) _# q6 m2 i/ D. b4 R3 ~ } |
|