Mercurial > hg > Members > koba > t_dandy
view state_task.cc @ 27:871f7d9a2f35
running.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 27 Dec 2010 17:21:24 +0900 |
parents | c4210c1053e8 |
children | 813f5461daab |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include "SDL_opengl.h" #include "object.h" #include "Character.h" #include "Character_state.h" #include "tokuten.h" #include "collision.h" #include "bom.h" #include "count2.h" #include "sgoex.h" #include "sankaku.h" #include "tama.h" #include "TaskManager.h" #include "Func.h" #include "property.h" #include "state_task.h" extern SpriteTable sptable[DEFOBJ]; extern TaskManager *tmanager; CHARACTER *kyeenemyno; CHARACTER *tekino0; CHARACTER *enemy_part1; CHARACTER *enemy_part2; CHARACTER *enemy_part3; CHARACTER *enemy_part4; CHARACTER *enemy_part5; //int tekino0; int rinkx; int rinky; int rinkf1 = 0, rinkf2 = 0; CHARACTER *asteroiddt[200]; int asteroidi = 0; int enemyfaste = 0; int fastebos = 0; State state_list[LIST_NUM]; int GetStateNum(int task_num) { int num = task_num % LIST_NUM; return num; } void SetTaskState(int task_num, CHARACTER *(state)(CHARACTER *chara)) { int num = GetStateNum(task_num); state_list[num] = state; } void initStateList() { SetTaskState(DELETE_CHARA, delete_chara); SetTaskState(STATE0, chara_state0); SetTaskState(STATE1, chara_state1); SetTaskState(STATE2, chara_state2); SetTaskState(STATE3, chara_state3); SetTaskState(STATE4, chara_state4); SetTaskState(STATE5, chara_state5); SetTaskState(STATE6, chara_state6); SetTaskState(STATE7, chara_state7); #if 0 SetTaskState(STATE8, chara_state8); SetTaskState(STATE9, chara_state9); SetTaskState(STATE10, chara_state10); SetTaskState(STATE11, chara_state11); SetTaskState(STATE12, chara_state12); SetTaskState(STATE13, chara_state13); #endif SetTaskState(STATE20, chara_state20); SetTaskState(STATE21, chara_state21); SetTaskState(STATE22, chara_state22); SetTaskState(STATE23, chara_state23); #if 0 SetTaskState(STATE24, chara_state24); SetTaskState(STATE25, chara_state25); SetTaskState(STATE26, chara_state26); SetTaskState(STATE27, chara_state27); SetTaskState(STATE28, chara_state28); SetTaskState(STATE29, chara_state29); #endif SetTaskState(STATE30, chara_state30); #if 0 SetTaskState(STATE31, chara_state31); SetTaskState(STATE32, chara_state32); SetTaskState(STATE33, chara_state33); SetTaskState(STATE34, chara_state34); SetTaskState(STATE35, chara_state35); SetTaskState(STATE40, chara_state40); SetTaskState(STATE41, chara_state41); SetTaskState(STATE400, chara_state400); SetTaskState(STATE401, chara_state401); SetTaskState(STATE402, chara_state402); SetTaskState(STATE410, chara_state410); SetTaskState(STATE411, chara_state411); SetTaskState(STATE500, chara_state500); SetTaskState(STATE501, chara_state501); SetTaskState(STATE600, chara_state600); SetTaskState(STATE601, chara_state601); SetTaskState(STATE602, chara_state602); #endif } void updateState(SchedTask *s, void *chara, void *arg) { CHARACTER *p = (CHARACTER*)chara; int num = GetStateNum(p->task); 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); } int num = GetStateNum(p->task); p=state_list[num](p); free(new_tama); } CHARACTER* SimpleStateTask(CHARACTER *p) { int task_num = p->task; HTaskPtr state_task = tmanager->create_task(task_num); state_task->add_inData(p, sizeof(CHARACTER)); state_task->add_outData(p, sizeof(CHARACTER)); state_task->set_post(updateState, (void*)p, NULL); state_task->set_cpu(SPE_ANY); state_task->spawn(); return p; } CHARACTER* withJikiTask(CHARACTER *p) { int task_num = p->task; HTaskPtr state_task = tmanager->create_task(task_num); state_task->add_inData(p, sizeof(CHARACTER)); state_task->add_inData(&jiki, sizeof(player)); state_task->add_outData(p, sizeof(CHARACTER)); state_task->set_post(updateState, (void*)p, NULL); state_task->set_cpu(SPE_ANY); state_task->spawn(); return p; } CHARACTER* putTamaTask1(CHARACTER *p) { int task_num = p->task; HTaskPtr state_task = tmanager->create_task(task_num); TamaContainerPtr tama = (TamaContainerPtr)tmanager->allocate(sizeof(TamaContainer)); state_task->add_inData(p, sizeof(CHARACTER)); state_task->add_inData(tama, sizeof(TamaContainer)); state_task->add_outData(p, sizeof(CHARACTER)); state_task->add_outData(tama, sizeof(TamaContainer)); state_task->set_post(checkSingleTama, (void*)p, (void*)tama); state_task->set_cpu(SPE_ANY); state_task->spawn(); return p; } CHARACTER* noaction(CHARACTER *p) { p->state = noaction; return p; } CHARACTER* delete_chara(CHARACTER *p) { CHARACTER *parent = p; p->f = FALSE; p->state = noaction; p->collision = noaction; return parent; } CHARACTER* chara_state0(CHARACTER *p) { p->task = STATE0; return SimpleStateTask(p); } CHARACTER* chara_state1(CHARACTER *p) { p->task = STATE1; return SimpleStateTask(p); } CHARACTER* chara_state2(CHARACTER *p) { p->task = STATE2; return SimpleStateTask(p); } CHARACTER* chara_state3(CHARACTER *p) { p->task = STATE3; return putTamaTask1(p); } CHARACTER* chara_state4(CHARACTER *p) { p->task = STATE4; return withJikiTask(p); } CHARACTER* chara_state5(CHARACTER *p) { p->task = STATE5; return withJikiTask(p); } CHARACTER* chara_state6(CHARACTER *p) { p->task = STATE6; return withJikiTask(p); } CHARACTER* chara_state7(CHARACTER *p) { p->task = STATE7; return putTamaTask1(p); } #if 0 // state1 boss patern CHARACTER * chara_state8(CHARACTER *p) { if(p->y < 520) { tekino0 = p; kyeenemyno = p; p->y += p->vy; count++; DefSpriteEx(p->charano, 16*4, 32*4); PutSpriteEx(p->charano, (p->x * 4), (p->y * 4), 0.2, 0.2, 1); p->dt1 = 512; p->s = 0.125; p->state = chara_state8; return p; } p->state = chara_state9; return p; } CHARACTER * chara_state9(CHARACTER *p) { if(p->s <= 2) { p->s += 0.05; p->y -= 12; count++; DefSpriteEx(54, 16*4, 32*4); PutSpriteEx(54, (p->x * 4), (p->y * 4), p->s, p->s, 1); p->state = chara_state9; return p; } count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, p->s, p->s, 1); rinkx = p->x; rinky = p->y; Putenemy(5, rinkx - 16, rinky - 16, 1, 0, chara_state10); Putenemy(5, rinkx - 16, rinky - 16, -1, 0, chara_state10); p->state = chara_state11; p->dt1 = 8192; return p; } CHARACTER * chara_state10(CHARACTER *p) { if(p->dt1 < 48) { p->x += p->vx; p->y += p->vy; p->dt1++; p->state = chara_state10; //PutSprite(count, p->x, p->y, return p; } rinkf1 = 1; p->dt1 = rinkx; p->dt2 = rinky; p->state = chara_state13; return p; } CHARACTER * chara_state11(CHARACTER *p) { if(rinkf1 == 0) { count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, p->s, p->s, 1); p->state = chara_state11; return p; } p->dt1 = 0; p->dt2 = 0; p->state = chara_state12; return p; } CHARACTER * chara_state12(CHARACTER *p) { if(fastebos > 60*60) { if(p->y > 240+32) { p->state = delete_chara; } p->y += 3; rinky += 3; count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, 2, 2, 1); p->state = chara_state12; return p; } if(p->dt1 <= 60) { if(jiki.x + 15 - rinkx < -5) { p->vx = -0.8; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +0.8; } else p->vx = 0; rinkx = p->x; rinky = p->y; } if((p->dt1 > 60) && (p->dt1 <= 70)) { if(p->dt1 % 2 == 1) { Puttama(0, rinkx - 16, rinky); Puttama(0, rinkx, rinky); Puttama(0, rinkx + 16, rinky); } } if((p->dt1 > 180) && (p->dt1 <= 240)) { if(p->dt1 % 2 == 1) { rinkf2 = 1; Puttama(2, rinkx - 16, p->y - 32); Puttama(3, rinkx + 32 - 16, p->y - 32); } else { rinkf2 = 2; } } if(p->dt1 > 240) { rinkf2 = 2; } if((p->dt1 > 240) && (p->dt1 <= 400)) { count++; PutSprite(count, rinkx - 16, rinky + 32, 58 + p->dt1 % 4); } if((p->dt1 > 300) && (p->dt1 <= 400)) { rinkf2 = 3; if(jiki.x + 15 - rinkx < -5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; Puttama(4, rinkx - 8, rinky + 16); } if((p->dt1 > 400) && (p->dt1 <= 500)) { rinkf2 = 4; if(jiki.x + 15 - rinkx > 5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; } if(p->dt1 > 500) { rinkf2 = 5; if(jiki.x + 15 - rinkx < -5) { p->vx = -1; } else if(jiki.x + 15 - rinkx > 5) { p->vx = +1; } else p->vx = 0; p->x += p->vx; rinkx = p->x; rinky = p->y; } if(p->dt1 > 600) { rinkf2 = 0; p->dt1 = 0; } fastebos++; p->dt1++; count++; DefSpriteEx(54, 16, 32); PutSpriteEx(54, p->x, p->y, 2, 2, 1); return p; } CHARACTER * chara_state13(CHARACTER *p) { if(tekino0->f == FALSE){ Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x += rinkx - p->dt1; p->y += rinky - p->dt2; p->dt1 = rinkx; p->dt2 = rinky; if(rinkf2 == 1) { if(p->x > rinkx) { Puttama(2, p->x + 32, p->y); } if(p->x < rinkx) { Puttama(3, p->x, p->y); } } if(rinkf2 == 4) { count++; PutSprite(count, p->x, p->y + 56, 58+filpcount % 4); } if(rinkf2 == 5) { if(p->x > rinkx) { Puttama(5, p->x + 8, p->y + 24); } if(p->x < rinkx) { Puttama(5, p->x + 8, p->y + 24); } } return p; } #endif CHARACTER * chara_state20(CHARACTER *p) { p->task = STATE20; return SimpleStateTask(p); } CHARACTER * chara_state21(CHARACTER *p) { p->task = STATE21; return SimpleStateTask(p); } //ここまでgetate boss CHARACTER * chara_state22(CHARACTER *p) { return SimpleStateTask(p); } CHARACTER * chara_state23(CHARACTER *p) { // p=asteroid(p); return p; } #if 0 CHARACTER * chara_state24(CHARACTER *p) { kyeenemyno = p; tekino0 = 0; enemy_part1 = p->next; enemy_part2 = enemy_part1->next; enemy_part3 = enemy_part2->next; enemy_part4 = enemy_part3->next; enemy_part5 = enemy_part4->next; rinkx = 0; rinky = 0; rinkf1 = 0; rinkf2 = 0; p->state = chara_state25; return p; } CHARACTER * chara_state25(CHARACTER *p) { int amari; if(p->dt1 <= 360) { p->x = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } if(p->dt1 > 360) { p->x = Mycos(p->dt1) * 30 * -1 /SANKAKU + 142 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } count++; PutSprite(count, p->x - 42, p->y, 64); amari = rand() % 160; if((amari == 1) && (enemy_part5->f == TRUE)) { p->state = chara_state26; rinkf1 = 1; } if((amari == 2) && (enemy_part1->f == TRUE)) { p->state = chara_state27; rinkf1 = 5; rinkx = 0; return p; } if((enemy_part5->f == TRUE) && (enemy_part1->f != TRUE)) { p->state = chara_state28; } p->dt1 += 3; if(p->dt1 == 720) { p->dt1 = 0; } return p; } CHARACTER * chara_state26(CHARACTER *p) { if((p->dt2 > 50) && (p->dt2 < 100)) { rinkf1 = 2; } if(p->dt2 > 100) { rinkf1 = 3; } if(p->dt2 == 400) { rinkf1 = 4; } count++; PutSprite(count, p->x - 42, p->y, 64); if(p->dt2 == 401) { p->dt2 = 0; rinkf1 = 0; p->state = chara_state25; return p; } p->dt2++; return p; } CHARACTER * chara_state27(CHARACTER *p) //rocket punch { if((p->dt2 > 50) && (p->dt2 < 60) && (p->x > -24) && (p->y > -24)) { rinkf1 = 6; rinkx -= 4; p->x -= 4; p->y -= 4; } if(p->dt2 == 80) { rinkf1 = 7; } if(p->dt2 == 81) { rinkf1 = 8; } if(p->dt2 == 124) { rinkf1 = 9; } if(p->dt2 == 400) { rinkf1 = 10; } if(p->dt2 == 444) { rinkf1 = 11; } if(p->dt2 == 500) { rinkf1 = 12; } if((p->dt2 > 80) && (p->dt2 < 200)) { if((rinkx != 0) && (p->dt2 % 2 == 1)) { rinkx++; p->x++; p->y++; } } count++; PutSprite(count, p->x - 32, p->y, 6); if(rinkf1 == 12) { p->dt2 = 0; rinkf1 = 0; rinkx = 0; p->state = chara_state25; return p; } p->dt2++; return p; } CHARACTER * chara_state28(CHARACTER *p) { if (p->dt1 <= 360) { p->x = Mycos(p->dt1) * 30 / SANKAKU + 82 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } if (p->dt1 > 360) { p->x = Mycos(p->dt1) * 30 * -1 / SANKAKU + 142 + 32; p->y = Mysin(p->dt1) * 30 / SANKAKU + 30; } count++; PutSprite(count, p->x - 42, p->y, 64); if (p->dt1 % 30 == 3) { Putenemy(24, p->x + 14, p->y + 14, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state29); } p->dt1 += 3; return p; } CHARACTER * chara_state29(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if(p->dt1 % 18 == 1) { Puttama(0, p->x, p->y); } p->dt1++; return p; } #endif CHARACTER * chara_state30(CHARACTER *p) { p->task = STATE30; return SimpleStateTask(p); } #if 0 CHARACTER * chara_state31(CHARACTER *p) //right hand { if((enemy_part3->f == FALSE) || (kyeenemyno->f == FALSE)) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } if(rinkf1 == 0) { p->x = kyeenemyno->x + 40; p->y = kyeenemyno->y + 28; p->dt2 = 0; } if(rinkf1 == 5) { p->x = kyeenemyno->x + 52; p->y = kyeenemyno->y; count++; PutSprite(count, p->x - 4, p->y - 20, 80 + p->dt2 % 4); p->dt2++; } if(rinkf1 == 6) { if(p->y < 240 - 40) { p->y += 6; } else { return p; } count++; PutSprite(count, p->x - 4, p->y - 20, 90 + p->dt2 % 4); p->dt2++; } if(rinkf1 == 7) { Putenemy(22, p->x + 14, p->y + 14, 0, 0, chara_state40); return p; } if(rinkf1 == 11) { if(p->y + 20 != p->y) { p->y--; } else { return p; } count++; PutSprite(count, p->x + 8, p->y + 44, 58 + p->dt2 % 4); p->dt2++; } return p; } CHARACTER * chara_state32(CHARACTER *p) //left hand { if ((enemy_part4->f == FALSE) || (kyeenemyno->f == FALSE)) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 40; p->y = kyeenemyno->y + 28; if (rinkf1 == 5) { p->x = kyeenemyno->x - 24 + 4; p->y = kyeenemyno->y + 28; p->charano = enemystate[20].charano; } if (rinkf1 == 11) { p->charano = enemystate[14].charano; } if (rinkf1 == 7) { Putenemy(23, p->x + 14, p->y + 14, 0, 0, chara_state41); // rinkf1=8; return p; } return p; } CHARACTER * chara_state33(CHARACTER *p) // right shoulder { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x + 32; p->y = kyeenemyno->y; if (rinkf1 == 5) { p->x = kyeenemyno->x + 32 - 4; p->y = kyeenemyno->y; p->charano = enemystate[19].charano; } if (rinkf1 == 6) { p->charano = enemystate[11].charano; } return p; } CHARACTER * chara_state34(CHARACTER *p) //left shoulder { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 32; p->y = kyeenemyno->y; if (rinkf1 == 5) { p->charano = enemystate[21].charano; } if (rinkf1 == 6) { p->charano = enemystate[12].charano; } return p; } CHARACTER * chara_state35(CHARACTER *p) // bust { if (kyeenemyno->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x; p->y = kyeenemyno->y + 32; if (rinkf1 == 1) { p->charano = enemystate[16].charano; } if (rinkf1 == 2) { count++; PutSprite(count, p->x - 10, p->y + 16, 58 + p->dt2 % 4); count++; PutSprite(count, p->x + 10, p->y + 16, 58 + p->dt2 % 4); p->dt2++; } if (rinkf1 == 3) { count++; PutSprite(count, p->x - 10, p->y + 16, 58 + p->dt2 % 4); count++; PutSprite(count, p->x + 10, p->y + 16, 58 + p->dt2 % 4); if (p->dt2 % 20 == 1) { Puttama(7, p->x, p->y + 16); Puttama(7, p->x + 20, p->y + 16); } p->dt2++; } if (rinkf1 == 4) { p->charano = enemystate[15].charano; p->dt2 = 0; } return p; } CHARACTER * chara_state40(CHARACTER *p) //arm vulkan { if (enemy_part1->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } if ((rinkf1 == 8) && (p->dt1 % 3 == 1)) { if ((p->dt2 < 16)) { p->dt2++; DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss); } else { // rinkf1=9; return p; } } if (rinkf1 == 9) { if (p->dt1 % 15 == 1) { Puttama(8, p->x, p->y); } } if (rinkf1 == 10) { if (p->dt2 != 0) { p->dt2--; DefSprite(76, "boss2_rightarm_b", 16, p->dt2, 480, boss); } else { p->f = FALSE; p->state = delete_chara; p->collision = noaction; // rinkf1=11; } } p->dt1++; return p; } CHARACTER * chara_state41(CHARACTER *p) //left arm up arm vulkan { if (enemy_part2->f == FALSE) { Bom(p->x, p->y); p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; } p->x = kyeenemyno->x - 20 - 7; p->y = kyeenemyno->y + 28 + 15; if ((rinkf1 == 8) && (p->dt1 % 3 == 1)) { if ((p->dt2 < 16)) { p->dt2++; DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss); /*左腕アップアーム砲 */ } else { rinkf1 = 9; return p; } } if (rinkf1 == 9) { if (p->dt1 % 15 == 1) { Puttama(9 + rand() % 2, p->x, p->y); } } if (rinkf1 == 10) { if (p->dt2 != 0) { p->dt2--; DefSprite(77, "boss2_leftarmbattery", p->dt2, 16, 480, boss); } else { p->f = FALSE; p->state = delete_chara; p->collision = noaction; return p; // rinkf1=11; } } p->dt1++; return p; } CHARACTER * chara_state400(CHARACTER *p) { return SimpleStateTask(p); } CHARACTER * chara_state401(CHARACTER *p) { p->vx++; p->x += p->vx / 8; if (p->x > (jiki.x - 32)) { p->vy--; } p->y += p->vy / 8; if (p->dt1 % 50 == 37) { Puttama(1, p->x + 8, p->y + 24); } p->dt1++; return p; } CHARACTER * chara_state402(CHARACTER *p) { p->vx--; p->x += p->vx / 8; if (p->x < (jiki.x + 32)) { p->vy--; } p->y += p->vy / 8; if (p->dt1 % 50 == 37) { Puttama(1, p->x + 8, p->y + 24); } p->dt1++; return p; } CHARACTER * chara_state410(CHARACTER *p) { kyeenemyno = p; p->state = chara_state411; return p; } CHARACTER * chara_state411(CHARACTER *p) { if (p->dt2 > 356) { p->vx = -1; } if (p->dt2 < -398) { p->vx = 1; } if ((p->dt1) % 62 == 0) Putenemy(41, p->x, p->y, (int) -Mycos(p->dt1 / 16) * 4 / SANKAKU, (int) -Mysin(p->dt1 / 16) * 4 / SANKAKU, chara_state7); if ((p->dt1) % 13 == 0) Puttama(11, p->x + 32, p->y + 32); p->dt2 += p->vx; p->dt1 += p->dt2 / 4; p->x = jiki.x - 16 + Mycos(p->dt1 / 16) * 128 / SANKAKU; p->y = jiki.y - 16 + Mysin(p->dt1 / 16) * 128 / SANKAKU; 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; } return p; } CHARACTER * chara_state500(CHARACTER *p) { p->s = 0; kyeenemyno = p; p->dt2++; p->dt2 %= 512; p->dt1++; count++; DefSpriteEx(100, 16, 16); // PutSprite(count, enemy[tekino].x + 16, // enemy[tekino].y + 16, 100); PutSpriteEx(100, p->x + 16, p->y + 16, 2, 2, p->dt1); if (p->dt1 % (5 + p->dt2 / 8) == 1) { if (rand() % 2 == 1) Putenemy(24, p->x, p->y, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state501); else Putenemy(rand() % 2 + 1, p->x, p->y, (int) Mycos(p->dt1 / 4) * 4 / SANKAKU, (int) -Mysin(p->dt1 / 4) * 4 / SANKAKU, chara_state501); } if (p->dt1 == 50) { /*Putenemy(44,0,0,1,1,411); */ } return p; } CHARACTER * chara_state501(CHARACTER *p) { p->x += p->vx; p->y += p->vy; if(p->dt1 % 32 == 1) { Puttama(11, p->x, p->y); } p->dt1++; return p; } CHARACTER * chara_state600(CHARACTER *p) { kyeenemyno = p; p->dt1 += 30; p->dt2++; p->dt1 %= 360; p->x += Mycos(p->dt1) * 4 / SANKAKU; p->y += Mysin(p->dt1) * 4 / SANKAKU; Puttama(11, p->x + 16, p->y + 16); Puttama(11, p->x + 32, p->y + 48); Puttama(11, p->x + 48, p->y + 16); if (p->dt2 > 240) p->state = chara_state601; 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; return p; } CHARACTER * chara_state601(CHARACTER *p) { 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, chara_state400); 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 = chara_state602; } return p; } CHARACTER * chara_state602(CHARACTER *p) { p->dt2++; Putenemy(24, p->x + 14, p->y + 14, (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), (rand() % 5 + 0.5) * (rand() % 2 == 1 ? -1 : 1), chara_state29); if (p->dt2 > 1024) { p->state = chara_state600; p->dt2 = 0; } return p; } CHARACTER * asteroid(CHARACTER *p) { 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 p; } #endif