|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
, a8 }* o9 ~7 r$ s, Y% X9 h public void spreadmoney(int m){( k) h( b0 O) U6 t( R$ o, `
for(int i=0;i<m;i++){
' o! e+ B4 Y' B3 I: a/ b int x = (int)(Math.random()*(moneyspace.getSizeX()));
4 ]! F B. a* K# t int y = (int)(Math.random()*(moneyspace.getSizeY()));
8 i" l' \1 b) q* a5 \" r. s4 B; G5 a% c8 _" a* `
int I;
7 X# |! ], D9 B- S7 n& ^2 K- N4 Y4 W3 j h if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();6 l/ d( d, U, n$ r- D& N$ _8 V4 I
}2 M! P s' d, J! g [
else{4 [* i5 j2 m% c# m7 C" r
I = 0;
; u, F' r T1 r2 X' j$ f: \ }
# f1 Y2 Y0 w1 Z1 x9 u( ? moneyspace.putObjectAt(x, y, new Integer(I+1)); }
: C2 q# ~* Z$ V } |
|