|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的? i0 Y: D; m X9 Q! N9 [1 M$ w) P. k# k
public void spreadmoney(int m){, y" a1 ?7 W$ }
for(int i=0;i<m;i++){: B, p' s* z" F, ^ \; `* d. A
int x = (int)(Math.random()*(moneyspace.getSizeX()));& v' x0 D$ R; |2 W
int y = (int)(Math.random()*(moneyspace.getSizeY()));6 B5 B; ]) V0 W2 Q# R/ s+ V4 D1 |
% T, m( G6 ]+ H1 z! l9 Y4 ?
int I;" x$ m& D8 I. |, k2 u" [
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
% i8 V8 Z) L! { }
, b8 W3 U6 ?4 | @; [ else{
/ h# R- D9 H5 l5 ~! E I = 0;9 G/ S4 c B$ { \
}6 h7 p" P5 O) A6 B
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
, Y! a9 Z7 c2 H/ D: T } |
|