|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
p3 {/ k; X0 X, X public void spreadmoney(int m){! E( [6 f6 z+ [* Z0 p+ P- t7 E
for(int i=0;i<m;i++){% M; W" N" o* i# j! d* t6 V/ K
int x = (int)(Math.random()*(moneyspace.getSizeX()));$ c$ T5 w* _. @3 @5 f$ g
int y = (int)(Math.random()*(moneyspace.getSizeY()));
$ v; X1 S6 q( H+ `4 J" d/ f7 ~; G- U- T) w ]' X3 Y
int I;
- P% q4 Y( U {- |( R1 u if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();! Z$ h& ?+ M* L6 L! L, f+ r5 `
}
7 z$ y+ W% \* O* p: a else{, M7 ?2 m2 U0 q4 y9 j, K: j
I = 0;
5 q. d2 F9 n( E- v" e6 S8 [ }$ K2 d$ W' T% u( g- ]6 e5 d. X
moneyspace.putObjectAt(x, y, new Integer(I+1)); }; Z/ }0 z4 F% i$ L; E
} |
|