|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
' N; I: j: d2 V# K" D6 ?9 ~ public void spreadmoney(int m){- h7 G) C4 N1 h' @9 d- N! j
for(int i=0;i<m;i++){0 i$ U! f. M; Z+ d( |- O" _ L
int x = (int)(Math.random()*(moneyspace.getSizeX()));
( [/ { e. ~, l" v int y = (int)(Math.random()*(moneyspace.getSizeY()));& X6 \6 R% o" C) H2 o9 y
1 G5 V+ @. f2 P3 V" l
int I;* m. O" d4 _9 _' A) b. ]. p
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue(); Q z+ J9 v. A* T& }' \
}8 S2 f3 N( b6 S: ] _
else{
1 J* D) J0 F3 f! \2 o, _, t, y I = 0;
; V# n$ u( l) R/ g" c2 j2 }4 ] }5 R, L1 d+ w) H
moneyspace.putObjectAt(x, y, new Integer(I+1)); }/ y4 I/ U/ p5 D- N# J
} |
|