|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?' x# _" z" H6 z/ q6 q. _
public void spreadmoney(int m){! W( H5 \, e" m3 R2 c/ l' x0 E
for(int i=0;i<m;i++){: b9 I6 D" O* l3 u7 H5 N
int x = (int)(Math.random()*(moneyspace.getSizeX()));
8 a% t, ~0 A6 J$ ]+ E# i& ^ int y = (int)(Math.random()*(moneyspace.getSizeY()));9 x- q: l d: w L* _
/ q7 K( I7 _, U2 p int I;
2 P/ Q! A6 Q# n) Z" G5 M# g" c5 \ if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
4 f" A# c. R% ^, |2 Y }
5 x! [% d+ S) e$ g+ F+ p5 z else{
' _4 e( O& i w( B( U/ g I = 0;; Z; L; E$ B0 N/ h* w9 B9 E) Y8 \
}& K. u: E# n0 B* j8 U( b
moneyspace.putObjectAt(x, y, new Integer(I+1)); }* `% C$ p$ C5 W# k3 K
} |
|