|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
& }9 I, F3 X0 @' a( D public void spreadmoney(int m){" [ G; h, ]" u% s
for(int i=0;i<m;i++){
: p; O# U9 a2 z C# s, v, z int x = (int)(Math.random()*(moneyspace.getSizeX()));
# ]6 |7 ]0 ?) ]) R int y = (int)(Math.random()*(moneyspace.getSizeY()));6 V& P A: V3 c/ i
, _- c) F1 g8 u3 c- G
int I;
$ o3 V% A1 m5 x8 _1 B if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();0 T" x( J4 \- {* l8 l6 l* [& @, p
}
0 `$ _! R* z k, g: c else{
2 G( d7 Z% C8 X" _! l# ? I = 0;
( h: M6 {; M3 q; M) r* j }
H% [5 w- X4 C7 I moneyspace.putObjectAt(x, y, new Integer(I+1)); }4 m6 Q( g* q) W/ v
} |
|