view ppe/chara_state601.cc @ 65:b97628fca317

int -> long. not move on ABIBIT=64.
author tkaito
date Thu, 17 Feb 2011 04:49:47 +0900
parents e0018f39f7e1
children f27a6af6514c
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 rand1 = (long)smanager->get_param(0);
    long rand2 = (long)smanager->get_param(1);

    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 + rand1 % 32,
	     p->y, 0, rand2 % 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->state_task = STATE602;
    }
    CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0);

    *q = *p;
    return 0;
}