view spe/asteroid.cc @ 70:cee55c8365e9 default tip

fix
author Kazuma
date Thu, 19 May 2016 18:52:26 +0900
parents c330ded6d728
children cfd42ee2ad28
line wrap: on
line source

#include "asteroid.h"
#include "tobject.h"

SchedDefineTask(ASTEROID);

static int
run(SchedTask *smanager, void *rbuf, void *wbuf)
{
    CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
    int i;
    
    asteroiddt[asteroidi] = p;
    //            if(asteroidi==0)
    //            {
    p->x += p->vx;
    p->y += p->vy;
    //            }
    if (asteroidi > 0) {
	for (i = 0; i < asteroidi; i++) {
	    if ((asteroiddt[i]->x + 32 > p->x)
		&& (p->x + 32 > asteroiddt[i]->x)
		&& (asteroiddt[i]->y + 32 > p->y)
		&& (asteroiddt[i]->y < p->y + 32)) {
		p->vx *= -1;
		p->vy *= -1;
	    }
	}
    }
    asteroidi++;
    return 0;
}