|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
% c! Z2 r+ B( _5 }! W! w/ r" z public void spreadmoney(int m){
9 k% s2 u- r2 w" A! ]/ F( u6 F for(int i=0;i<m;i++){
: C. r }8 m9 j int x = (int)(Math.random()*(moneyspace.getSizeX()));
, t. x# ]1 W2 C! ? int y = (int)(Math.random()*(moneyspace.getSizeY()));
( j9 ^- D2 r4 R9 g0 d5 T7 c, w2 N1 L) A2 o
int I;
3 ]% H8 K4 r" T* j2 X, C7 y, J( j if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
! Z; n2 S, t9 Q3 N- c" U. m }
, l% M7 O4 F' ^& D s3 f else{
. W, u! W, t9 v/ [- l' {% { I = 0;
/ f, |& r0 J. i) B' h. Q }- x& L6 c2 j) z1 p' a$ {
moneyspace.putObjectAt(x, y, new Integer(I+1)); }0 J' M: \- N7 w5 c$ Y+ k" G
} |
|