|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?- M2 k, t" U: z& {) a# m- d2 E
public void spreadmoney(int m){; s! s# y' S! N% W4 [; t( H( m9 ]( R
for(int i=0;i<m;i++){6 I6 I% u( v7 Z
int x = (int)(Math.random()*(moneyspace.getSizeX()));
2 D! X* A2 H0 f+ s" E; [ int y = (int)(Math.random()*(moneyspace.getSizeY()));
8 { u X, E- c$ G$ Q
8 U0 d: d1 ~5 Z$ Z- p; j' O int I;
# {/ f! A( X* D/ C if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();% E U$ ?/ w# ]7 a4 F! b! e
}+ {$ M0 V1 m2 K/ b+ _1 {
else{1 V5 r. K3 ]- t8 x
I = 0;
* y. n, L2 N" [$ n6 W }- o+ A: V2 \' x, j( ^
moneyspace.putObjectAt(x, y, new Integer(I+1)); }2 V0 y0 y! h4 l! @) C, u
} |
|