Mercurial > hg > Members > tkaito > task_dandy
comparison stage_init.cc @ 26:6bea374ee604
global alloc test.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 10 Dec 2010 02:20:37 +0900 |
parents | 3fb8a6a34e24 |
children | 34fde39c0a31 |
comparison
equal
deleted
inserted
replaced
23:3fb8a6a34e24 | 26:6bea374ee604 |
---|---|
1 #include "dandy.h" | 1 #include "dandy.h" |
2 | 2 |
3 void | 3 HTaskPtr |
4 create_crab(SchedTask *s, void *charactor_, void *b) | 4 pad_alloc(Viewer *sgroot) |
5 { | 5 { |
6 ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_; | 6 HTaskPtr task = sgroot->manager->create_task(PAD_ALLOCATE); |
7 SceneGraphPtr crab = (SceneGraphPtr)charactor->root; | 7 void *pad = (void*)sgroot->getController(); |
8 int size = sizeof(Pad); | |
8 | 9 |
9 crab->xyz[0] = charactor->x; | 10 task->set_param(0, PAD_INPUT); |
10 crab->xyz[1] = charactor->y; | 11 task->set_param(1, size); |
12 task->add_inData(pad, size); | |
13 task->set_cpu(SPE_ANY); | |
14 task->spawn(); | |
15 | |
16 return task; | |
17 } | |
18 | |
19 HTaskPtr | |
20 pad_update(SceneGraphRoot *sgroot) | |
21 { | |
22 HTaskPtr task = sgroot->tmanager->create_task(PAD_UPDATE); | |
23 void *pad = (void*)sgroot->getController(); | |
24 int size = sizeof(Pad); | |
25 | |
26 task->set_param(0, PAD_INPUT); | |
27 task->set_param(1, size); | |
28 task->add_inData(pad, size); | |
29 task->set_cpu(SPE_ANY); | |
30 task->spawn(); | |
31 | |
32 return task; | |
33 } | |
34 | |
35 HTaskPtr | |
36 pad_free(Viewer *sgroot) | |
37 { | |
38 HTaskPtr task = sgroot->manager->create_task(PAD_FREE); | |
39 | |
40 task->set_param(0, PAD_INPUT); | |
41 task->set_cpu(SPE_ANY); | |
42 task->spawn(); | |
43 | |
44 return task; | |
11 } | 45 } |
12 | 46 |
13 void | 47 void |
14 create_title(SchedTask *s, void *charactor_, void *b) | 48 title_move(SceneGraphPtr node, void *sgroot_, int w, int h) |
15 { | 49 { |
16 ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_; | 50 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
17 SceneGraphPtr title = (SceneGraphPtr)charactor->root; | |
18 | 51 |
19 if (charactor->flag == 1) { | 52 HTaskPtr update = pad_update(sgroot); |
20 title->remove(); | 53 HTaskPtr title_task = sgroot->tmanager->create_task(TITLE_MOVE); |
21 charactor->flag = 0; | 54 int size = sizeof(ObjProperty); |
22 } | 55 title_task->set_param(0, PAD_INPUT); |
56 title_task->add_inData((void *)&charactor[0], size); | |
57 title_task->add_outData((void *)&charactor[0], size); | |
58 title_task->set_cpu(SPE_ANY); | |
59 title_task->wait_for(update); | |
60 title_task->spawn(); | |
23 } | 61 } |
24 | 62 |
25 void | 63 void |
26 create_title_back(Viewer *sgroot_, int w, int h) | 64 create_title_back(Viewer *sgroot_, int w, int h) |
27 { | 65 { |
33 charactor[0].y = h/2; | 71 charactor[0].y = h/2; |
34 charactor[0].vx = 0.0; | 72 charactor[0].vx = 0.0; |
35 charactor[0].vy = 0.0; | 73 charactor[0].vy = 0.0; |
36 charactor[0].flag = 0; | 74 charactor[0].flag = 0; |
37 charactor[0].parent = (void*)root; | 75 charactor[0].parent = (void*)root; |
38 | 76 |
39 title->xyz[0] = charactor[0].x; | 77 title->xyz[0] = charactor[0].x; |
40 title->xyz[1] = charactor[0].y; | 78 title->xyz[1] = charactor[0].y; |
79 title->set_move_collision(title_move); | |
41 | 80 |
42 SceneGraphPtr crab = (SceneGraphPtr)charactor[1].root; | 81 pad_alloc(sgroot); |
43 charactor[1].x = w/2; | |
44 charactor[1].y = h/2; | |
45 charactor[1].vx = 1.0; | |
46 charactor[1].vy = 1.0; | |
47 charactor[1].flag = 0; | |
48 charactor[1].parent = (void*)root; | |
49 | |
50 crab->xyz[0] = charactor[1].x; | |
51 crab->xyz[1] = charactor[1].y; | |
52 crab->flag_drawable = 0; | |
53 | 82 |
54 int size = sizeof(ObjProperty); | |
55 sgroot->task_array_init(TITLE_MOVE, TASK_NUM, PARAMETER, INDATA_NUM, OUTDATA_NUM); | |
56 sgroot->set_pad_task(title, TITLE_MOVE, (void*)&charactor[0], size, create_title); | |
57 sgroot->set_pad_task(crab, CRAB_MOVE, (void*)&charactor[1], size, create_crab); | |
58 | |
59 root->addChild(title); | 83 root->addChild(title); |
60 root->addChild(crab); | |
61 sgroot->setSceneData(root); | 84 sgroot->setSceneData(root); |
62 } | 85 } |
63 | |
64 | |
65 void | |
66 create_stage(void *sgroot_, int w, int h, ObjPropertyPtr charactor) | |
67 { | |
68 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
69 | |
70 SceneGraphPtr stage = sgroot->createSceneGraph(); | |
71 SceneGraphPtr mydandy = sgroot->createSceneGraph("mydandy"); | |
72 | |
73 //mydandy->set_move_collision(dandy_move, dandy_coll); | |
74 //stage->set_move_collision(stage_move, stage_coll); | |
75 | |
76 mydandy->xyz[0] = w/2; | |
77 mydandy->xyz[1] = h*0.9; | |
78 mydandy->xyz[2] = 0.0f; | |
79 | |
80 stage->addChild(mydandy); | |
81 sgroot->setSceneData(stage); | |
82 } |