|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
0 W3 w1 b+ g" |2 ?( S# l+ T2 z. G public void spreadmoney(int m){6 O8 J6 e2 h# E1 Z4 W* x6 c
for(int i=0;i<m;i++){2 c, o" A. h' @3 j# l
int x = (int)(Math.random()*(moneyspace.getSizeX()));
3 q* d2 a* D/ |$ w/ @1 Q" @ int y = (int)(Math.random()*(moneyspace.getSizeY())); T9 D S8 {4 @' S
$ [- {6 \$ |- M6 t
int I;6 Q, {6 O5 t, p% `! [; [
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
# j2 W# o) |, L6 [- Y }, o D# F% K$ E& \! {; t7 X( z9 A& H4 ]
else{
8 ]1 g4 n2 \0 V3 T! L% h4 t$ g I = 0;6 M" y) y: m% G3 ^( O" a& _
}% g6 ^ @' Z/ f2 Q# p% z; x. \
moneyspace.putObjectAt(x, y, new Integer(I+1)); }5 T6 L. x+ p- y, R
} |
|