|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
: z, N& D) |/ [0 w& B public void spreadmoney(int m){
& X$ T# r4 k' a, A& h for(int i=0;i<m;i++){$ e* ?+ z) g2 |: ]
int x = (int)(Math.random()*(moneyspace.getSizeX()));, b) H$ M" R# e+ _* o6 Z y1 t6 K& d
int y = (int)(Math.random()*(moneyspace.getSizeY()));
* H+ { g& {- _0 m, }5 q, W& k. H; G- T
" W5 e0 c9 D: Q1 D0 g: g int I;# ~3 k0 Q+ Q- y9 L7 @1 `: `
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
% Z7 t# K% |2 w C) \8 N) F }
# p! }( `! M% I! |1 q else{7 q, n. X9 x6 e& r e4 R S2 ~
I = 0;
" _4 I4 \5 Q0 G3 p }9 {7 w9 b$ N& @# @% m
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
) o' t9 m. V5 E' P G7 G) b& { } |
|