|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?* k) @! i, L2 I/ M! Q6 ~
public void spreadmoney(int m){! Y4 h' v( o/ e' W4 a
for(int i=0;i<m;i++){. K0 o* U9 g m1 Z
int x = (int)(Math.random()*(moneyspace.getSizeX()));5 ]% S) l* U% a& K# G9 l
int y = (int)(Math.random()*(moneyspace.getSizeY()));
- Y& y! Q* d4 a6 u
: Q! a% |, j! ~3 g" j m( Q int I;
9 L: `1 H( Q2 g& U( a) e if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
s n5 k& _8 [ }
# V) V) e+ S/ W0 b0 w Y, J else{9 f$ g5 K a# f# e' k+ T, D
I = 0;; ], @+ }( y, H y) B7 N, S
}
8 f: f9 y% b( C# g4 M- u moneyspace.putObjectAt(x, y, new Integer(I+1)); }' q; s" _6 X/ L, S7 |
} |
|