Mercurial > hg > Members > kono > tree_dandy2
view Character.c @ 21:b7654db65a34
add TODO
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 10 Dec 2010 19:04:17 +0900 |
parents | 972a7f233b23 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "syokika.h" #include "bool.h" #include <SDL.h> #include "SDL_opengl.h" #include "object.h" #include "Character.h" #include "Character_state.h" #include "count2.h" #include "tokuten.h" #include "schedule.h" #include "sankaku.h" #include "sgoex.h" #include "collision.h" #include "debug.h" #include "error.h" #define CHARACTER_MAX_POOL_SIZE 2048 CHARACTER *active_chara_list; CHARACTER *free_chara_list; const table enemystate[] = ENEMY_STATUS_TABLE; int filpcount = 0; int stage = 0; BOOL tf = FALSE; static int pool_size; int init_chara_list(int num) { if(active_chara_list == NULL) { return extend_chara_list_pool(num); } return 1; } int extend_chara_list_pool(int num) { pool_size = num; __debug("task init start"); int i; CHARACTER *q[num]; for(i = 0; i<num ; i++) { q[i] = (CHARACTER*)malloc(sizeof(CHARACTER)); q[i]->f = FALSE; q[i]->state = noaction; q[i]->collision = noaction; } for(i = 0; i<num-1 ; i++) { q[i]->next = q[i+1]; //q[i]->next->prev = q[i]; } q[num-1]->next = NULL; active_chara_list = (CHARACTER*)malloc(sizeof(CHARACTER)); active_chara_list->f = FALSE; active_chara_list->state = noaction; active_chara_list->collision = noaction; active_chara_list->next = q[0]; //q[0]->prev = active_chara_list; //active_chara_list->prev = q[num-1]; //q[num-1]->next = active_chara_list; CHARACTER *p; for(p = active_chara_list->next; p != NULL ; p = p->next) { if(p != NULL) { __debug("list_test"); } } return 1; } void TFon() { tf = TRUE; } void TFoff() { tf = FALSE; } void Putenemy(int charano, float x, float y, float vx, float vy, CHARACTER * (*action)(CHARACTER *chara)) { CHARACTER *q; for(q = active_chara_list->next; q != NULL ;q = q->next) { if(q->f == FALSE) { break; } } q->state = action; q->collision = atari; q->x = x; q->y = y; q->vx = vx; q->vy = vy; q->tama = tf; q->vit = enemystate[charano].p; q->score = enemystate[charano].sc; q->charano = enemystate[charano].charano; q->s = 0; q->f = TRUE; //q->state = ALIVE; //q->group = ENEMY } CHARACTER * delete_chara(CHARACTER *p) { CHARACTER *parent = p; p->f = FALSE; p->state = noaction; p->collision = noaction; return parent; } void state_update() { CHARACTER *p; for(p = active_chara_list->next; p!= NULL ;p = p->next) { p=(*p->state)(p); } } void collision_detect() { CHARACTER *p; for(p = active_chara_list->next; p!=NULL;p = p->next) { if((p->state != chara_state8) && (p->state != chara_state9)) { p=(*p->collision)(p); } } } void obj_draw() { CHARACTER *p; for(p = active_chara_list->next; p!=NULL;p = p->next) { if(p->f == TRUE) { PutSprite(1, p->x, p->y, p->charano); } } } void outofwindow() { CHARACTER *p; for(p = active_chara_list->next; p!=NULL; p = p->next) { if((p->state != chara_state8) && (p->state != chara_state9)) { if ((p->y > 964 + 32) || (p->x > 1688 + 50) || (p->y < 0 - 128) || (p->x < 0 - 200)) { p->f = FALSE; p->state = delete_chara; p->collision = noaction; } } } }