view ppe/chara_state601.cc @ 70:cee55c8365e9 default tip

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

#include "task_base.h"
#include "task_object.h"

SchedDefineTask1(State601, state601);

static int
state601(SchedTask *smanager, void *rbuf, void *wbuf)
{
    long rand = (long)smanager->get_param(0);

    CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0);
    player *jiki = (player*)smanager->get_input(rbuf, 1);

    int length = 1;
    smanager->set_outputSize(1, sizeof(ObjContainer)+sizeof(ObjData)*(length-1));
    smanager->setup_outputData();
    
    ObjContainerPtr sprite = (ObjContainerPtr)smanager->get_output(wbuf, 1);
    sprite->flag = true;
    sprite->length = length;

    p->dt2++;
    if (p->x < jiki->x)
	p->vx++;
    if (p->x > jiki->x)
	p->vx--;
    p->x += p->vx;
    Putenemy(6, p->x + 16 + rand % 32,
	     p->y, 0, rand % 4, STATE400, &sprite->data[0]);
    if (p->x < 0)
	p->x = 0;
    if (p->x > 260)
	p->x = 260;
    if (p->y < 0)
	p->y = 0;
    if (p->y > 232)
	p->y = 232;
    if (p->dt2 > 800) {
	p->task = STATE602;
    }
    CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);

    *q = *p;
    return 0;
}