|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
% W2 C; w; r' a8 x public void spreadmoney(int m){
1 B2 b' y9 A2 r; R0 H1 E for(int i=0;i<m;i++){
8 p' b9 }" `3 p& D! n" Z2 T+ M int x = (int)(Math.random()*(moneyspace.getSizeX()));& D9 B8 D! O- O4 b0 i
int y = (int)(Math.random()*(moneyspace.getSizeY()));
/ b# [* K! s& p8 J
& l, @; W* |; B+ @$ | int I;
3 `+ w) a; @( E+ s# U if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
# ^6 [" p* y5 A2 H/ j. ~% _ }, V0 B7 ?+ l1 z1 r9 a
else{9 N3 t2 f! c% b" r& Y+ I! m
I = 0;
( [' X: S* w+ C* J: H, E }
( s7 }3 B5 k4 g: P* F, { moneyspace.putObjectAt(x, y, new Integer(I+1)); }; n f9 E' Y) W" p6 ]+ z
} |
|