comparison collision_task.cc @ 53:b31bed246abd

fix code and add log.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 25 Jan 2011 17:43:30 +0900
parents 6989f8cb0259
children 3acdeb3dc3e8
comparison
equal deleted inserted replaced
52:150e832193fe 53:b31bed246abd
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include <SDL.h> 3 #include <SDL.h>
4 #include "SDL_opengl.h" 4 #include "SDL_opengl.h"
5 #include "object.h"
6 #include "Character.h" 5 #include "Character.h"
7 #include "Character_state.h"
8 #include "tokuten.h" 6 #include "tokuten.h"
9 #include "collision.h"
10 #include "bom.h" 7 #include "bom.h"
11 #include "count2.h" 8 #include "count2.h"
9 #include "object.h"
12 #include "sgoex.h" 10 #include "sgoex.h"
13 #include "TaskManager.h" 11 #include "TaskManager.h"
14 #include "Func.h" 12 #include "Func.h"
13 #include "ObjectType.h"
15 #include "property.h" 14 #include "property.h"
15
16 16
17 extern SpriteTable sptable[DEFOBJ]; 17 extern SpriteTable sptable[DEFOBJ];
18 extern TaskManager *tmanager; 18 extern TaskManager *tmanager;
19 19
20 CollisionPropertyPtr 20 static CollisionPropertyPtr
21 get_property() 21 get_property(CHARACTER *p)
22 { 22 {
23 CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty)); 23 CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty));
24 24
25 property->collision_type = NO;
25 property->enemycount = 0; 26 property->enemycount = 0;
26 property->tlv3 = tlv3[0]; 27 property->tlv3 = tlv3[0];
27 property->laser_lv2 = laser_lv2[0]; 28 property->laser_lv2 = laser_lv2[0];
29 property->p = *p;
28 30
29 memcpy(property->tama_lv1, tama_lv1, sizeof(tama1)*20); 31 memcpy(property->tama_lv1, tama_lv1, sizeof(tama1)*(tama_lv1_end+1));
30 memcpy(property->tama_lv2, tama_lv2, sizeof(tama2)*20); 32 memcpy(property->tama_lv2, tama_lv2, sizeof(tama2)*(tama_lv2_end+1));
31 memcpy(property->laser_lv1, laser_lv1, sizeof(laser)*20); 33 memcpy(property->laser_lv1, laser_lv1, sizeof(laser)*(laser_lv1_end+1));
32 memcpy(property->laser_lv3, laser_lv3, sizeof(laser)*128); 34 memcpy(property->laser_lv3, laser_lv3, sizeof(laser)*128);
33 35
34 return property; 36 return property;
37 }
38
39 static void
40 check_collision()
41 {
42
35 } 43 }
36 44
37 void 45 void
38 free_property(SchedTask *s, void *prop, void *obj) 46 free_property(SchedTask *s, void *prop, void *obj)
39 { 47 {
40 CollisionPropertyPtr property = (CollisionPropertyPtr)prop; 48 CollisionPropertyPtr property = (CollisionPropertyPtr)prop;
49
50 switch(property->collision_type) {
51 check_collision();
52
53 case JIKI:
54 jiki.bf = property->jiki.bf;
55 jiki.zanki = property->jiki.zanki;
56 jiki.muteki = property->jiki.muteki;
57 infg = property->infg;
58 infg_level = property->infg_level;
59 break;
60
61 case TAMALV1:
62 infg = property->infg;
63 memcpy(tama_lv1, property->tama_lv1, sizeof(tama1)*(tama_lv1_end+1));
64 break;
65
66 case TAMALV2:
67 infg = property->infg;
68 memcpy(tama_lv2, property->tama_lv2, sizeof(tama2)*(tama_lv2_end+1));
69 break;
70
71 case TAMALV3:
72 infg = property->infg;
73 break;
74
75 case LASERLV1:
76 infg = property->infg;
77 memcpy(laser_lv1, property->laser_lv1, sizeof(laser)*laser_lv1_end+1);
78 break;
79
80 case LASERLV2:
81 lg.stg -= 26;
82 infg = property->infg;
83 break;
84
85 case LASERLV3:
86 infg = property->infg;
87
88 break;
89
90 default:
91 break;
92 }
93
41 ObjContainer *new_obj = (ObjContainerPtr)obj; 94 ObjContainer *new_obj = (ObjContainerPtr)obj;
42 95
43 if ((new_obj->flag == true) && (new_obj->length == 1)){ 96 if (new_obj->flag == true){
44 ObjDataPtr obj_data = new_obj->data; 97 ObjDataPtr obj_data = new_obj->data;
45 Bom(obj_data->x, obj_data->y); 98 Bom(obj_data->x, obj_data->y);
99
100 enemycount += property->enemycount;
46 } 101 }
47
48 if(lg.stg > property->lg.stg) {
49 lg.stg -= 26;
50 }
51 infg_level = property->infg_level;
52 enemycount += property->enemycount;
53
54 jiki.bf = property->jiki.bf;
55 jiki.zanki = property->jiki.zanki;
56 jiki.muteki = property->jiki.muteki;
57
58 infg = property->infg;
59
60 memcpy(tama_lv1, property->tama_lv1, sizeof(tama1)*20);
61 memcpy(tama_lv2, property->tama_lv2, sizeof(tama2)*20);
62 memcpy(laser_lv1, property->laser_lv1, sizeof(laser)*20);
63 102
64 free(new_obj); 103 free(new_obj);
65 free(prop); 104 free(prop);
66 } 105 }
67 106
68 107
69 CHARACTER* 108 CHARACTER*
70 atari(CHARACTER *p) 109 atari(CHARACTER *p)
71 { 110 {
72 int w, h, charno; 111 int w, h, charno;
73 CollisionPropertyPtr property = get_property(); 112 CollisionPropertyPtr property = get_property(p);
74 113
75 charno = p->charano; 114 charno = p->charano;
76 w = sptable[charno].w; 115 w = sptable[charno].w;
77 h = sptable[charno].h; 116 h = sptable[charno].h;
78 117
79 int obj_size = sizeof(ObjContainer)+sizeof(ObjData)*1; 118 int obj_size = sizeof(ObjContainer);
80 ObjContainerPtr obj = (ObjContainerPtr)tmanager->allocate(obj_size); 119 ObjContainerPtr obj = (ObjContainerPtr)tmanager->allocate(obj_size);
81 obj->flag = false; 120 obj->flag = false;
82 obj->length = 0; 121 obj->length = 0;
83 122
84 HTaskPtr collision_task = tmanager->create_task(ATARI); 123 HTaskPtr collision_task = tmanager->create_task(ATARI);
85 124
86 collision_task->set_param(0,(memaddr)w); 125 collision_task->set_param(0,(memaddr)w);
87 collision_task->set_param(1,(memaddr)h); 126 collision_task->set_param(1,(memaddr)h);
88 collision_task->set_param(2,(memaddr)tama_lv1_end);
89 collision_task->set_param(3,(memaddr)tama_lv2_end);
90 collision_task->set_param(4,(memaddr)laser_lv1_end);
91 127
92 collision_task->set_inData(0, p, sizeof(CHARACTER)); 128 collision_task->set_inData(0, property, sizeof(CollisionProperty));
93 collision_task->set_inData(1, &jiki, sizeof(player)); 129 collision_task->set_inData(1, &jiki, sizeof(player));
94 collision_task->set_inData(2, &lg, sizeof(stge)); 130 collision_task->set_inData(2, &lg, sizeof(stge));
95 collision_task->set_inData(3, &infg, sizeof(stge)); 131 collision_task->set_inData(3, &infg, sizeof(stge));
96 collision_task->set_inData(4, &infg_level, sizeof(int)); 132 collision_task->set_inData(4, &infg_level, sizeof(int));
97 collision_task->set_inData(5, property, sizeof(CollisionProperty)); 133 collision_task->set_inData(5, &tama_lv1_end, sizeof(int));
134 collision_task->set_inData(6, &tama_lv2_end, sizeof(int));
135 collision_task->set_inData(7, &laser_lv1_end, sizeof(int));
98 136
99 collision_task->set_outData(0, p, sizeof(CHARACTER)); 137 collision_task->set_outData(0, property, sizeof(CollisionProperty));
100 collision_task->set_outData(1, property, sizeof(CollisionProperty)); 138 collision_task->set_outData(1, obj, sizeof(ObjContainer));
101 collision_task->set_outData(2, obj, 0);
102 139
103 collision_task->set_post(free_property, (void*)property, (void*)obj); 140 collision_task->set_post(free_property, (void*)property, (void*)obj);
104 collision_task->set_cpu(SPE_ANY); 141 collision_task->set_cpu(SPE_ANY);
105 collision_task->spawn(); 142 collision_task->spawn();
106 143