|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
: Y! b4 o* Z/ e4 @) s. q H public void spreadmoney(int m){
' k/ Y' l( Y/ d/ `$ D/ c for(int i=0;i<m;i++){$ }. f0 v. r% K/ W( v0 o
int x = (int)(Math.random()*(moneyspace.getSizeX()));0 a. N+ T; _1 ~
int y = (int)(Math.random()*(moneyspace.getSizeY()));
( V- K! D0 l6 e% P: K
, `/ h7 G, S/ p int I;4 X8 F9 s7 \1 |7 ?: n7 v
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();& V; I" x% p- C; g) M6 D" @
}& D( Z2 B# |+ i" i
else{
% P! Q, B/ V& {( C% J I = 0;8 G5 i9 z4 j4 n' \. r1 T
}% T4 a7 V9 L F: n
moneyspace.putObjectAt(x, y, new Integer(I+1)); }# G# D% {# N$ h1 o, R1 }( k( {
} |
|