|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?3 R% }9 E% @9 a" o a) P
public void spreadmoney(int m){% y; o# u" S4 O; j/ r) _) m
for(int i=0;i<m;i++){! d8 @( k P! ~ b- C) `
int x = (int)(Math.random()*(moneyspace.getSizeX()));
- w4 q4 Q# h) B, ~, d+ W2 Z% G+ W int y = (int)(Math.random()*(moneyspace.getSizeY()));
; j0 h- ]9 H0 A) e- B) \# h1 l& _/ X" o
int I;
9 @% S& c: L+ e" s, w if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
3 J8 |2 Q# J& i }
' y0 X5 d# B$ j$ x else{+ H% R# x! T& A4 r
I = 0;
" u* `) V. c! u1 U, A8 I9 H }
6 c8 v; j7 }3 C9 u! R6 U/ J. } moneyspace.putObjectAt(x, y, new Integer(I+1)); }, p' s3 R! G) f$ i, [
} |
|