Mercurial > hg > old > magoroku_racing
diff schedule.c @ 90:8edae89a3877
compile on Mac OS X
author | Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 May 2011 16:41:21 +0900 |
parents | ce9ef7dcf2f0 |
children | cb6c6de125dc |
line wrap: on
line diff
--- a/schedule.c Thu May 19 16:38:44 2011 +0900 +++ b/schedule.c Thu May 19 16:41:21 2011 +0900 @@ -1,11 +1,9 @@ -/* - * $Id$ - */ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "libps2.h" -#include "ps2util.h" +#include <stdbool.h> +//#include "libps2.h" +//#include "ps2util.h" #include "field.h" #include "car.h" #include "gSprite.h" @@ -13,15 +11,18 @@ #include "game.h" #include "controler.h" #include "camera.h" -#include "light.h" +//#include "light.h" #include "title_scene.h" #include "game_time.h" #include "schedule.h" +#include "game.h" + + #ifdef LINDA -extern Bool linda_update(int); +bool linda_update(int p, Game *game); #else -#define linda_update(int) TRUE +#define linda_update(change_state, game) true #endif #define MAXCAR 3 // 選択可能機体 @@ -30,6 +31,27 @@ #define SP_SEL_CAR 50 #define SP_SEL_COURSE 80 +//extern Game *game; + +static void set_schedule(Game *game); +static void sche_game_init(Game *game); +static void sche_game_wait(Game *game); +static void sche_game_wait_ready(Game *game); +static void sche_game_opening(Game *game); +static void sche_game_select_car(Game *game); +static void sche_game_select_course(Game *game); +static void sche_game_ready(Game *game); +static void sche_game_main_init(Game *game); +static void sche_game_main_ready(Game *game); +static void sche_game_main(Game *game); +//static void sche_game_main_pause(Game *game); +static void sche_game_main_goal(Game *game); +static void sche_game_main_finish(Game *game); +static void sche_game_main_finish2(Game *game); + + + + /* --- car.c --- */ extern void car_update(CarPtr); /* --- carNode.c */ @@ -40,7 +62,7 @@ extern void field_update(CarPtr); /* --- mytype.c --- */ extern void wait_init(); -extern Bool wait(double); +//extern bool wait(double); extern void time_RaceStart(); extern double time_RaceTime(); /* --- linda.c --- */ @@ -54,7 +76,7 @@ char raptime[10]; static int ranking = 0; -static LIGHT l; +//static LIGHT l; static int i=0; @@ -75,7 +97,7 @@ } static void -set_schedule() +set_schedule(Game *game) { sche_func = sche_func_assumption; change_state = 0; @@ -84,26 +106,26 @@ static void graphic_init() { - gSprite_Init(); // グラフィック関連の初期化 + // gSprite_Init(); // グラフィック関連の初期化 gFont_Init(); // フォント関連の初期化 } static void -play_init() +play_init(Game *game) { - game.jiki = car_init(game.car_id); - carNode_append(game.jiki); - field_init(game.course_id); + game->jiki = car_init(game->car_id); + carNode_append(game->jiki); + field_init(game->course_id); } static void -game_env_init() +game_env_init(Game *game) { - game.car_id = 1; - game.course_id = 1; - game.camera_type = 0; - game.rap = 1; - game.jiki = NULL; + game->car_id = 1; + game->course_id = 1; + game->camera_type = 0; + game->rap = 1; + game->jiki = NULL; ranking = 0; @@ -114,9 +136,9 @@ void -sche_game_init() +sche_game_init(Game *game) { - game_env_init(); + game_env_init(game); graphic_init(); camera_init(); @@ -132,56 +154,58 @@ * 通信対戦専用 * 全ユーザが接続するまで待つ */ + static void -sche_game_wait() +sche_game_wait(Game *game) { gFont_SetString("WAITING...", 200, 100); set_schedule_assumption(sche_game_wait_ready); } + /** * 通信対戦専用 * 全ユーザの接続を確認したら呼び出す */ static void -sche_game_wait_ready() +sche_game_wait_ready(Game *game) { gFont_SetString("CONNECT OK!!", 170, 300); - if (game.play_id == 1) { + if (game->play_id == 1) { gFont_SetString(" PUSH START ", 170, 400); - if (pad.st != 1) { goto WAIT_READY; } + // if (pad.st != 1) { goto WAIT_READY; } } set_schedule_assumption(sche_game_opening); -WAIT_READY: + //WAIT_READY: return; } void -sche_game_opening() +sche_game_opening(Game *game) { static int blink_count = 0; - if (game.play_id==1){ + 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) { goto OPENING; } + // if (pad.st != 1) { goto OPENING; } } set_schedule_assumption(sche_game_select_car); -OPENING: + //OPENING: return; /* - if (game.play_id == 1) { + if (game->play_id == 1) { if (title_scene() < 0){ } - } else if (game.play_id == 2) { + } else if (game->play_id == 2) { if (i==0){ title_init_call(); i=1; @@ -191,75 +215,76 @@ } void -sche_game_select_car() +sche_game_select_car(Game *game) { 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); - + // 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; + 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; + game->car_id = + (game->car_id < 2) ? MAXCAR : game->car_id - 1 } - if (game.play_id == 1) - if (pad.circle != 1) { goto SELECT_CAR; } - + if (game->play_id == 1) + if (pad.circle != 1) { goto SELECT_CAR; } + */ - set_schedule_assumption(sche_game_select_course); + set_schedule_assumption(sche_game_select_course); -SELECT_CAR: + //SELECT_CAR: return; } void -sche_game_select_course() +sche_game_select_course(Game *game) { - gSprite_PutSpriteEx(SP_SEL_COURSE+game.course_id, 190, 200, 1.7, 1.8); - gSprite_PutSprite(24, 460, 300); - gSprite_PutSprite(25, 120, 300); + // 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); + // gFont_SetString("SELECT COURSE", 150, 50); - if (game.play_id == 1) { - if (pad.right == 1) { - game.course_id = - (game.course_id > MAXFIELD-1) ? 1 : game.course_id + 1; + if (game->play_id == 1) { + /* if (pad.right == 1) { + game->course_id = + (game->course_id > MAXFIELD-1) ? 1 : game->course_id + 1; goto SELECT_COURSE; } if (pad.left == 1) { - game.course_id = - (game.course_id < 2) ? MAXFIELD : game.course_id - 1; + game->course_id = + (game->course_id < 2) ? MAXFIELD : game->course_id - 1; goto SELECT_COURSE; } if (pad.circle != 1) { goto SELECT_COURSE; } + */ } set_schedule_assumption(sche_game_ready); -SELECT_COURSE: + //SELECT_COURSE: return; } void -sche_game_ready() +sche_game_ready(Game *game) { - static int blink_count = 0; + 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); + 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) { @@ -280,24 +305,24 @@ } void -sche_game_main_init() +sche_game_main_init(Game *game) { - if (!game.jiki) - play_init(); + if (!game->jiki) + play_init(game); RUNNIG=0; set_schedule_assumption(sche_game_main_ready); } static void -sche_game_main_ready() +sche_game_main_ready(Game *game) { gFont_SetString("Loading....", 180, 100); set_schedule_assumption(sche_game_main); } static void -sche_game_main() +sche_game_main(Game *game) { /** begin: dispaly RAP TIME **/ @@ -312,62 +337,65 @@ gFont_SetString(raptime,400,20); /** end: dispaly RAP TIME **/ - light_init(&l); - set_light(&l); + // light_init(&l); + // set_light(&l); - car_update(game.jiki); - field_update(game.jiki); - camera_update(game.jiki->body->transfer); - carNode_draw(); + car_update(game->jiki); + field_update(game->jiki); + // camera_update(game->jiki->body->transfer); + // carNode_draw(); - gFont_SetStringInt(game.rap, 50, 100); + gFont_SetStringInt(game->rap, 50, 100); /* スピードメーター */ - gSprite_DefSprite(23, 1, 1,(int)(106.0*(game.jiki->speed/game.jiki->speed_max)), 34); + 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) { + if (game->rap > MAXRAP) { ranking = 1; set_schedule_assumption(sche_game_main_goal); } - gFont_SetStringInt((int)(100.0*game.jiki->speed), 380, 350); + 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.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.left > 0) && ((game->jiki->speed != 0) || (pad.circle > 0))) { + car_swerve(game->jiki, -1); } if (pad.circle > 0) { - car_accelerate(game.jiki, 1); + car_accelerate(game->jiki, 1); } if (pad.cross > 0) { - car_accelerate(game.jiki, -1); + car_accelerate(game->jiki, -1); } if (pad.r1 == 1) { - game.camera_type = !game.camera_type; + game->camera_type = !game->camera_type; } if (pad.st == 1) { set_schedule_assumption(sche_game_main_pause); } + */ } +/* void -sche_game_main_pause() +sche_game_main_pause(Game *game) { static int select = 0; - field_update(game.jiki); - carNode_draw(); + field_update(game->jiki); + // carNode_draw(); - if (game.play_id == 1) { - /* 選択マーク */ + if (game->play_id == 1) { + // 選択マーク gSprite_PutSprite(17, 100, 190+select*100); gFont_SetString("BACK TO GAME", 200, 200); @@ -376,6 +404,7 @@ gFont_SetString("Pause ...", 200, 200); } + if (pad.circle == 1) { if (select == 0) { set_schedule_assumption(sche_game_main); @@ -387,10 +416,12 @@ } else if (pad.up == 1 || pad.down == 1) { select = !select; } + } +*/ void -sche_game_main_goal() +sche_game_main_goal(Game *game) { /** dispaly TOTAL TIME **/ game_time_set_raptime(raptime,time_count); @@ -406,51 +437,57 @@ gFont_SetString("You Lose...", 200, 250); #endif - car_update(game.jiki); - field_update(game.jiki); - carNode_draw(); - camera_update(game.jiki->body->transfer); + car_update(game->jiki); + field_update(game->jiki); + // carNode_draw(); + // camera_update(game->jiki->body->transfer); + /* if (pad.st == 1) { set_schedule_assumption(sche_game_main_finish); } + */ } void -sche_game_main_finish() +sche_game_main_finish(Game *game) { field_destroy(); carNode_destroy(); - game_env_init(); + game_env_init(game); set_schedule_assumption(sche_game_main_finish2); } void -sche_game_main_finish2() +sche_game_main_finish2(Game *game) { gFont_SetString("GAME OVER ...", 200, 200); + /* if (pad.st == 1) { set_schedule_assumption(sche_game_opening); } + */ } void -schedule() +schedule(Game *game) { - sche_func(); + sche_func(game); - if (linda_update(change_state) == TRUE) - set_schedule(); - else + if (linda_update(change_state, game) == true){ + set_schedule(game); + } + else{ unset_schedule(); + } - wait_sync(); - swap_dbuff(); - sjoy_poll(); + // wait_sync(game); + // swap_dbuff(); + // sjoy_poll(); - ps2util_sprite_Draw(); - gSprite_Draw_Reset(); - gFont_Draw_Reset(); + // ps2util_sprite_Draw(); + // gSprite_Draw_Reset(); + // gFont_Draw_Reset(); }