|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
3 a: r, d3 f4 H2 y4 h9 N0 i public void spreadmoney(int m){/ g9 m3 L; {1 u$ z) Q5 P7 u D
for(int i=0;i<m;i++){0 P+ V* G- c; V+ _. T# b( _4 E
int x = (int)(Math.random()*(moneyspace.getSizeX()));
" W0 q" [7 ~, a' Q" Y int y = (int)(Math.random()*(moneyspace.getSizeY()));$ _1 L/ g" u! T! f2 [- S
! m% o. x1 k! o" t int I;
: T* b/ ^' z( d- D if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue(); i' u! y' K$ Q) ]1 o) q
}
, G; D& u# f' g else{0 {' W. _; a- F' z6 Q& n) J" w
I = 0;
9 b9 T8 C O# @& u6 V% P }& D* f$ {, q* K* k' M
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
/ n7 @5 b! |1 b; h9 q# @ } |
|