|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
+ l i7 g4 M& `& ?, y8 L e' M public void spreadmoney(int m){
4 D1 W: }8 G$ e) j( x% g for(int i=0;i<m;i++){3 N" b# y. C6 k' ^. s
int x = (int)(Math.random()*(moneyspace.getSizeX()));! P+ ]) s& ]* v' }/ I" u2 K. d
int y = (int)(Math.random()*(moneyspace.getSizeY()));3 m0 H3 {9 F& G4 a+ B
8 t. ^; J7 c1 o" }/ G+ p+ I, N, T int I;
( L! g$ L1 i- d if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();8 l8 G) k" f; h: R s
}
3 e( o! L% G# D4 l% K* g1 [6 Q else{, X3 s3 v. b% n2 j/ Y. f
I = 0;
" P( V7 ?7 o. q$ G }6 M1 w D. q0 x( Q1 t
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
( w: n% l5 e9 O! e' j } |
|