diff ppe/chara_state22.cc @ 38:6626e451a09d

fix random number.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 11 Jan 2011 16:27:01 +0900
parents 7aaaaf5dde40
children 978097c6427a 21ac9f57a6d4
line wrap: on
line diff
--- a/ppe/chara_state22.cc	Sun Jan 09 23:14:26 2011 +0900
+++ b/ppe/chara_state22.cc	Tue Jan 11 16:27:01 2011 +0900
@@ -6,31 +6,33 @@
 static int
 state22(SchedTask *smanager, void *rbuf, void *wbuf)
 {
+    int rand = (int)smanager->get_param(0);
+
     CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
 
-      int sf = rand() % 4;
+      int sf = rand % 4;
       if((sf == 0) || (sf == 1))
       {
 	  p->x = -35;
-	  p->y = rand() % (120 - 35);
-	  p->vx = (rand() % 4 + 1);
-	  p->vy = rand() % 3 + 1;
+	  p->y = rand % (120 - 35);
+	  p->vx = (rand % 4 + 1);
+	  p->vy = rand % 3 + 1;
 	  p->task = STATE23;
       }
       if((sf == 2))
       {
-	  p->x = rand() % 290;
+	  p->x = rand % 290;
 	  p->y = -30;
-	  p->vx = rand() % 3 - 1;
-	  p->vy = (rand() % 4 + 1);
+	  p->vx = rand % 3 - 1;
+	  p->vy = (rand % 4 + 1);
 	  p->task = STATE23;
       }
       if(sf == 3)
       {
 	  p->x = 320;
-	  p->y = rand() % (120 - 35);
-	  p->vx = (rand() % 4 + 1) * -1;
-	  p->vy = rand() % 3 -1;
+	  p->y = rand % (120 - 35);
+	  p->vx = (rand % 4 + 1) * -1;
+	  p->vy = rand % 3 -1;
 	  p->task = STATE23;
       }