|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
8 O7 M5 v7 U0 `: X+ m; v$ J public void spreadmoney(int m){. r6 f, }4 q" g6 i
for(int i=0;i<m;i++){- K* [7 q3 f6 h3 p- u, ~2 c
int x = (int)(Math.random()*(moneyspace.getSizeX()));& I+ M+ b9 F! x3 V2 q! U
int y = (int)(Math.random()*(moneyspace.getSizeY()));
+ W* _. _1 Z6 }$ Z5 t% ~0 M. J# B9 b+ K: |6 [) D: P
int I;
7 o* T' K; V- W* d L' w if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();* o* H6 s; y. m; Q b, Z6 Z
}
; _% R! i1 K6 R* ` else{
4 q3 Z# |) t7 M& s3 f/ ` I = 0;$ i$ J0 Z6 F: x% \
}: ?4 Z& r5 l8 k3 c! e* X+ r. Z, \# x
moneyspace.putObjectAt(x, y, new Integer(I+1)); }+ L9 E% M+ x" S
} |
|