view stage_init.cc @ 5:bcbcee3c6729

title done.
author tkaito
date Mon, 21 Jun 2010 03:47:35 +0900
parents ccc811ee5f55
children 661ec1e92042
line wrap: on
line source

#include "dandy.h"

void stage_move(SceneGraphPtr node, void *sgroot_, int w, int h);
void stage_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree);

void
createSceneGraphFromProperty(SchedTask *s, void *charactor_, void *b)
{
  ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_; 
  SceneGraphPtr back1, title;
  back1 = (SceneGraphPtr)charactor[0].parent;
  title = (SceneGraphPtr)charactor[0].root;
  

  title->xyz[0] = charactor[0].x;
  title->xyz[1] = charactor[0].y;
  title->stack_xyz[0] = charactor[0].vx;
  title->stack_xyz[1] = charactor[0].vy;

  back1->addChild(title);

  //charactor[0].frame;

  //printf("charactor.x = %d\n", charactor1[0].frame);

}

void
create_title(void *sgroot_, int w, int h, ObjPropertyPtr charactor) 
{
  Viewer *sgroot = (Viewer *)sgroot_;
  SceneGraphPtr back1, title;

  back1 = sgroot->createSceneGraph();
  sgroot->setSceneData(back1);

  /* createPropertyFromSceneGraph */
  title = sgroot->createSceneGraph("title001");

  charactor[0].x  = w/2;
  charactor[0].y  = h/2;
  charactor[0].vx = back1->stack_xyz[0];
  charactor[0].vy = back1->stack_xyz[1];
  //charactor[0].frame = back1->frame;
  charactor[0].parent = (void*)back1;
  charactor[0].root   = (void*)title;
  
  /* set_game_task(int id, ObjProperty property, int size, PostFunction post_func) */
  HTask *back;

  back = sgroot->manager->create_task(TITLE_MOVE);
  back->set_cpu(SPE_ANY);
  back->add_inData(charactor, sizeof(ObjPropertyPtr)*16);
  back->add_outData(charactor, sizeof(ObjPropertyPtr)*16);
  back->add_param((memaddr)1);
  back->set_post(createSceneGraphFromProperty, (void*)charactor, 0);
  back->spawn();
}

  //title->xyz[0] = w/2;
  //title->xyz[1] = h/2;


  //title->set_move_collision(title_move, title_coll);

		


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);
}

void
stage_move(SceneGraphPtr node, void *sgroot_, int w, int h)
{

  //stage_plan(node, sgroot_, w, h);
  node->frame += 1;

}

void
stage_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree) 
{
}