view mydandy.cc @ 3:dca6d5d2ef46

stage 1 add
author tkaito
date Sun, 06 Jun 2010 05:23:51 +0900
parents 69b4108bf4e8
children 57af5c610b34
line wrap: on
line source

#include "game_scene01.h"

void def_angle(SceneGraphPtr node, void *sgroot_, int w, int h);
void left_angle(SceneGraphPtr node, void *sgroot_, int w, int h);
void right_angle(SceneGraphPtr node, void *sgroot_, int w, int h);

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

  /* 左右の移動 */  
  if (pad->right.isPush() && w > node->xyz[0]) {
    right_angle(node, sgroot, w, h);
  } else if (pad->left.isPush() && 0 < node->xyz[0]) {
    left_angle(node, sgroot, w, h);
  } else {
    //def_angle(node, sgroot, w, h);
  }
  if (pad->right.isHold() && w > node->xyz[0]) {
    node->xyz[0] += 10.0f;
  } else if (pad->left.isHold() && 0 < node->xyz[0]) {
    node->xyz[0] -= 10.0f;
  }
  if (pad->right.isRelease()) {
    
  } else if(pad->left.isRelease()) {

  }  
  /* 上下の移動 */
  if (pad->up.isHold() && 0 < node->xyz[1]) {
    node->xyz[1] -= 10.0f;
    //def_angle(node, sgroot, w, h);
  } else if (pad->down.isHold() && h > node->xyz[1]) {
    node->xyz[1] += 10.0f;
  }

}

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

}

/* 時機や敵機のオブジェクトや何やらを作成してsetSceneDataまで */

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

  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;      
  SceneGraphPtr dandy = sgroot->createSceneGraph("mydandy");
  SceneGraphPtr back = sgroot->createSceneGraph(); 
  
  dandy->xyz[0] = node->xyz[0];
  dandy->xyz[1] = node->xyz[1];
  
  dandy->set_move_collision(dandy_move, dandy_collision);
  
  back->addChild(dandy);  
  sgroot->setSceneData(back);
}

void
right_angle(SceneGraphPtr node, void *sgroot_, int w, int h) 
{
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  SceneGraphPtr rtdandy;
  SceneGraphPtr back = sgroot->createSceneGraph();

  rtdandy = sgroot->createSceneGraph("rt-dandy");

  rtdandy->xyz[0] = node->xyz[0];
  rtdandy->xyz[1] = node->xyz[1];
  
  rtdandy->set_move_collision(dandy_move, dandy_collision);
  back->addChild(rtdandy);
  
  sgroot->setSceneData(back);
  rtdandy->xyz[0] += 1.0f;
}
void
left_angle(SceneGraphPtr node, void *sgroot_, int w, int h) 
{
  SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
  SceneGraphPtr ltdandy;
  SceneGraphPtr back = sgroot->createSceneGraph();

  ltdandy = sgroot->createSceneGraph("lt-dandy");

  ltdandy->xyz[0] = node->xyz[0];
  ltdandy->xyz[1] = node->xyz[1];
  
  ltdandy->set_move_collision(dandy_move, dandy_collision);
  back->addChild(ltdandy);  
  
  sgroot->setSceneData(back);
  ltdandy->xyz[0] -= 1.0f;
}