changeset 19:632ce41a842a

testing game task with pad's input
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Thu, 26 Aug 2010 03:37:36 +0900
parents 2c188b2becec
children ec540ce4519d
files dandy.h main.cc ppe/TitleMove.cc ppe/TitleMove.h schedule.cc stage_init.cc
diffstat 6 files changed, 57 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/dandy.h	Mon Aug 09 01:22:53 2010 +0900
+++ b/dandy.h	Thu Aug 26 03:37:36 2010 +0900
@@ -23,7 +23,6 @@
   const char *chara;
   int vital; //4
   int score; //4
-  int a;
   void *parent; 
   void *root;
   int flag;
@@ -33,7 +32,7 @@
 extern ObjProperty back_property;
 extern ObjPropertyPtr charactor;
 
-static const int ENEMY_NUM = 1;
+static const int ENEMY_NUM = 2;
 
 static const float player_speed = 10.0f;
 static const float player_radius = 42.0f;
--- a/main.cc	Mon Aug 09 01:22:53 2010 +0900
+++ b/main.cc	Thu Aug 26 03:37:36 2010 +0900
@@ -35,7 +35,7 @@
   sgroot->createFromXMLfile("xml/redbullet.xml");
   sgroot->createFromXMLfile("xml/title2.xml");  
 
-  for (int i = 0; i < 2; i++) {
+  for (int i = 0; i < ENEMY_NUM; i++) {
     charactor[i].root  = (void*)sgroot->createSceneGraph(status[i].charano);
     charactor[i].score = status[i].score;
     charactor[i].vital = status[i].vital;
@@ -48,7 +48,7 @@
 MainLoopPtr
 dandy::init(Viewer *sgroot, int w, int h)
 {
-  charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjPropertyPtr)*16);
+  charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjPropertyPtr)*ENEMY_NUM);
   init_charactor(sgroot, w, h);
   return sgroot;
 }
--- a/ppe/TitleMove.cc	Mon Aug 09 01:22:53 2010 +0900
+++ b/ppe/TitleMove.cc	Thu Aug 26 03:37:36 2010 +0900
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include "SchedTask.h"
 #include "TitleMove.h"
+#include "Joystick.h"
 #include "Func.h"
 
 /* これは必須 */
@@ -9,19 +10,18 @@
 static int
 titlemove(SchedTask *s,void *rbuf, void *wbuf)
 {
-  ObjPropertyPtr i_obj;
-  ObjPropertyPtr o_obj;
+  Pad* pad;
+  ObjPropertyPtr i_obj, o_obj;
 
   i_obj = (ObjPropertyPtr)s->get_input(rbuf, 0);
+  pad = (Pad*)s->get_input(rbuf, 1);
   o_obj = (ObjPropertyPtr)s->get_output(wbuf, 0);
 
-  i_obj[0].x += i_obj[0].vx;
-  i_obj[0].y += i_obj[0].vy;
+  if(pad->start.isPush() || pad->start.isHold()) {
+    i_obj->flag = 1;
+  }
 
-  //  printf("indata_x = %f\n", i_obj[0].x);
-  //  printf("indata_y = %f\n", i_obj[0].y);
-
-  s->swap();
+  o_obj->flag = i_obj->flag;
 
   return 0;
 }
--- a/ppe/TitleMove.h	Mon Aug 09 01:22:53 2010 +0900
+++ b/ppe/TitleMove.h	Thu Aug 26 03:37:36 2010 +0900
@@ -14,17 +14,16 @@
  */
 
 typedef struct {
-  double x, y;
-  double vx, vy;
-  int frame;
+  double x, y; //8?
+  double vx, vy; //8?
+  int frame; //4
   const char *chara;
-  int vital;
-  int score;
-  int remove;
-  void *parent;
+  int vital; //4
+  int score; //4
+  void *parent; 
   void *root;
+  int flag;
   
 } *ObjPropertyPtr, ObjProperty;
 
-
 #endif
--- a/schedule.cc	Mon Aug 09 01:22:53 2010 +0900
+++ b/schedule.cc	Thu Aug 26 03:37:36 2010 +0900
@@ -21,7 +21,8 @@
   }
   */
 
-  if(back_property.flag == 1) {
+  /* 取りあえず根っこのSceneGraphのPropertyのフラグでif文に入るようにしてみた */
+  if(charactor[0].flag == 1) {
   switch (node->frame) {
   case 1:
     break;    
--- a/stage_init.cc	Mon Aug 09 01:22:53 2010 +0900
+++ b/stage_init.cc	Thu Aug 26 03:37:36 2010 +0900
@@ -1,67 +1,56 @@
 #include "dandy.h"
 
-
 void
 create_title(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] += 1;//charactor[0].x;
-  title->xyz[1] += 1; //charactor[0].y;
+    ObjPropertyPtr charactor = (ObjPropertyPtr)charactor_;
 
-  printf("title_x = %f\n", title->xyz[0]);
-  printf("title_y = %f\n", title->xyz[1]);
+    if (charactor->flag == 1) {
+      /* タイトルが終わり、次はココにゲームの準備をする処理を書く */
+      printf("Title finished");
+    }
 }
 
-ObjProperty back_property;
-
 void
 create_title_back(Viewer *sgroot_, int w, int h) 
-{
-  
-  Viewer *sgroot = sgroot_;
-  SceneGraphPtr back;
-  back_property.flag = 0;
+{ 
+    Viewer *sgroot = sgroot_;
+    SceneGraphPtr back;
 
-  back = sgroot->createSceneGraph();
-  charactor[0].x = w/2;
-  charactor[0].y = h/2;
-  charactor[0].vx = 1.0;
-  charactor[0].vy = 1.0;
-  charactor[0].parent = (void*)back;
-
-  SceneGraphPtr title = (SceneGraphPtr)charactor[0].root;
-  title->xyz[0] = charactor[0].x;
-  title->xyz[1] = charactor[0].y;
-
-  int size = sizeof(ObjProperty);
-  //printf("size = %d\n", size);
-  
-  back->addChild(title);
-  sgroot->setSceneData(back);
-  sgroot->set_move_task(title, TITLE_MOVE, (void*)&charactor[0], size, create_title);
+    back = sgroot->createSceneGraph();
+    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;
+    
+    SceneGraphPtr title = (SceneGraphPtr)charactor[0].root;
+    title->xyz[0] = charactor[0].x;
+    title->xyz[1] = charactor[0].y;
+    
+    int size = sizeof(ObjProperty);
+    back->addChild(title);
+    sgroot->setSceneData(back);  
+    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"); 
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
 
-  //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);
+    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);
 }
-