|
在CarryDrop model中那个spreadmoney方法里,哪一句是用来随机撒钱的啊?程序代码如下,我看到了随机选取坐标,并将该坐标对应的空间格内的值转换为数值,关键在于这个值貌似始终为0,不知道怎么把它修改掉的?哪一句是生成不为0的值的?8 u6 M0 I3 f9 D1 v+ W
public void spreadmoney(int m){
& P, }6 S& k! \( ?" y+ j! A- [! M for(int i=0;i<m;i++){
/ |( [# ~: y5 p$ b; D/ f0 ~5 ? int x = (int)(Math.random()*(moneyspace.getSizeX()));
+ F3 G, A2 y/ X& ~1 l int y = (int)(Math.random()*(moneyspace.getSizeY()));
! k1 N- ]/ Y1 p( t
. f8 a# m" {* P5 g( M$ _ int I;4 M( l. p, o: Z# T% U8 _9 m q
if(moneyspace.getObjectAt(x,y)!=null I = ((Integer)moneyspace.getObjectAt(x,y)).intValue();
. s$ q# C1 ]7 c8 e5 [( H }4 f3 g; N# l% _+ s0 J
else{: d* A4 M( B9 A7 A2 l
I = 0;
% t" ~; B9 w4 V, r* Z8 z( X9 x }. z; a! M' [; J7 E
moneyspace.putObjectAt(x, y, new Integer(I+1)); }
# Y/ s/ T5 s. r9 p( w( n; i; c } |
|