view main.cc @ 23:3fb8a6a34e24

debug and keep up with task_array
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 26 Oct 2010 17:28:56 +0900
parents fd9deaa67de9
children a131729d6e4d 6bea374ee604
line wrap: on
line source

#include "dandy.h"

#define ENEMY_STATUS(charano,score,hardness) {charano,score,hardness}
const state status[50] = ENEMY_STATUS_TABLE;

extern void task_init(void);

TaskManager *manager;
ObjPropertyPtr charactor;

const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\
  -length  Number of data (default DATA_NUM (Func.h))\n\
  -count   Number of task (default 1)\n";

int
init(int argc, char **argv)
{
    for (int i = 1; argv[i]; ++i) {
        if (strcmp(argv[i], "-length") == 0) {
	    //length = atoi(argv[++i]);
        } else if (strcmp(argv[i], "-count") == 0) {
	    //task = atoi(argv[++i]);
        }
    }

    return 0;
}

void
init_charactor(Viewer *sgroot, int w, int h)
{
    sgroot->createFromXMLfile("xml/mydandy.xml");
    sgroot->createFromXMLfile("xml/greencrab.xml");
    sgroot->createFromXMLfile("xml/gameover.xml");
    sgroot->createFromXMLfile("xml/greencrab.xml");
    sgroot->createFromXMLfile("xml/bluebullet.xml");
    sgroot->createFromXMLfile("xml/redbullet.xml");
    sgroot->createFromXMLfile("xml/title2.xml");

    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;
    }
    create_title_back(sgroot, w, h);
}

MainLoopPtr
Dandy::init(Viewer *sgroot, int w, int h)
{
    charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjProperty)*ENEMY_NUM);
    init_charactor(sgroot, w, h);
    return sgroot;
}

extern Application *
application() {
    return new Dandy();
}

extern int init(TaskManager *manager, int argc, char *argv[]);
extern void task_initialize();
static void TMend(TaskManager *manager);

int
TMmain(TaskManager *manager,int argc, char *argv[])
{
    /*  
	if (init(argc, argv) < 0) {
	return -1;
	}
    */
    // Task Register
    //   ppe/task_init.cc
    task_init();
    /*
      for (int i = 0; i < task; ++i) {
      twice_init(manager);
      }
    */
    //create_title(sgroot, w, h);
    task_initialize();
    manager->set_TMend(TMend);
    return init(manager,argc, argv);
}

void
TMend(TaskManager *manager)
{
    printf("game end\n");
}