annotate collision_task.cc @ 14:c7e7971a76d0

fix.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Thu, 16 Dec 2010 15:29:43 +0900
parents e90c4a8f9dc8
children 00c3272a801f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdlib.h>
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <SDL.h>
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "SDL_opengl.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "object.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "Character.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "Character_state.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "tokuten.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "collision.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "bom.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "count2.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "sgoex.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "TaskManager.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "Func.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include "property.h"
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 extern SpriteTable sptable[DEFOBJ];
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 extern TaskManager *tmanager;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 CollisionPropertyPtr
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 get_property(CHARACTER *p)
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 {
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
23 CollisionPropertyPtr property = (CollisionPropertyPtr)tmanager->allocate(sizeof(CollisionProperty));
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
25 property->bomend = bomend;
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 property->infg_level = infg_level;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 property->enemycount = 0;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 property->jiki = jiki;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 property->p = *p;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 property->tlv3 = tlv3[0];
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 property->lg = lg;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 property->infg = infg;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
36 memcpy(property->tama_lv1, &tama_lv1, sizeof(tama1)*20);
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 memcpy(property->tama_lv2, &tama_lv2, sizeof(tama2)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 memcpy(property->laser_lv1, &laser_lv1, sizeof(laser)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 memcpy(property->laser_lv2, &laser_lv2, sizeof(laser)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 memcpy(property->laser_lv3, &laser_lv3, sizeof(laser)*128);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 memcpy(property->bchar, &bchar, sizeof(bomchar)*100);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 return property;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 void
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 free_property(SchedTask *s, void *prop, void *chara)
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 {
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 CollisionPropertyPtr property = (CollisionPropertyPtr)prop;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 CHARACTER *character = (CHARACTER *)chara;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
52 if(bomend > property->bomend) {
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
53 bomend = property->bomend;
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 }
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
55 if(lg.stg > property->lg.stg) {
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 lg.stg -= 26;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 }
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
58 infg_level = property->infg_level;
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 enemycount += property->enemycount;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
7
23d54565aa7b not working.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
61 jiki.bf = property->jiki.bf;
23d54565aa7b not working.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
62 jiki.zanki = property->jiki.zanki;
23d54565aa7b not working.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
63 jiki.muteki = property->jiki.muteki;
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
64
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 *character = property->p;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 infg = property->infg;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 memcpy(tama_lv1, property->tama_lv1, sizeof(tama1)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 memcpy(tama_lv2, property->tama_lv2, sizeof(tama2)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 memcpy(laser_lv1, property->laser_lv1, sizeof(laser)*20);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 memcpy(bchar, property->bchar, sizeof(bomchar)*100);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
73 free(prop);
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
7
23d54565aa7b not working.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
77 CHARACTER *atari(CHARACTER *p)
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 {
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 int w, h, charno;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 CollisionPropertyPtr property = get_property(p);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 charno = p->charano;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 w = sptable[charno].w;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 h = sptable[charno].h;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 HTaskPtr collision_task = tmanager->create_task(ATARI);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 collision_task->set_param(0,(memaddr)w);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 collision_task->set_param(1,(memaddr)h);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 collision_task->set_param(2,(memaddr)enemycount);
8
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
91 collision_task->set_param(3,(memaddr)tama_lv1_end);
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
92 collision_task->set_param(4,(memaddr)tama_lv2_end);
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
93 collision_task->set_param(5,(memaddr)laser_lv1_end);
5
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 collision_task->add_inData(property, sizeof(CollisionProperty));
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 collision_task->add_outData(property, sizeof(CollisionProperty));
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 collision_task->set_post(free_property, property, p);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 collision_task->set_cpu(SPE_ANY);
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 collision_task->spawn();
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 return p;
c9e9b605f08e rename tcollision.cc
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 }