|
|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?
8 T) e! W3 p" Y9 e public void spreadmoney(int m){
# J- T x# n! l9 m1 V2 C# c O for(int i=0;i<m;i++){) m! F! H6 s& s$ c) v
int x = (int)(Math.random()*(moneyspace.getSizeX()));
" [6 H5 F. n B5 ?2 V0 f; k, [! A int y = (int)(Math.random()*(moneyspace.getSizeY()));; c+ {1 o+ W3 `: F
: B, s: J2 T& Z2 q ]- B+ {) {
int I;$ A5 [) \8 o3 h. a: k
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
5 k7 k( c7 g. P3 A }
& |' J% b4 o+ ~5 u. V' W else{ K2 C6 Q# a- ? r& r, H
I = 0;
. b3 Q: V) M4 Q- f }
% f3 l e+ J0 W* [ moneyspace.putObjectAt(x, y, new Integer(I+1)); }3 Z: e c( T9 J2 g) x7 f
} |
|