|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
, l. d: B, s/ d$ ~8 ~ public void spreadmoney(int m){: W7 p. o! V8 Y1 W* I! u, U2 B6 [/ O
for(int i=0;i<m;i++){9 S7 Q$ Q. \7 A+ k- a" V
int x = (int)(Math.random()*(moneyspace.getSizeX()));
; A$ q* L0 K4 ^, `' y int y = (int)(Math.random()*(moneyspace.getSizeY()));
7 J) y6 @& `( x( x
5 p' ^( n, Y1 d+ y int I;6 h! Z. ]' J7 [0 U0 b
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();! f( V) m! k. T3 s9 Y' g0 w4 m
}, Z% V& V) A" _! N7 h
else{" G' t% T, D% ~6 I( j
I = 0;( p7 j s7 X2 ~3 Y. M7 ]" @: E
}' t2 t) I! y. W
moneyspace.putObjectAt(x, y, new Integer(I+1)); }+ F5 J* ^: n+ a# I2 I5 ]
} |
|