Mercurial > hg > old > magoroku_racing
changeset 2:b6a1385f19be
*** empty log message ***
author | gongo |
---|---|
date | Sat, 04 Nov 2006 08:04:53 +0000 |
parents | 0fae5658fb0b |
children | 38aedf763052 |
files | Makefile car.c controler.c controler.h gFont.c game.c light.c schedule.c title_scene.c |
diffstat | 9 files changed, 389 insertions(+), 322 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Nov 02 08:55:19 2006 +0000 +++ b/Makefile Sat Nov 04 08:04:53 2006 +0000 @@ -28,8 +28,13 @@ cd ${VU1DIR}; make cp ${VU1OBJ} . -${TARGET} : ${OBJS} ${VU1OBJ} - ${CC} -o ${TARGET} ${OBJS} ${LIBS} +#${TARGET} : ${OBJS} ${VU1OBJ} +# ${CC} -o ${TARGET} ${OBJS} ${LIBS} + +$(TARGET) : $(OBJS) + $(AR) x $(LIB_OBJ) $(MPG_OBJ) + $(CC) -o $(TARGET) $(OBJS) $(LIBS) + tag: etags *.[ch] @@ -306,7 +311,7 @@ camera.o: /usr/local/include/libps2a/object.h camera.o: /usr/local/include/libps2a/malloc128.h camera.o: /usr/local/include/libps2a/debug.h -camera.o: /usr/local/include/ps2util/ps2util.h col.h field.h car.h game.h +camera.o: /usr/local/include/ps2util/ps2util.h car.h game.h controler.h gSprite.o: /usr/include/stdio.h /usr/include/features.h gSprite.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h gSprite.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/stddef.h @@ -358,15 +363,15 @@ schedule.o: /usr/include/sys/select.h /usr/include/bits/select.h schedule.o: /usr/include/bits/sigset.h /usr/include/bits/time.h schedule.o: /usr/include/sys/sysmacros.h /usr/include/alloca.h -schedule.o: /usr/local/include/libps2a/libps2.h /usr/include/ps2gs.h -schedule.o: /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h -schedule.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h -schedule.o: /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h -schedule.o: /usr/include/linux/ps2/dev.h /usr/include/linux/ioctl.h -schedule.o: /usr/include/asm/types.h /usr/include/linux/autoconf.h -schedule.o: /usr/include/linux/ps2/ee.h /usr/include/linux/ps2/gs.h -schedule.o: /usr/include/linux/ps2/pad.h /usr/include/gs_vc.h -schedule.o: /usr/include/libvu0.h /usr/include/ps2vpu.h +schedule.o: /usr/include/string.h /usr/local/include/libps2a/libps2.h +schedule.o: /usr/include/ps2gs.h /usr/include/sys/ioctl.h +schedule.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +schedule.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +schedule.o: /usr/include/sys/ttydefaults.h /usr/include/linux/ps2/dev.h +schedule.o: /usr/include/linux/ioctl.h /usr/include/asm/types.h +schedule.o: /usr/include/linux/autoconf.h /usr/include/linux/ps2/ee.h +schedule.o: /usr/include/linux/ps2/gs.h /usr/include/linux/ps2/pad.h +schedule.o: /usr/include/gs_vc.h /usr/include/libvu0.h /usr/include/ps2vpu.h schedule.o: /usr/local/include/libps2a/sjoy.h schedule.o: /usr/local/include/libps2a/sprite.h schedule.o: /usr/local/include/libps2a/texture.h @@ -381,7 +386,8 @@ schedule.o: /usr/local/include/ps2util/ps2util.h col.h field.h car.h schedule.o: gSprite.h gFont.h game.h controler.h camera.h mytype.h schedule.o: /usr/include/math.h /usr/include/bits/huge_val.h -schedule.o: /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h +schedule.o: /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h light.h +schedule.o: title_scene.h game_time.h /usr/include/sys/time.h demo.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h demo.o: /usr/include/gnu/stubs.h demo.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/stddef.h @@ -532,7 +538,9 @@ linda.o: /usr/include/bits/endian.h /usr/include/sys/select.h linda.o: /usr/include/bits/select.h /usr/include/bits/sigset.h linda.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h -linda.o: /usr/include/alloca.h /usr/local/include/libps2a/libps2.h +linda.o: /usr/include/alloca.h /usr/include/math.h +linda.o: /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h +linda.o: /usr/include/bits/mathcalls.h /usr/local/include/libps2a/libps2.h linda.o: /usr/include/ps2gs.h /usr/include/sys/ioctl.h linda.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h linda.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h @@ -554,3 +562,63 @@ linda.o: /usr/local/include/libps2a/debug.h linda.o: /usr/local/include/ps2util/ps2util.h car.h game.h linda.o: /usr/local/include/libps2a/lindaapi.h +light.o: /usr/include/stdio.h /usr/include/features.h +light.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +light.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/stddef.h +light.o: /usr/include/bits/types.h /usr/include/bits/pthreadtypes.h +light.o: /usr/include/bits/sched.h /usr/include/libio.h +light.o: /usr/include/_G_config.h /usr/include/wchar.h +light.o: /usr/include/bits/wchar.h /usr/include/gconv.h +light.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/stdarg.h +light.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/va-mips.h +light.o: /usr/include/bits/stdio_lim.h /usr/local/include/libps2a/libps2.h +light.o: /usr/include/ps2gs.h /usr/include/sys/ioctl.h +light.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +light.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +light.o: /usr/include/sys/ttydefaults.h /usr/include/linux/ps2/dev.h +light.o: /usr/include/linux/ioctl.h /usr/include/asm/types.h +light.o: /usr/include/linux/autoconf.h /usr/include/linux/ps2/ee.h +light.o: /usr/include/linux/ps2/gs.h /usr/include/linux/ps2/pad.h +light.o: /usr/include/gs_vc.h /usr/include/libvu0.h /usr/include/ps2vpu.h +light.o: /usr/local/include/libps2a/sjoy.h +light.o: /usr/local/include/libps2a/sprite.h +light.o: /usr/local/include/libps2a/texture.h +light.o: /usr/local/include/libps2a/ps2dma.h /usr/include/ps2vpufile.h +light.o: /usr/local/include/libps2a/def.h /usr/local/include/libps2a/xml.h +light.o: /usr/local/include/libps2a/surface.h +light.o: /usr/local/include/libps2a/giftag.h +light.o: /usr/local/include/libps2a/material.h +light.o: /usr/local/include/libps2a/object.h +light.o: /usr/local/include/libps2a/malloc128.h +light.o: /usr/local/include/libps2a/debug.h light.h +title_scene.o: /usr/local/include/libps2a/libps2.h /usr/include/ps2gs.h +title_scene.o: /usr/include/sys/ioctl.h /usr/include/features.h +title_scene.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +title_scene.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +title_scene.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +title_scene.o: /usr/include/sys/ttydefaults.h /usr/include/linux/ps2/dev.h +title_scene.o: /usr/include/linux/ioctl.h /usr/include/asm/types.h +title_scene.o: /usr/include/linux/autoconf.h /usr/include/linux/ps2/ee.h +title_scene.o: /usr/include/linux/ps2/gs.h /usr/include/linux/ps2/pad.h +title_scene.o: /usr/include/gs_vc.h /usr/include/libvu0.h +title_scene.o: /usr/include/ps2vpu.h /usr/local/include/libps2a/sjoy.h +title_scene.o: /usr/local/include/libps2a/sprite.h +title_scene.o: /usr/local/include/libps2a/texture.h +title_scene.o: /usr/local/include/libps2a/ps2dma.h /usr/include/ps2vpufile.h +title_scene.o: /usr/local/include/libps2a/def.h +title_scene.o: /usr/local/include/libps2a/xml.h +title_scene.o: /usr/local/include/libps2a/surface.h +title_scene.o: /usr/local/include/libps2a/giftag.h +title_scene.o: /usr/local/include/libps2a/material.h +title_scene.o: /usr/local/include/libps2a/object.h +title_scene.o: /usr/local/include/libps2a/malloc128.h +title_scene.o: /usr/local/include/libps2a/debug.h +title_scene.o: /usr/local/include/ps2util/ps2util.h title_scene.h +game_time.o: game_time.h /usr/include/sys/time.h /usr/include/features.h +game_time.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +game_time.o: /usr/include/bits/types.h +game_time.o: /usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/stddef.h +game_time.o: /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h +game_time.o: /usr/include/time.h /usr/include/bits/time.h +game_time.o: /usr/include/sys/select.h /usr/include/bits/select.h +game_time.o: /usr/include/bits/sigset.h
--- a/car.c Thu Nov 02 08:55:19 2006 +0000 +++ b/car.c Sat Nov 04 08:04:53 2006 +0000 @@ -29,17 +29,6 @@ static int *check; static int check_value; -extern void free_check(void *,int); -extern int check_car(){ - if(check){ - // if(*check!=check_value){ - // printf("err\n"); - // } - // free_check(check,6); - } - return 0; -} - static CarPtr car_create(int car_id, char *filename, char *texname, float speed_accel, float speed_max, float rot, float brake)
--- a/controler.c Thu Nov 02 08:55:19 2006 +0000 +++ b/controler.c Sat Nov 04 08:04:53 2006 +0000 @@ -25,13 +25,8 @@ pad1 = sjoy_get_ps2_button( JOYPAD_1 ); -#ifdef DEMO_CREATE - if (game.state == GAME_MAIN) - setPadValue(pad1); -#endif - if (pad1 & SJOY_PS2_START) { - pad.st += (pad.st > 100) ? 0 : 1; + pad.st += (pad.st < 2) ? 1 : 0; } else { pad.st = 0; } @@ -41,67 +36,67 @@ } if (pad1 & SJOY_PS2_SELECT) { - pad.se += (pad.se > 100) ? 0 : 1; + pad.se += (pad.se < 2) ? 1 : 0; } else { pad.se = 0; } if (pad1 & SJOY_PS2_LEFT) { - pad.left += (pad.left > 100) ? 0 : 1; + pad.left += (pad.left < 2) ? 1 : 0; } else { pad.left = 0; } if (pad1 & SJOY_PS2_RIGHT) { - pad.right += (pad.right > 100) ? 0 : 1; + pad.right += (pad.right < 2) ? 1 : 0; } else { pad.right = 0; } if (pad1 & SJOY_PS2_UP) { - pad.up += (pad.up > 100) ? 0 : 1; + pad.up += (pad.up < 2) ? 1 : 0; } else { pad.up = 0; } if (pad1 & SJOY_PS2_DOWN) { - pad.down += (pad.down > 100) ? 0 : 1; + pad.down += (pad.down < 2) ? 1 : 0; } else { pad.down = 0; } if (pad1 & SJOY_PS2_R1) { - pad.r1 += (pad.r1 > 100) ? 0 : 1; + pad.r1 += (pad.r1 < 2) ? 1 : 0; } else { pad.r1 = 0; } if (pad1 & SJOY_PS2_R2) { - pad.r2 += (pad.r2 > 100) ? 0 : 1; + pad.r2 += (pad.r2 < 2) ? 1 : 0; } else { pad.r2 = 0; } if (pad1 & SJOY_PS2_L1) { - pad.l1 += (pad.l1 > 100) ? 0 : 1; + pad.l1 += (pad.l1 < 2) ? 1 : 0; } else { pad.l1 = 0; } if (pad1 & SJOY_PS2_L2) { - pad.l2 += (pad.l2 > 100) ? 0 : 1; + pad.l2 += (pad.l2 < 2) ? 1 : 0; } else { pad.l2 = 0; } if (pad1 & SJOY_PS2_CROSS) { - pad.cross += (pad.cross > 100) ? 0 : 1; + pad.cross += (pad.cross < 2) ? 1 : 0; } else { pad.cross = 0; } if (pad1 & SJOY_PS2_CIRCLE) { - pad.circle += (pad.circle > 100) ? 0 : 1; + pad.circle += (pad.circle < 2) ? 1 : 0; } else { pad.circle = 0; } if (pad1 & SJOY_PS2_TRIANGLE) { - pad.triangle += (pad.triangle > 100) ? 0 : 1; + pad.triangle += (pad.triangle < 2) ? 1 : 0; } else { pad.triangle = 0; } if (pad1 & SJOY_PS2_SQUARE) { - pad.square += (pad.square > 100) ? 0 : 1; + pad.square += (pad.square < 2) ? 1 : 0; } else { pad.square = 0; }
--- a/controler.h Thu Nov 02 08:55:19 2006 +0000 +++ b/controler.h Sat Nov 04 08:04:53 2006 +0000 @@ -1,6 +1,13 @@ /* * $Id$ */ + +/* + * チャタリング防止 + * value = 0: 押してない + * 1: 1回押した + * 2: 押し続けている + */ typedef struct SGO_PAD { short st; short se;
--- a/gFont.c Thu Nov 02 08:55:19 2006 +0000 +++ b/gFont.c Sat Nov 04 08:04:53 2006 +0000 @@ -162,8 +162,3 @@ gFont_SetFont_OP() { } - - - - -
--- a/game.c Thu Nov 02 08:55:19 2006 +0000 +++ b/game.c Sat Nov 04 08:04:53 2006 +0000 @@ -39,7 +39,7 @@ game.play_id = linda_init(); - while (flg) { + while (flg == TRUE) { flg = padCheck(); if (flg == FALSE && game.demo_flg == 1) { game.state = GAME_FINISH;
--- a/light.c Thu Nov 02 08:55:19 2006 +0000 +++ b/light.c Sat Nov 04 08:04:53 2006 +0000 @@ -56,7 +56,3 @@ ps2_vu0_normal_light_matrix(normal_light, l->light0, l->light1, l->light2); ps2_vu0_light_color_matrix(light_color, l->color0, l->color1, l->color2, l->ambient); } - - - -
--- a/schedule.c Thu Nov 02 08:55:19 2006 +0000 +++ b/schedule.c Sat Nov 04 08:04:53 2006 +0000 @@ -26,7 +26,7 @@ #define MAXRAP 3 // ラップ数 #define SP_SEL_CAR 50 #define SP_SEL_COURSE 80 - extern int car_check(); +extern int car_check(); /* --- controler.c --- */ extern SGO_PAD pad; /* --- car.c --- */ @@ -64,15 +64,15 @@ static int get_random() { - srand((unsigned)time(NULL)); - return (int)(rand()*DEMO_NUM/(1.0+RAND_MAX)); + srand((unsigned)time(NULL)); + return (int)(rand()*DEMO_NUM/(1.0+RAND_MAX)); } static void -graphic_Init() +graphic_init() { - gSprite_Init(); // グラフィック関連の初期化 - gFont_Init(); // フォント関連の初期化 + gSprite_Init(); // グラフィック関連の初期化 + gFont_Init(); // フォント関連の初期化 } static void @@ -84,7 +84,7 @@ } static void -syokika() +game_env_init() { game.car_id = 1; game.course_id = 1; @@ -104,284 +104,47 @@ void schedule() { - char raptime[10]; + char raptime[10]; - /* timer */ - static int start_time,time_count; - static int RUNNIG=0; + /* timer */ + static int start_time,time_count; + static int RUNNIG=0; switch (game.state) { case GAME_INIT: - graphic_Init(); - syokika(); - camera_init(); - -#ifdef DEMO_CREATE - game.car_id = 1; - game.course_id = 2; - demo_openFp(2); - play_init(); - game.state = GAME_MAIN; -#else -#ifdef LINDA - game.state = GAME_WAIT; -#else - game.state = GAME_OPENING; -#endif -#endif - break; - case GAME_WAIT: - if (pad.st == 1) { - game.state = GAME_OPENING; - } + sche_game_init(); break; case GAME_OPENING: - /*title*/ - { - static int blink_count = 0; - /* 点滅 */ - if (game.play_id==1){ - if (blink_count < 35) { - gFont_SetString("PUSH START !!", 170, 380); - } - blink_count = (blink_count > 70) ? 0 : blink_count+1; - } - } - -#ifndef LINDA - /* 時間が経てばデモ画面へ移行 */ - if (wait(1.0) == TRUE) { - demo_openFp(get_random()); - game.demo_flg = 1; - title_finish_call(); - game.state = GAME_MAIN_INIT; - } -#endif - if (game.play_id==1){ - if (title_scene() < 0){ - game.state = GAME_SELECT_CAR; - } - }else if (game.play_id==2){ - if (i==0){ - title_init_call(); - i=1; - } - } - + sche_game_opening(); break; case GAME_SELECT_CAR: - if (i==1){ - title_finish_call(); - i=2; - } - gSprite_PutSpriteEx(SP_SEL_CAR+game.car_id, 190, 200, 1.5, 1.5); - gSprite_PutSprite(24, 460, 300); - gSprite_PutSprite(25, 120, 300); - gFont_SetString("SELECT CAR", 180, 50); - - if (pad.right == 1) { - game.car_id = - (game.car_id > MAXCAR-1) ? 1 : game.car_id + 1; - } - if (pad.left == 1) { - game.car_id = - (game.car_id < 2) ? MAXCAR : game.car_id - 1; - } - if (pad.circle == 1) { - game.state = GAME_SELECT_COURSE; - } - break; + sche_game_select_car(); + break; case GAME_SELECT_COURSE: - gSprite_PutSpriteEx(SP_SEL_COURSE+game.course_id, 190, 200, 1.7, 1.8); - gSprite_PutSprite(24, 460, 300); - gSprite_PutSprite(25, 120, 300); - - gFont_SetString("SELECT COURSE", 150, 50); - - if (pad.right == 1) { - game.course_id = - (game.course_id > MAXFIELD-1) ? 1 : game.course_id + 1; - } - if (pad.left == 1) { - game.course_id = - (game.course_id < 2) ? MAXFIELD : game.course_id - 1; - } - if (pad.circle == 1) { - game.state = GAME_READY; - } - break; + sche_game_select_course(); + break; case GAME_READY: - gSprite_PutSprite(27+game.play_id,265,10); - gSprite_PutSpriteEx(SP_SEL_CAR+game.car_id, 50, 120, 1.5, 1.5); - gSprite_PutSpriteEx(SP_SEL_COURSE+game.course_id, 340, 120, 1.7, 1.8); - { - static int blink_count = 0; - - /* 点滅 */ - if (blink_count < 35) { - gFont_SetString("GAME START !!", 170, 380); - } - blink_count = (blink_count > 70) ? 0 : blink_count+1; - } - - if (pad.st > 0) { - game.state = GAME_MAIN_INIT; - } - if (pad.cross > 0) { - game.state = GAME_SELECT_CAR; - } - break; + sche_game_ready(); + break; case GAME_MAIN_INIT: - if (!game.jiki) - play_init(); - RUNNIG=0; - game.state = GAME_MAIN; - break; + sche_game_main_init(); + break; case GAME_MAIN: - - /** begin: dispaly RAP TIME **/ - if(RUNNIG==0){ - start_time = game_time_get_msec(); - RUNNIG=1; - } - - time_count = game_time_get_msec() - start_time; - game_time_set_raptime(raptime,time_count); - gFont_SetString("TIME",300,20); - gFont_SetString(raptime,400,20); - /** end: dispaly RAP TIME **/ - - - - light_init(&l); - set_light(&l); - - car_update(game.jiki); - // check_car(); - field_update(game.jiki); - camera_update(game.jiki->body->transfer); - carNode_draw(); - - gFont_SetStringInt(game.rap, 50, 100); - - /* スピードメーター */ - gSprite_DefSprite(23, 1, 1,(int)(106.0*(game.jiki->speed/game.jiki->speed_max)), 34); - gSprite_PutSprite(23, 400, 400); - /* km/h */ - gSprite_PutSprite(26, 470, 350); - /* Rap */ - gSprite_PutSprite(27, 80, 100); - - if (game.demo_flg == 1) { - gFont_SetString("D E M O", 280, 200); - } - - if (game.rap > MAXRAP) { - wait_init(); - ranking = 1; - game.state = GAME_GOAL; - } - - gFont_SetStringInt((int)(100.0*game.jiki->speed), 380, 350); - - if ( (pad.right > 0) && ( (game.jiki->speed != 0) || (pad.circle > 0) )) - { - car_swerve(game.jiki, 1); - } - if ( (pad.left > 0) && ( (game.jiki->speed !=0) || (pad.circle > 0) ) ) - { - car_swerve(game.jiki, -1); - } - if (pad.circle > 0) { - car_accelerate(game.jiki, 1); - } - if (pad.cross > 0) { - car_accelerate(game.jiki, -1); - } - if (pad.r1 == 1) { - game.camera_type = !game.camera_type; - } - if (pad.st == 1) { - if (game.demo_flg == 1) { - game.state = GAME_FINISH; - } else { - game.state = GAME_PAUSE; - } - } + sche_game_main(); break; case GAME_PAUSE: - field_update(game.jiki); - carNode_draw(); - - if (game.play_id == 1) { - /* 選択マーク */ - gSprite_PutSprite(17, 100, 190+game.select*100); - - gFont_SetString("BACK TO GAME", 200, 200); - gFont_SetString("GO TO TITLE", 200, 300); - } else { - gFont_SetString("Pause ...", 200, 200); - } - - if (pad.circle == 1) { - if (game.select == 0) { - game.state = GAME_MAIN; - } else { - game.state = GAME_FINISH; - } - } - if (pad.st == 1) { - game.state = GAME_MAIN; - } - if (pad.up == 1 || pad.down == 1) { - game.select = !game.select; - } - break; + sche_game_main_pause(); + break; case GAME_GOAL: - - /** dispaly TOTAL TIME **/ - game_time_set_raptime(raptime,time_count); - - gFont_SetString("TOTAL TIME",150,20); - gFont_SetString(raptime,400,20); - - - - gFont_SetString("GOAL !!", 220, 150); -#ifdef LINDA - if (ranking == 1) - gFont_SetString("You WIN!!", 200, 250); - else - gFont_SetString("You Lose...", 200, 250); -#endif - car_update(game.jiki); - field_update(game.jiki); - carNode_draw(); - camera_update(game.jiki->body->transfer); - if (pad.st == 1) { - game.state = GAME_FINISH; - } - break; + sche_game_main_goal(); + break; case GAME_FINISH: - if (game.demo_flg == 1) { + sche_game_main_finish(); + break; + default: game.state = GAME_OPENING; - } else { - gFont_SetString("GAME OVER ...", 200, 200); - } - if (game.jiki) { - field_destroy(); - carNode_destroy(); - demo_closeFp(); - syokika(); - } - if (pad.st == 1) { - game.state = GAME_OPENING; - } - break; - default: - game.state = GAME_OPENING; - break; + break; } wait_sync(); @@ -393,3 +156,257 @@ gFont_Draw_Reset(); } +void +sche_game_init() +{ + game_env_init(); + graphic_init(); + camera_init(); +} + +void +sche_game_opening() +{ + static int blink_count = 0; + if (game.play_id==1){ + if (blink_count < 35) { + gFont_SetString("PUSH START !!", 170, 380); + } + blink_count = (blink_count > 70) ? 0 : blink_count+1; + } + + if (pad.st == 1) { + game.state = GAME_SELECT_CAR; + } + + /* + if (game.play_id == 1) { + if (title_scene() < 0){ + game.state = GAME_SELECT_CAR; + } + } else if (game.play_id == 2) { + if (i==0){ + title_init_call(); + i=1; + } + } + */ +} + +void +sche_game_select_car() +{ + if (i==1){ + title_finish_call(); + i=2; + } + gSprite_PutSpriteEx(SP_SEL_CAR+game.car_id, 190, 200, 1.5, 1.5); + gSprite_PutSprite(24, 460, 300); + gSprite_PutSprite(25, 120, 300); + gFont_SetString("SELECT CAR", 180, 50); + + if (pad.right == 1) { + game.car_id = + (game.car_id > MAXCAR-1) ? 1 : game.car_id + 1; + } + if (pad.left == 1) { + game.car_id = + (game.car_id < 2) ? MAXCAR : game.car_id - 1; + } + if (pad.circle == 1) { + game.state = GAME_SELECT_COURSE; + } +} + +void +sche_game_select_course() +{ + gSprite_PutSpriteEx(SP_SEL_COURSE+game.course_id, 190, 200, 1.7, 1.8); + gSprite_PutSprite(24, 460, 300); + gSprite_PutSprite(25, 120, 300); + + gFont_SetString("SELECT COURSE", 150, 50); + + if (pad.right == 1) { + game.course_id = + (game.course_id > MAXFIELD-1) ? 1 : game.course_id + 1; + } + if (pad.left == 1) { + game.course_id = + (game.course_id < 2) ? MAXFIELD : game.course_id - 1; + } + if (pad.circle == 1) { + game.state = GAME_READY; + } +} + +void +sche_game_ready() +{ + static int blink_count = 0; + + gSprite_PutSprite(27+game.play_id,265,10); + gSprite_PutSpriteEx(SP_SEL_CAR+game.car_id, 50, 120, 1.5, 1.5); + gSprite_PutSpriteEx(SP_SEL_COURSE+game.course_id, 340, 120, 1.7, 1.8); + + /* 点滅 */ + if (blink_count < 35) { + gFont_SetString("GAME START !!", 170, 380); + } + blink_count = (blink_count > 70) ? 0 : blink_count + 1; + + if (pad.st > 0) { + game.state = GAME_MAIN_INIT; + } + if (pad.cross > 0) { + game.state = GAME_SELECT_CAR; + } +} + +void +sche_game_main_init() +{ + if (!game.jiki) + play_init(); + RUNNIG=0; + game.state = GAME_MAIN; +} + +void +sche_game_main() +{ + + /** begin: dispaly RAP TIME **/ + if(RUNNIG==0){ + start_time = game_time_get_msec(); + RUNNIG=1; + } + + time_count = game_time_get_msec() - start_time; + game_time_set_raptime(raptime,time_count); + gFont_SetString("TIME",300,20); + gFont_SetString(raptime,400,20); + /** end: dispaly RAP TIME **/ + + light_init(&l); + set_light(&l); + + car_update(game.jiki); + field_update(game.jiki); + camera_update(game.jiki->body->transfer); + carNode_draw(); + + gFont_SetStringInt(game.rap, 50, 100); + + /* スピードメーター */ + gSprite_DefSprite(23, 1, 1,(int)(106.0*(game.jiki->speed/game.jiki->speed_max)), 34); + gSprite_PutSprite(23, 400, 400); + /* km/h */ + gSprite_PutSprite(26, 470, 350); + /* Rap */ + gSprite_PutSprite(27, 80, 100); + + if (game.rap > MAXRAP) { + wait_init(); + ranking = 1; + game.state = GAME_GOAL; + } + + gFont_SetStringInt((int)(100.0*game.jiki->speed), 380, 350); + + if ((pad.right > 0) && ((game.jiki->speed != 0) || (pad.circle > 0))) { + car_swerve(game.jiki, 1); + } + if ((pad.left > 0) && ((game.jiki->speed != 0) || (pad.circle > 0))) { + car_swerve(game.jiki, -1); + } + if (pad.circle > 0) { + car_accelerate(game.jiki, 1); + } + if (pad.cross > 0) { + car_accelerate(game.jiki, -1); + } + if (pad.r1 == 1) { + game.camera_type = !game.camera_type; + } + if (pad.st == 1) { + game.state = GAME_PAUSE; + } +} + +void +sche_game_main_pause() +{ + field_update(game.jiki); + carNode_draw(); + + if (game.play_id == 1) { + /* 選択マーク */ + gSprite_PutSprite(17, 100, 190+game.select*100); + + gFont_SetString("BACK TO GAME", 200, 200); + gFont_SetString("GO TO TITLE", 200, 300); + } else { + gFont_SetString("Pause ...", 200, 200); + } + + if (pad.circle == 1) { + if (game.select == 0) { + game.state = GAME_MAIN; + } else { + game.state = GAME_FINISH; + } + } + if (pad.st == 1) { + game.state = GAME_MAIN; + } + if (pad.up == 1 || pad.down == 1) { + game.select = !game.select; + } +} + +void +sche_game_main_goal() +{ + + /** dispaly TOTAL TIME **/ + game_time_set_raptime(raptime,time_count); + + gFont_SetString("TOTAL TIME",150,20); + gFont_SetString(raptime,400,20); + + + + gFont_SetString("GOAL !!", 220, 150); + +#ifdef LINDA + if (ranking == 1) + gFont_SetString("You WIN!!", 200, 250); + else + gFont_SetString("You Lose...", 200, 250); +#endif + + car_update(game.jiki); + field_update(game.jiki); + carNode_draw(); + camera_update(game.jiki->body->transfer); + if (pad.st == 1) { + game.state = GAME_FINISH; + } +} + +void +sche_game_main_finish() +{ + gFont_SetString("GAME OVER ...", 200, 200); + + if (game.jiki) { + field_destroy(); + carNode_destroy(); + demo_closeFp(); + game_env_init(); + } + if (pad.st == 1) { + game.state = GAME_OPENING; + } +}