|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
, ?: z# c5 C0 Q' j6 s" \) Y3 t, ? public void spreadmoney(int m){, n7 x9 i! m3 y. F) ~* r7 R3 C
for(int i=0;i<m;i++){! G, W2 y, `/ m g
int x = (int)(Math.random()*(moneyspace.getSizeX()));6 H- l& G+ _" w, W
int y = (int)(Math.random()*(moneyspace.getSizeY()));
0 |* s$ d: N" _! j/ n( x! b7 j5 _6 K5 p3 t5 c% p6 K
int I;
0 _) s2 B$ H0 Q4 Y3 y if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
, A u5 D. o' d* F2 m }
0 q4 Z% p' h! u3 T1 B0 r+ U' o2 n else{
. y" a4 h: j- H( _3 T I = 0;2 ]/ c- y( [+ K: ?/ t7 x6 i# a. i/ y
}
: j8 \3 L! V, u ^ moneyspace.putObjectAt(x, y, new Integer(I+1)); }2 b& g. O! _. b8 [+ _
} |
|