|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?7 M* ? K# ~) _# R" D
public void spreadmoney(int m){
$ j3 g. h! ]" ~' y, U for(int i=0;i<m;i++){0 m9 u$ B3 ?9 t
int x = (int)(Math.random()*(moneyspace.getSizeX()));! V( C1 l. {: L1 X
int y = (int)(Math.random()*(moneyspace.getSizeY()));7 |5 I4 ~3 ^) ^! ^6 ^ b6 `
7 w5 X: s/ U" f/ [5 p int I;
# t4 O+ c+ f( n1 f& L) d: j if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();& Q' ^* F$ x9 y" c) l
}
# G7 z2 j, M7 P* @, t else{& h B* n7 A( G- h
I = 0;
* q$ K0 b( C3 _' c& ?3 |4 ~9 |. u }5 G( L7 _5 ?6 L& o7 t
moneyspace.putObjectAt(x, y, new Integer(I+1)); }4 \9 M4 z1 H, b$ a
} |
|