|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?# t% u: e- Q$ A2 w, J; B: S
public void spreadmoney(int m){
+ V* l0 [8 Z: ~/ ~4 Z for(int i=0;i<m;i++){
# U$ \8 F+ W9 p& D9 ?' P0 d4 n3 V7 U) @ int x = (int)(Math.random()*(moneyspace.getSizeX())); L' b# q( l/ L: v! E) H" U4 S
int y = (int)(Math.random()*(moneyspace.getSizeY()));
* g+ h, W9 t+ i9 U! P+ k' d3 `2 V2 ^, ~$ [, A' L$ t
int I;" I Z3 I7 S5 ?! `5 L8 w1 l
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();. V6 R7 O' s1 r1 S4 ~
}& ?8 l3 [) n: K0 ^
else{
; w" q9 L- b! i' E+ ? I = 0;& A8 u; Z- a/ K6 O6 Q6 _
}
! ~6 h: ^2 v( Q/ n& k/ T+ T& l moneyspace.putObjectAt(x, y, new Integer(I+1)); }8 ]7 L1 J! N o8 C! g' f/ P
} |
|