Mercurial > hg > Members > koba > t_dandy
changeset 31:ccb8d9956a1e
add multi container function.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Dec 2010 19:19:13 +0900 |
parents | 427e1aac0bd7 |
children | 1b161e808240 |
files | ObjectType.h ppe/chara_state3.cc ppe/chara_state7.cc ppe/tama.cc ppe/task_object.h property.h state_task.cc |
diffstat | 7 files changed, 92 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ObjectType.h Fri Dec 31 19:19:13 2010 +0900 @@ -0,0 +1,4 @@ +enum { + Tama, + Enemy, +};
--- a/ppe/chara_state3.cc Fri Dec 31 15:50:44 2010 +0900 +++ b/ppe/chara_state3.cc Fri Dec 31 19:19:13 2010 +0900 @@ -1,5 +1,6 @@ #include "task_base.h" #include "task_object.h" +#include "../ObjectType.h" SchedDefineTask(State3); @@ -7,11 +8,14 @@ run(SchedTask *smanager, void *rbuf, void *wbuf) { CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0); - CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0); - TamaContainerPtr tama = (TamaContainerPtr)smanager->get_output(wbuf, 1); + int length = 3; - smanager->set_outputSize(1, sizeof(TamaContainer)*3); + smanager->set_outputSize(1, sizeof(ObjContainer)+sizeof(ObjData)*(length-1)); smanager->setup_outputData(); + + CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0); + ObjContainerPtr tama = (ObjContainerPtr)smanager->get_output(wbuf, 1); + tama->flag = false; p->x += p->vx; p->y += p->vy; @@ -19,9 +23,13 @@ (p->dt1 == 90) || (p->dt1 == 30)) { - Puttama(0, p->x, p->y, &tama[0]); - Puttama(0, p->x, p->y, &tama[1]); - Puttama(0, p->x, p->y, &tama[2]); + tama->flag = true; + tama->type = Tama; + tama->length = length; + + Puttama(0, p->x, p->y, &tama->data[0]); + Puttama(0, p->x, p->y, &tama->data[1]); + Puttama(0, p->x, p->y, &tama->data[2]); } p->dt1++; p->task = STATE3;
--- a/ppe/chara_state7.cc Fri Dec 31 15:50:44 2010 +0900 +++ b/ppe/chara_state7.cc Fri Dec 31 19:19:13 2010 +0900 @@ -1,5 +1,6 @@ #include "task_base.h" #include "task_object.h" +#include "../ObjectType.h" SchedDefineTask(State7); @@ -7,17 +8,30 @@ run(SchedTask *smanager, void *rbuf, void *wbuf) { CHARACTER *p = (CHARACTER*)smanager->get_input(rbuf, 0); - TamaContainerPtr tama = (TamaContainerPtr)smanager->get_input(rbuf, 1); + int length = 1; + + smanager->set_outputSize(1, sizeof(ObjContainer)+sizeof(ObjData)*(length-1)); + smanager->setup_outputData(); + + CHARACTER *q = (CHARACTER*)smanager->get_output(wbuf, 0); + ObjContainerPtr tama = (ObjContainerPtr)smanager->get_output(wbuf, 1); + tama->flag = false; p->x += p->vx; p->y += p->vy; if((p->dt1 == 60) || (p->dt1 == 90) || (p->dt1 == 30)) { - Puttama(1, p->x, p->y, tama); + tama->flag = true; + tama->type = Tama; + tama->length = length; + + + Puttama(1, p->x, p->y, &tama->data[0]); } p->dt1++; p->task = STATE7; - smanager->swap(); + + *q = *p; return 0; }
--- a/ppe/tama.cc Fri Dec 31 15:50:44 2010 +0900 +++ b/ppe/tama.cc Fri Dec 31 19:19:13 2010 +0900 @@ -1,10 +1,9 @@ #include "task_object.h" void -Puttama(int type, float x, float y, TamaContainerPtr tama) +Puttama(int type, float x, float y, ObjDataPtr tama) { - tama->flag = true; - tama->type = type; + tama->tama_type = type; tama->x = x; tama->y = y; }
--- a/ppe/task_object.h Fri Dec 31 15:50:44 2010 +0900 +++ b/ppe/task_object.h Fri Dec 31 19:19:13 2010 +0900 @@ -109,17 +109,28 @@ } CollisionProperty, *CollisionPropertyPtr; -typedef struct TamaContainer { - bool flag; +typedef struct ObjData { + int tama_type; + int charano; + int task; + + float x, y; + float vx, vy; +} ObjData, *ObjDataPtr; +typedef struct ObjContainer { + bool flag; + int length; int type; - float x, y; -} TamaContainer, *TamaContainerPtr; + + ObjData data[1]; +} ObjContainer, *ObjContainerPtr; + CHARACTER * noaction(CHARACTER *p); CHARACTER * delete_chara(CHARACTER *p); void Bom(int x, int y, int *bomend, bomchar *bchar); -void Puttama(int type, float x, float y, TamaContainerPtr tama); +void Puttama(int type, float x, float y, ObjDataPtr tama); void Putenemy(int charano, float x, float y, float vx, float vy, int task); #endif
--- a/property.h Fri Dec 31 15:50:44 2010 +0900 +++ b/property.h Fri Dec 31 19:19:13 2010 +0900 @@ -25,26 +25,21 @@ } CollisionProperty, *CollisionPropertyPtr; -typedef struct TamaContainer { - bool flag; - int type; +typedef struct ObjData { + int tama_type; + int charano; + int task; - int tama_type; float x, y; -} TamaContainer, *TamaContainerPtr; + float vx, vy; +} ObjData, *ObjDataPtr; typedef struct ObjContainer { bool flag; + int length; int type; - int tama_type; - int number; - float x, y; - float w, h; - int color; - float angle; - short middlex, middley; - float scalex, scaley; + ObjData data[1]; } ObjContainer, *ObjContainerPtr; #endif
--- a/state_task.cc Fri Dec 31 15:50:44 2010 +0900 +++ b/state_task.cc Fri Dec 31 19:19:13 2010 +0900 @@ -16,6 +16,7 @@ #include "Func.h" #include "property.h" #include "state_task.h" +#include "ObjectType.h" extern SpriteTable sptable[DEFOBJ]; extern TaskManager *tmanager; @@ -118,58 +119,38 @@ p->state = state_list[num]; } -void -checkSingleTama(SchedTask *s, void *chara, void *tama) -{ - CHARACTER *p = (CHARACTER*)chara; - TamaContainer *new_tama = (TamaContainerPtr)tama; - - if (new_tama->flag == true) { - Puttama(new_tama->type, new_tama->x, new_tama->y); - Puttama(new_tama[0].type, new_tama[0].x, new_tama[0].y); - Puttama(new_tama[1].type, new_tama[1].x, new_tama[1].y); - Puttama(new_tama[2].type, new_tama[2].x, new_tama[2].y); - } - - int num = GetStateNum(p->task); - p=state_list[num](p); - free(new_tama); -} void checkContainer(SchedTask *s, void *chara, void *obj) { CHARACTER *p = (CHARACTER*)chara; ObjContainer *new_obj = (ObjContainerPtr)obj; - + + if (new_obj->flag == true) { + int length = new_obj->length; + int type = new_obj->type; + + switch(type) { + case Tama: + for(int i=0; i < length; i++) { + ObjDataPtr data = &new_obj->data[i]; + Puttama(data->tama_type, data->x, data->y); + } + case Enemy: + for(int i=0; i < length; i++) { + ObjDataPtr data = &new_obj->data[i]; + int task_num = GetStateNum(data->task); + Putenemy(data->charano, data->x, data->y, data->vx, data->vy, + state_list[task_num]); + } + } + } + int num = GetStateNum(p->task); + p->state = state_list[num]; - - int num = GetStateNum(p->task); - p=state_list[num](p); free(new_obj); } -CHARACTER* -sendContainerTask(CHARACTER *p) -{ - int task_num = p->task; - int data_size = sizeof(ObjContainer) * DATA_LENGTH; - HTaskPtr state_task = tmanager->create_task(task_num); - ObjContainerPtr obj = (ObjContainerPtr)tmanager->allocate(data_size); - - state_task->set_inData(0, p, sizeof(CHARACTER)); - state_task->set_inData(1, obj, data_size); - - state_task->set_outData(0, p, sizeof(CHARACTER)); - state_task->set_outData(1, obj, data_size); - - state_task->set_post(checkContainer, (void*)p, (void*)obj); - - state_task->set_cpu(SPE_ANY); - state_task->spawn(); - - return p; -} CHARACTER* SimpleStateTask(CHARACTER *p) @@ -187,6 +168,7 @@ return p; } + CHARACTER* withJikiTask(CHARACTER *p) { @@ -204,21 +186,22 @@ return p; } + CHARACTER* putTamaTask1(CHARACTER *p) { int task_num = p->task; - int tama_size = sizeof(TamaContainer)*DATA_LENGTH; + int obj_size = sizeof(ObjContainer)+sizeof(ObjData)*DATA_LENGTH; HTaskPtr state_task = tmanager->create_task(task_num); - TamaContainerPtr tama = (TamaContainerPtr)tmanager->allocate(tama_size); + ObjContainerPtr obj = (ObjContainerPtr)tmanager->allocate(obj_size); + obj->length = 0; state_task->set_inData(0, p, sizeof(CHARACTER)); - state_task->set_inData(1, tama, tama_size); state_task->set_outData(0, p, sizeof(CHARACTER)); - state_task->set_outData(1, tama, 0); + state_task->set_outData(1, obj, 0); - state_task->set_post(checkSingleTama, (void*)p, (void*)tama); + state_task->set_post(checkContainer, (void*)p, (void*)obj); state_task->set_cpu(SPE_ANY); state_task->spawn(); @@ -226,6 +209,7 @@ return p; } + CHARACTER* noaction(CHARACTER *p) {