|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?( y0 h1 |, p; s6 c7 U+ b
public void spreadmoney(int m){" F, ~* H2 t( ] O* M( d; ~
for(int i=0;i<m;i++){
# @& _: }0 e6 x. Z int x = (int)(Math.random()*(moneyspace.getSizeX()));( T9 s- G( ^6 N/ S3 J o0 O1 D
int y = (int)(Math.random()*(moneyspace.getSizeY()));. x8 D( ?% N' w+ |
1 Z: `% N3 S, e2 K* Q1 m* V% D; O int I;
; d, y3 W) l' Y% ] \- [3 X3 O if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();6 @2 M0 w1 W# F1 y: l$ b. Z; s
}
% [: ]4 T4 ?0 B else{+ O- D7 |0 \ }* _5 R
I = 0;7 y4 @, a' P6 k5 w, K6 ~
}
7 U" {8 s" ?& w8 k7 v7 f3 G moneyspace.putObjectAt(x, y, new Integer(I+1)); }. Q- m9 Z }, B" a% }8 } Z
} |
|