comparison ppe/asteroid.cc @ 34:7aaaaf5dde40

add new task.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Fri, 07 Jan 2011 23:19:05 +0900
parents
children b97628fca317
comparison
equal deleted inserted replaced
33:39e643fc4f90 34:7aaaaf5dde40
1 #include "task_base.h"
2 #include "task_object.h"
3
4 SchedDefineTask1(Asteroid, asteroid_task);
5
6 static int
7 asteroid_task(SchedTask *smanager, void *rbuf, void *wbuf)
8 {
9 int asteroidi = (int)smanager->get_param(0);
10
11 CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
12
13 p->x += p->vx;
14 p->y += p->vy;
15
16 if (asteroidi > 0) {
17 CHARACTER* asteroiddt = (CHARACTER*)smanager->get_input(rbuf, 1);
18
19 for (int i = 0; i < asteroidi; i++) {
20 if ((asteroiddt[i].x + 32 > p->x)
21 && (p->x + 32 > asteroiddt[i].x)
22 && (asteroiddt[i].y + 32 > p->y)
23 && (asteroiddt[i].y < p->y + 32)) {
24 p->vx *= -1;
25 p->vy *= -1;
26 }
27 }
28 }
29 CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);
30
31 *q = *p;
32 return 0;
33 }