comparison 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
comparison
equal deleted inserted replaced
37:6989f8cb0259 38:6626e451a09d
4 SchedDefineTask1(State22, state22); 4 SchedDefineTask1(State22, state22);
5 5
6 static int 6 static int
7 state22(SchedTask *smanager, void *rbuf, void *wbuf) 7 state22(SchedTask *smanager, void *rbuf, void *wbuf)
8 { 8 {
9 int rand = (int)smanager->get_param(0);
10
9 CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0); 11 CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
10 12
11 int sf = rand() % 4; 13 int sf = rand % 4;
12 if((sf == 0) || (sf == 1)) 14 if((sf == 0) || (sf == 1))
13 { 15 {
14 p->x = -35; 16 p->x = -35;
15 p->y = rand() % (120 - 35); 17 p->y = rand % (120 - 35);
16 p->vx = (rand() % 4 + 1); 18 p->vx = (rand % 4 + 1);
17 p->vy = rand() % 3 + 1; 19 p->vy = rand % 3 + 1;
18 p->task = STATE23; 20 p->task = STATE23;
19 } 21 }
20 if((sf == 2)) 22 if((sf == 2))
21 { 23 {
22 p->x = rand() % 290; 24 p->x = rand % 290;
23 p->y = -30; 25 p->y = -30;
24 p->vx = rand() % 3 - 1; 26 p->vx = rand % 3 - 1;
25 p->vy = (rand() % 4 + 1); 27 p->vy = (rand % 4 + 1);
26 p->task = STATE23; 28 p->task = STATE23;
27 } 29 }
28 if(sf == 3) 30 if(sf == 3)
29 { 31 {
30 p->x = 320; 32 p->x = 320;
31 p->y = rand() % (120 - 35); 33 p->y = rand % (120 - 35);
32 p->vx = (rand() % 4 + 1) * -1; 34 p->vx = (rand % 4 + 1) * -1;
33 p->vy = rand() % 3 -1; 35 p->vy = rand % 3 -1;
34 p->task = STATE23; 36 p->task = STATE23;
35 } 37 }
36 38
37 smanager->swap(); 39 smanager->swap();
38 return 0; 40 return 0;