view mydandy.cc @ 10:93d9db48775f default tip

Property add not move. 30%
author tkaito
date Mon, 14 Jun 2010 17:20:03 +0900
parents c7c497f1c585
children
line wrap: on
line source

#include "stage_init.h"

void change_angle(SceneGraphPtr node, void *sgroot, int w, int h, int angle);
void collision_obj(SceneGraphIteratorPtr it,SceneGraphPtr node ,int w, int h, void *sgroot);
void shot_move(SceneGraphPtr node, void *sgroot_, int w, int h);
void shot_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);

void
mydandy_move(SceneGraphPtr node, void *sgroot_, int w, int h)
{
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  Pad *pad = sgroot->getController();

  if (pad->right.isHold() && w > node->xyz[0]) {
    //change_angle(node, sgroot, w, h, 0);
    //node->frame += 1;
    //if (node->frame > 1000) {
    //change_angle(node, sgroot, w, h, 1);
    //}
    node->xyz[0] += 10.0f;
  } else if (pad->left.isHold() && 0 < node->xyz[0]) {
    //change_angle(node, sgroot, w, h, 1);
    node->xyz[0] -= 10.0f;
  }
  if (pad->up.isHold() && 0 < node->xyz[1]) {
    node->xyz[1] -= 10.0f;
  } else if (pad->down.isHold() && h > node->xyz[1]) {
    node->xyz[1] += 10.0f;
  }
  if (pad->circle.isPush()) {
    SceneGraphPtr shot = sgroot->createSceneGraph("bluebullet");
    shot->set_move_collision(shot_move, shot_coll);
    shot->xyz[0] = node->xyz[0];
    shot->xyz[1] = node->xyz[1] - player_radius;
    node->addBrother(shot);
  }
}

void
change_angle(SceneGraphPtr node, void *sgroot_, int w, int h, int angle) 
{
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  SceneGraphPtr dandy;

  if(angle == 0){
    dandy = sgroot->createSceneGraph("r-dandy");
  } else if(angle == 1) {
    dandy = sgroot->createSceneGraph("l-dandy");
  }
    dandy->set_move_collision(mydandy_move, dandy_coll);
    dandy->xyz[0] = node->xyz[0];
    dandy->xyz[1] = node->xyz[1];
    dandy->xyz[2] = node->xyz[2];
    node->addBrother(dandy);
    //node->remove();
}
void
shot_move(SceneGraphPtr node, void *sgroot_, int w, int h)
{
  node->xyz[1] -= shot_speed;

  if (node->xyz[1] < 0) {
    node->remove();
  }
}
void
shot_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree){}

void
mydandy_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree)
{
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  SceneGraphIteratorPtr it = sgroot->getIterator(tree);
  collision_obj(it, node, w, h, sgroot);
}

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

void
collision_obj(SceneGraphIteratorPtr it,SceneGraphPtr node ,int w, int h, void *sgroot_){}

void
lockon_move(SceneGraphPtr node, void *sgroot_, int w, int h)
{  
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  Pad *pad = sgroot->getController();
  if (pad->triangle.isHold()) {
    node->angle[1] += 10.0f;
  } else if (pad->square.isHold()) {
    //node->angle[1] += 10.0f;
  }
}

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