Mercurial > hg > old > magoroku_racing.bad
changeset 122:5219bf3d5e71
title_draw
author | e085768 |
---|---|
date | Mon, 27 Jun 2011 19:44:46 +0900 |
parents | 411ba68e9cf8 |
children | 78665470f9f9 |
files | Magoroku.cc Magoroku.h car.cc controler.cc gSprite.cc gSprite.h ps2util.cc schedule.cc xml_file/title.xml |
diffstat | 9 files changed, 153 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- a/Magoroku.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/Magoroku.cc Mon Jun 27 19:44:46 2011 +0900 @@ -83,7 +83,6 @@ // schedule.ccで使用してる void linda_env_init( void ); - extern int init(TaskManager *manager, int argc, char *argv[]); extern void task_initialize(); static void TMend(TaskManager *manager); @@ -106,17 +105,6 @@ // magoroku_racing game_main(); - /* - // Dandy - printf("gamef = %d\n",gamef); - switch (gamef) { - case 0: gamef= magoroku_main_init(gamef); break; - case 1: gamef= gamesyokika(gamef); break; - case 2: gamef= opening(gamef); break; - case 3: gamef= magoroku_main_loop(gamef); break; - case 4: gamef= magoroku_closing(gamef); break; - } - */ return next; }; @@ -187,3 +175,16 @@ } } +// 画面の横幅の値を返す +int getScreen_W () +{ + int w = SCREEN_W; + return w; +} + +// 画面の縦幅の値を返す +int getScreen_H () +{ + int h = SCREEN_H; + return h; +}
--- a/Magoroku.h Mon Jun 27 17:49:47 2011 +0900 +++ b/Magoroku.h Mon Jun 27 19:44:46 2011 +0900 @@ -15,8 +15,14 @@ extern Viewer *droot; - typedef void (*move)(SceneGraphPtr node, void *sgroot_, int w, int h); typedef void (*coll)(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree); #endif + +// 初期設定の画面サイズ +#define SCREEN_W 640 +#define SCREEN_H 480 + +int getScreen_W (); +int getScreen_H ();
--- a/car.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/car.cc Mon Jun 27 19:44:46 2011 +0900 @@ -37,6 +37,10 @@ fprintf(main_fp, "car.c: malloc_align16 error\n"); exit(EXIT_FAILURE); } + + // car->body = new OBJECT(); + car->body = (OBJECT*)malloc(sizeof(OBJECT)); + car->body = body; car->next = NULL; car->speed = 0.0; @@ -74,6 +78,8 @@ return car; } +// idは 1 か 2 か 3 で引数取ってこないと落ちるよ +// car/car.dat ファイル内に3つしか車のデータ無から static CarPtr car_new_readCSV(FILE *fp, int id) { @@ -88,14 +94,12 @@ while ((bufp = fgets(buff, BUFSIZE, fp)) != NULL) { - // printf("trace\n"); - bufp++; switch (buff[0]) { case 'n': if (flag == false) { - sscanf(bufp, " %d\n", &car_id); + sscanf(bufp, " %d\n", &car_id); // car_id = nの後ろの数字一文字 if (id == car_id) { flag = true; }
--- a/controler.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/controler.cc Mon Jun 27 19:44:46 2011 +0900 @@ -224,4 +224,3 @@ return true; } -
--- a/gSprite.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/gSprite.cc Mon Jun 27 19:44:46 2011 +0900 @@ -12,40 +12,39 @@ #include "gSprite.h" #include <stdbool.h> -#define DEFOBJ 100 -#define SPRITE_COL 0x4f -#define SCREEN_HALF_W 320 -#define SCREEN_HALF_H 240 +#define DEFOBJ 100 +#define SPRITE_COL 0x4f +#define SCREEN_HALF_W 320 +#define SCREEN_HALF_H 240 -static SpriteTable sptable[DEFOBJ]; -static ps2utilSprite sp[DEFOBJ]; // 表示スプライト用スタック -static unsigned int sp_counter; -static bool flag_spriteInited = false; // スプライトロードフラグ +static SpriteTable sptable[DEFOBJ]; +static ps2utilSprite sp[DEFOBJ]; // 表示スプライト用スタック +static unsigned int sp_counter; +static bool flag_spriteInited = false; // スプライトロードフラグ //static TEXTURE *sprite_tex; - -extern Viewer *droot; +extern Viewer *droot; -/*static*/ SceneGraphPtr root; +/*static*/ SceneGraphPtr root; -static float my_scale = 5; +static float my_scale = 5; //SgoexCerium.ccより void flip() { - CameraPtr camera = droot->sgroot->getCamera(); + CameraPtr camera = droot->sgroot->getCamera(); droot->sgroot->flip(); droot->sgroot->lightCalc(); - root = droot->createSceneGraph(); + root = droot->createSceneGraph(); //root->xyz[0] = screen_w/2; //root->xyz[1] = screen_h/2;; - root->xyz[0] = 0; - root->xyz[1] = 0; + root->xyz[0] = 0; + root->xyz[1] = 0; //root->xyz[2] = 30.0f; /*親の回転、座標から、子の回転、座標を算出*/ @@ -58,8 +57,6 @@ - - /*void gSprite_DefSprite(int number, int tx, int ty, int tw, int th) { @@ -72,15 +69,15 @@ void gSprite_DefSprite(int number, const char *name, float w, float h, int color)//, OBJECT *obj) { - SpriteTable *m = &sptable[number]; - m->w = w; - m->h = h; - m->color = (color & 32); - m->mx = w / 2; //画像の中心を座標としたいらしい。 - m->my = h / 2; - m->tex_w = power_of_two(m->w); - m->tex_h = power_of_two(m->h); - m->texture = (int *)name; + SpriteTable *m = &sptable[number]; + m->w = w; + m->h = h; + m->color = (color & 32); + m->mx = w / 2; //画像の中心を座標としたいらしい。 + m->my = h / 2; + m->tex_w = power_of_two(m->w); + m->tex_h = power_of_two(m->h); + m->texture = (int *)name; } /*void @@ -117,45 +114,34 @@ // object->c_xyz[0] = m->mx; // object->c_xyz[1] = m->my; - // 適当に初期設定:miya - object->xyz[0] = 600; - object->xyz[1] = 100; - object->xyz[2] = -500; - - root->addChild(object); - + // テスト初期設定:miya + /* + object->xyz[0] = 300; + object->xyz[1] = 100; + object->xyz[2] = -100; + */ /* object->xyz[0] -= object->c_xyz[0]*my_scale; object->xyz[1] -= object->c_xyz[1]*my_scale; object->xyz[2] -= object->c_xyz[2]; - + */ + /* object->xyz[0] += x+m->mx; object->xyz[1] += y+m->my; */ + // object->xyz[2] += zorder * 0.01; + + + object->xyz[0] = x; + object->xyz[1] = y; + object->xyz[2] = -500; - // object->xyz[2] += zorder * 0.01; + root->addChild(object); float scale[] = {my_scale,my_scale,1}; //float c_xyz[] = {0,0,0}; //scale_matrix(object->matrix, scale, c_xyz); - CameraPtr camera = droot->sgroot->getCamera(); - - camera->xyz[0] = camera->xyz[1] = 0; - camera->xyz[2] = -100; - camera->xyz[3] = 0; - - printf( "obj_x: %f", object->xyz[0]); - printf( " obj_y:%f", object->xyz[1]); - printf( " obj_z:%f", object->xyz[2]); - printf( " obj_[3]:%f\n", object->xyz[3]); - - printf( "Camera_x: %f", camera->xyz[0]); - printf( " Camera_y:%f", camera->xyz[1]); - printf( " Camera_z:%f", camera->xyz[2]); - printf( " Camera_[3]:%f\n", camera->xyz[3]); - - /*親の回転、座標から、子の回転、座標を算出*/ get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); @@ -163,7 +149,6 @@ /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); - } @@ -272,31 +257,45 @@ gSprite_Init() { droot->createFromXMLfile("xml_file/title.xml"); - - droot->createFromXMLfile("xml_file/kuruma2.xml"); + droot->createFromXMLfile("xml_file/select.xml"); + droot->createFromXMLfile("xml_file/sp_meter.xml"); + droot->createFromXMLfile("xml_file/r_arrow.xml"); + droot->createFromXMLfile("xml_file/l_arrow.xml"); + droot->createFromXMLfile("xml_file/km.xml"); + droot->createFromXMLfile("xml_file/rap.xml"); + droot->createFromXMLfile("xml_file/1p.xml"); + droot->createFromXMLfile("xml_file/2p.xml"); + droot->createFromXMLfile("xml_file/select_car_1.xml"); + droot->createFromXMLfile("xml_file/select_car_2.xml"); + droot->createFromXMLfile("xml_file/select_car_3.xml"); + droot->createFromXMLfile("xml_file/select_corse_1.xml"); + droot->createFromXMLfile("xml_file/select_corse_2.xml"); + + ps2util_graphic_Init(); //gSprite_Init_Png("img/main2.png"); //gSprite_Create(); // スプライト生成 // testCoeler - int tc = 32; + int tc = 1; + - gSprite_DefSprite(10, "title", 512, 666, tc); // タイトル - gSprite_DefSprite(17, "select", 33, 33, tc); // 選択マーク - gSprite_DefSprite(23, "sp_meter", 106, 34, tc); // スピードメーター - gSprite_DefSprite(24, "r_arrow", 18, 20, tc); // 右矢印 - gSprite_DefSprite(25, "l_arrow", 17, 20, tc); // 左矢印 - gSprite_DefSprite(26, "km", 55, 26, tc); // km/h - gSprite_DefSprite(27, "rap", 39, 26, tc); // Rap - gSprite_DefSprite(28, "1p", 53, 46, tc); // 1p - gSprite_DefSprite(29, "2p", 53, 46, tc); // 2P - gSprite_DefSprite(51, "select_car_1", 165, 140, tc); // 選択画面の車 - gSprite_DefSprite(52, "select_car_2", 165, 140, tc); - gSprite_DefSprite(53, "select_car_3", 165, 140, tc); - gSprite_DefSprite(81, "select_corse_1", 148, 114, tc); // 選択画面のコース + gSprite_DefSprite( TITLE, "title", 512, 666, tc); // タイトル + gSprite_DefSprite( SELECT, "select", 33, 33, tc); // 選択マーク + gSprite_DefSprite( SP_METER, "sp_meter", 106, 34, tc); // スピードメーター + gSprite_DefSprite( R_ARROW, "r_arrow", 18, 20, tc); // 右矢印 + gSprite_DefSprite( L_ARROW, "l_arrow", 17, 20, tc); // 左矢印 + gSprite_DefSprite( KM, "km", 55, 26, tc); // km/h + gSprite_DefSprite( RAP, "rap", 39, 26, tc); // Rap + gSprite_DefSprite( PLAYER_1, "1p", 53, 46, tc); // 1p + gSprite_DefSprite( PLAYER_2, "2p", 53, 46, tc); // 2P + gSprite_DefSprite( SELECT_CAR_1, "select_car_1", 165, 140, tc); // 選択画面の車 + gSprite_DefSprite( SELECT_CAR_2, "select_car_2", 165, 140, tc); + gSprite_DefSprite( SELECT_CAR_3, "select_car_3", 165, 140, tc); + gSprite_DefSprite( SELECT_CORSE_1, "select_corse_1", 148, 114, tc); // 選択画面のコース // 本当は (82, 272,...)です。二つ目のコース絵がないので - gSprite_DefSprite(82, "select_corse_2", 148, 114 ,tc); + gSprite_DefSprite( SELECT_CORSE_2, "select_corse_2", 148, 114 ,tc); }
--- a/gSprite.h Mon Jun 27 17:49:47 2011 +0900 +++ b/gSprite.h Mon Jun 27 19:44:46 2011 +0900 @@ -1,6 +1,24 @@ #ifndef GSPRITE_H #define GSPRITE_H +// enum_SpriteNameの略 +enum eSpName { + TITLE = 10, + SELECT = 17, + SP_METER = 23, + R_ARROW = 24, + L_ARROW = 25, + KM = 26, // Km/h + RAP = 27, + PLAYER_1 = 28, + PLAYER_2 = 29, + SELECT_CAR_1 = 51, + SELECT_CAR_2 = 52, + SELECT_CAR_3 = 53, + SELECT_CORSE_1 = 81, + SELECT_CORSE_2 = 82 +}; + //スプライトの優先順位らしい ? #define SPRITE_PRIO_FOREGROUND 1
--- a/ps2util.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/ps2util.cc Mon Jun 27 19:44:46 2011 +0900 @@ -17,6 +17,12 @@ { OBJECT *body; + for( int i = 0; i < 4; i ++ ){ + body->xyz[i] = 0.0f; + body->angle[i] = 0.0f; + } + + /* body->xyz = {0,0,0,0}; body->angle = {0,0,0,0};
--- a/schedule.cc Mon Jun 27 17:49:47 2011 +0900 +++ b/schedule.cc Mon Jun 27 19:44:46 2011 +0900 @@ -26,6 +26,9 @@ #include "sjoy.h" +// getScreen_()関数用にインクルード +#include "Magoroku.h" + #ifdef LINDA bool linda_update(int p, Game *game); #else @@ -108,12 +111,16 @@ static void play_init( Game *game ) { + printf("play_init\n"); printf("game->car_id = %d\n",game->car_id); - //printf("game->jiki->speed = %f\n",game->jiki->speed); + + game->car_id = 1; // テスト用に、ここで強制的に1入れます//miya + printf("game->car_id = %d\n",game->car_id); + + // ここで、car_idには1か2か3が入らんとダメ game->jiki = car_init(game->car_id); - + carNode_append(game->jiki); - field_init(game->course_id); } @@ -204,7 +211,7 @@ // 試しブレンダーで作ったタイトルを表示してみたひ flip(); - gSprite_PutSprite(10, 100, 100); + gSprite_PutSprite(TITLE, 600, 100); //flip(); @@ -248,6 +255,8 @@ void sche_game_select_car(Game *game) { + + flip(); printf("sche_game_select_car()\n"); if (i==1){ title_finish_call(); @@ -307,7 +316,6 @@ SELECT_COURSE: return; - } void @@ -316,10 +324,11 @@ printf("sche_game_ready()\n"); static int blink_count = 0;// + flip(); gSprite_PutSprite(27+game->play_id,265,10); gSprite_PutSpriteEx(SP_SEL_CAR+game->car_id, 50, 120, 1.5, 1.5 , 0.0); gSprite_PutSpriteEx(SP_SEL_COURSE+game->course_id, 340, 120, 1.7, 1.8 , 0.0); - + /* 点滅 */ if (blink_count < 35) { gFont_SetString("GAME START !!", 170, 380); @@ -490,7 +499,6 @@ if (pad.st == 1) { set_schedule_assumption(sche_game_main_finish); } - } void
--- a/xml_file/title.xml Mon Jun 27 17:49:47 2011 +0900 +++ b/xml_file/title.xml Mon Jun 27 19:44:46 2011 +0900 @@ -2,12 +2,27 @@ <OBJECT-3D> <surface name="title" size="6" prim="Triangle" parent="NULL"> <coordinate> - -46.684662 35.716764 -0.818169 + <!-- -46.684662 35.716764 -0.818169 -64.928226 35.754207 -0.003736 -64.909756 23.782402 0.818169 -64.909756 23.782402 0.818169 -46.666191 23.744960 0.003735 - -46.684662 35.716764 -0.818169 + -46.684662 35.716764 -0.818169 --> + <!--x y z--> + <!-- + -46.000000, 23.000000, 0.000000 + -64.000000, 23.000000, 0.000000 + -64.000000, 35.000000, 0.000000 + -64.000000, 35.000000, 0.000000 + -46.000000, 35.000000, 0.000000 + -46.000000, 23.000000, 0.000000 + --> + -42.000000, 18.000000, 0.000000 + -69.000000, 18.000000, 0.000000 + -69.000000, 38.000000, 0.000000 + -69.000000, 38.000000, 0.000000 + -42.000000, 38.000000, 0.000000 + -42.000000, 18.000000, 0.000000 </coordinate> <normal> 0.267800 0.410954 5.979916