|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?9 }1 c# D# X& T7 ~% X, Z
public void spreadmoney(int m){
0 N* V: `. n& V4 J' W for(int i=0;i<m;i++){
2 g$ o, H/ p. q% L. \ int x = (int)(Math.random()*(moneyspace.getSizeX()));5 [6 n) o: c+ N1 j. t$ N1 P
int y = (int)(Math.random()*(moneyspace.getSizeY()));
* K; N4 X) ^/ R$ r- z6 ]+ L0 G/ p
int I;
( D7 \* k& D- R* _# v if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
+ h3 p J+ j* C! S; D" z }/ w: U, y. @) H. `2 ]
else{
3 H% n; _1 ]4 {7 ?; J* K I = 0;
* H+ X) o" m4 H: H7 J, |' Q }# w" L7 p- J$ B
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
: D, J) d3 R ?6 Q0 m } |
|