|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
8 J9 F- G* W8 L, H" s* S4 y* b public void spreadmoney(int m){
4 a) f% g5 n$ J# M' t7 B5 n for(int i=0;i<m;i++){
) Y) b: u; H- b9 r8 i$ O# r& i int x = (int)(Math.random()*(moneyspace.getSizeX()));) Y3 w9 ~: V( k/ y
int y = (int)(Math.random()*(moneyspace.getSizeY()));$ y( ~6 B, l9 x1 z2 L
/ t8 f; e+ j2 U2 `
int I;$ G% l" @9 m' S9 l: p+ ~3 L1 y7 I
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
7 [) d0 h) y/ E8 ]5 f9 B! B/ \ }7 i# P8 |3 f+ | y: u' e
else{
8 ]8 Z! c% o7 n I = 0;, O, ? d9 r0 @; y
}4 w# d; P2 D4 C0 o7 |9 ?
moneyspace.putObjectAt(x, y, new Integer(I+1)); }( T% s6 {8 |- ^6 |) L/ l$ P- K7 r
} |
|