view stage_init.cc @ 21:fd9deaa67de9

debug done.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Mon, 18 Oct 2010 02:52:52 +0900
parents 632ce41a842a
children 3fb8a6a34e24
line wrap: on
line source

#include "dandy.h"

void
create_crab(SchedTask *s, void *charactor_, void *b)
{
    ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_;
    SceneGraphPtr crab = (SceneGraphPtr)charactor[1].root;

    crab->xyz[0] = charactor[1].x;
    crab->xyz[1] = charactor[1].y;
}

void
create_title(SchedTask *s, void *charactor_, void *b)
{
    ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_;
    SceneGraphPtr title = (SceneGraphPtr)charactor->root;

    if (charactor->flag == 1) {
      title->remove();
      charactor->flag = 0;
    }
}

void
create_title_back(Viewer *sgroot_, int w, int h) 
{ 
    Viewer *sgroot = sgroot_;
    SceneGraphPtr back;
    back = sgroot->createSceneGraph();

    SceneGraphPtr title = (SceneGraphPtr)charactor[0].root;
    charactor[0].x = w/2;
    charactor[0].y = h/2;
    charactor[0].vx = 1.0;
    charactor[0].vy = 1.0;
    charactor[0].flag = 0;
    charactor[0].parent = (void*)back;
    
    title->xyz[0] = charactor[0].x;
    title->xyz[1] = charactor[0].y;

    SceneGraphPtr crab = (SceneGraphPtr)charactor[1].root;
    charactor[1].x = 0.0;
    charactor[1].y = 0.0;
    charactor[1].vx = 1.0;
    charactor[1].vy = 1.0;
    charactor[1].flag = 0;
    charactor[1].parent = (void*)back;
    
    crab->xyz[0] = charactor[1].x;
    crab->xyz[1] = charactor[1].y;
    
    back->addChild(title);
    //    back->addChild(crab);
    sgroot->setSceneData(back);

    int size = sizeof(ObjProperty);
    //    sgroot->set_pad_task(crab, CRAB_MOVE, (void*)&charactor[1], size, create_crab);
    sgroot->set_pad_task(title, TITLE_MOVE, (void*)&charactor[0], size, create_title);
}


void
create_stage(void *sgroot_, int w, int h, ObjPropertyPtr charactor) 
{
    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;

    SceneGraphPtr stage = sgroot->createSceneGraph();
    SceneGraphPtr mydandy = sgroot->createSceneGraph("mydandy"); 
    
    //mydandy->set_move_collision(dandy_move, dandy_coll);
    //stage->set_move_collision(stage_move, stage_coll);
    
    mydandy->xyz[0] = w/2;
    mydandy->xyz[1] = h*0.9;
    mydandy->xyz[2] = 0.0f;
    
    stage->addChild(mydandy);
    sgroot->setSceneData(stage);
}