annotate TaskManager/Test/test_render/chain.cpp @ 382:1c3f84a6f5d0 draft

chain.cpp update
author kazz@kazzone.cr.ie.u-ryukyu.ac.jp
date Mon, 03 Aug 2009 04:22:11 +0900
parents bdeb7a73285b
children 3d1e86396d16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
1 #include <iostream.h>
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include <math.h>
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 #include "SceneGraphRoot.h"
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 #include "SGList.h"
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
5
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #define FALSE 0
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 #define TRUE !FALSE
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
8 #define CHAIN_LEN 50
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
9
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 static double m = 100.0;
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
11 static double k = 7000.0;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 static double g = 9.8;
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
13 static double dt = 0.003;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
14 static double chain_width = 10;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 static double safe = 0.995;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
16
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 typedef struct {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 double x, y, next_x, next_y;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 double vx, vy, next_vx, next_vy;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 int can_move;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 } CHAIN_VARS;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
22
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 CHAIN_VARS cv[CHAIN_LEN];
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
24
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 init_chain_vars(CHAIN_VARS *cv) {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 cv->can_move = TRUE;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
31
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 set_vector(CHAIN_VARS *cv, SceneGraphPtr sg) {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 sg->xyz[0] = (float)cv->next_x;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 sg->xyz[1] = (float)cv->next_y;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 sg->xyz[2] = 0.0f;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
38
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
39
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 static void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 chain_move_ope(SceneGraphPtr node, int screen_w, int screen_h)
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 Pad *pad = sgroot->getController();
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
44
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 if (pad->circle.isHold()) {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 cv[CHAIN_LEN-1].can_move = FALSE;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
47 if (pad->left.isHold()) {
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
48 cv[CHAIN_LEN-1].x += -5.0;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
49 } else if (pad->right.isHold()) {
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
50 cv[CHAIN_LEN-1].x += 5.0;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
51 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
52
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 if (pad->up.isHold()) {
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
54 cv[CHAIN_LEN-1].y += -5.0;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
55 } else if (pad->down.isHold()) {
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
56 cv[CHAIN_LEN-1].y += 5.0;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
57 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
58 } else {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
59 cv[CHAIN_LEN-1].can_move = TRUE;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
61 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
62
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
63 void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
64 chain_move(SceneGraphPtr sg, int w, int h)
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
65 {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 int id = sg->id;
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
67 if(id == 0) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
68 for(int cnt = 0; cnt < 600; cnt++) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
69 for(int i = 0; i < CHAIN_LEN; i++) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
70 if(cv[i].can_move) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
71 double dx = cv[i-1].x - cv[i].x;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
72 double dy = cv[i-1].y - cv[i].y;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
73 double l = sqrt(dx * dx + dy * dy);
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
74 double a = k * (l - chain_width) / m;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
75 double ax = a * dx / l;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
76 double ay = a * dy / l;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
77 if(i < CHAIN_LEN - 1) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
78 dx = cv[i+1].x - cv[i].x;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
79 dy = cv[i+1].y - cv[i].y;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
80 l = sqrt(dx * dx + dy * dy);
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
81 a = k * (l - chain_width) / m;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
82 ax += a * dx / l;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
83 ay += a * dy / l;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
84 }
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
85 ay += g;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
86 cv[i].vx *= safe;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
87 cv[i].vy *= safe;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
88 cv[i].next_vx = cv[i].vx + ax * dt;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
89 cv[i].next_vy = cv[i].vy + ay * dt;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
90 cv[i].next_x = cv[i].x + cv[i].vx * dt;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
91 cv[i].next_y = cv[i].y + cv[i].vy * dt;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
92 } else {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
93 cv[i].next_x = cv[i].x;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
94 cv[i].next_y = cv[i].y;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
95 }
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
96 }
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
97 for(int i = 0; i < CHAIN_LEN; i++) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
98 cv[i].vx = cv[i].next_vx;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
99 cv[i].vy = cv[i].next_vy;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
100 cv[i].x = cv[i].next_x;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
101 cv[i].y = cv[i].next_y;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
102 }
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
103 }
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
104 // cout << id << ", " << sg->xyz[1] << endl;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
105 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
106 set_vector(&cv[id], sg);
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
107 int p, n;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
108 p = n = id;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
109 if(p != 0) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
110 p--;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
111 }
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
112 if(n != CHAIN_LEN - 1) {
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
113 n++;
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
114 }
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
115 sg->angle[2-(id%2)*2]
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
116 = 90 + atan((cv[p].next_y - cv[n].next_y) / (cv[p].next_x - cv[n].next_x)) * 180 / M_PI;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
117 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
118
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
119 void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
120 chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg)
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
121 {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
122
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
123 }
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
124
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
125 void
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
126 chain_init(int w, int h)
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
127 {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
128 SceneGraphPtr root_chain, chain;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
129 CHAIN_VARS rcv;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
130
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
131 sgroot->createFromXMLfile("xml_file/chain.xml");
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
132
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
133 root_chain = sgroot->createSceneGraph(CHAIN);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
134 root_chain->set_move_collision(chain_move_ope, chain_collision);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
135 init_chain_vars(&rcv);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
136 rcv.next_x = w / 2;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
137 rcv.next_y = 0.0;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
138 set_vector(&rcv, root_chain);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
139
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
140 for(int i = 0; i < CHAIN_LEN; i++) {
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
141 chain = sgroot->createSceneGraph(CHAIN);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
142 chain->id = i;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
143 init_chain_vars(&cv[i]);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
144 cv[i].x = 0;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
145 cv[i].y = chain_width * i;
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
146 set_vector(&cv[i], chain);
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
147 chain->angle[1] = -90 * (i % 2);
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
148 chain->set_move_collision(chain_move, chain_collision);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
149
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
150 root_chain->addChild(chain);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
151 }
382
1c3f84a6f5d0 chain.cpp update
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 378
diff changeset
152 cv[0].can_move = FALSE;
375
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
153
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
154 sgroot->setSceneData(root_chain);
2ae25549dd6a chain.cpp added
kazz@kazzone.ie.u-ryukyu.ac.jp
parents:
diff changeset
155 }