|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?% k$ H1 S9 W7 S/ G5 ~
public void spreadmoney(int m){
, ?6 w. f$ H8 Y% \! W! l for(int i=0;i<m;i++){
# o0 ~) j! x- x( u5 H- }# w. [ int x = (int)(Math.random()*(moneyspace.getSizeX()));
, h3 T/ J; `& |9 S/ G: \( z3 B1 `9 \ int y = (int)(Math.random()*(moneyspace.getSizeY()));+ ]- q2 Z4 u: `
* B# |- U+ ~& Q7 h
int I;
9 z. _5 U' t7 T( x; M6 c+ d if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
* I9 l3 j9 Q. e3 `/ ` }
" U* B! s( L: E; q4 O else{
. y9 x- I& M7 j/ q/ }# k I = 0;
6 {$ t3 n* ~$ t% ^2 Q }0 ]3 M/ U7 x$ d# ?5 u) b/ o+ {
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
( f! U& G _4 m* C$ ? } |
|