void RankingTopScore(RankingInfo *res) { sParam *ranking = ReadGameSettings(); res->score = ParamGetReal(ranking, "1.score"); res->boss = ParamGetReal(ranking, "1.boss"); ParamDestroy(ranking); }
int BulletCreate(char *id_str, FVector2 *pos, FVector2 *vct, float r, u_int target, sParam *param, int level, float powofs) { char id_param[ID_MAXLEN]; sParam *objParam = ObjGetSetupParam(id_str); ASSERT(objParam); int maxlevel = ParamGetReal(objParam, "maxlevel"); if(level > maxlevel) level = maxlevel; for(int i = 1; ; i += 1) { sprintf(id_param, "%d.shot_pos%d", level, i); if(!ParamIsExists(objParam, id_param)) break; FVector3 *p = ParamGetFVec3(objParam, id_param); FVector2 v; v.x = p->x; v.y = p->y; MathRotateXY(&v, r); AddV2d(&v, &v, pos); StkMakeFrame(); StkPushP(param); // 0 StkPushP(&v); // 1 StkPushP(vct); // 2 StkPushF(NormalAngle(r + ANG2RAD(p->z))); // 3 StkPushF(powofs); // 4 ObjCreate(id_str, OBJ_SHOT, objProc, level, target); StkDelFrame(); } sprintf(id_param, "%d.interval", level); return ParamGetReal(objParam, id_param); }
void SpriteSetup(Sprite *spr, char *name, sParam *param) { char id_str[ID_MAXLEN]; FVector2 *value; sprintf(id_str, "%s.uv", name); value = ParamGetFVec2(param, id_str); ASSERT(value); spr->uv = *value; sprintf(id_str, "%s.size", name); value = ParamGetFVec2(param, id_str); ASSERT(value); spr->size = *value; sprintf(id_str, "%s.pos", name); value = ParamGetFVec2(param, id_str); ASSERT(value); spr->pos = *value; spr->center = FVec2Zero; sprintf(id_str, "%s.center", name); if(ParamIsExists(param, id_str)) { spr->center = *ParamGetFVec2(param, id_str); } spr->scale = FVec2One; spr->col = RGBAWhite; spr->blend = GRP_BLEND_NORMAL; spr->rot = 0.0f; spr->prio = PRIO_COCKPIT; sprintf(id_str, "%s.disp", name); spr->disp = ParamIsExists(param, id_str) ? ParamGetReal(param, id_str) : TRUE; }
/* フィールドを無限ループする処理 */ BOOL GameFieldRange(FVector2 *pos) { sParam *param = MainGetParam(); FVector2 *p_pos = PlayerGetPos(); BOOL wrap = FALSE; if(param && p_pos) { float dx = pos->x - p_pos->x; float dy = pos->y - p_pos->y; float field_range = ParamGetReal(param, "field_range"); if(dx > field_range) { pos->x -= field_range * 2.0f; wrap = TRUE; } else if(dx < -field_range) { pos->x += field_range * 2.0f; wrap = TRUE; } if(dy > field_range) { pos->y -= field_range * 2.0f; wrap = TRUE; } else if(dy < -field_range) { pos->y += field_range * 2.0f; wrap = TRUE; } } return wrap; }
static int spriteProc(sTaskBody *body, int msg, int lParam, int rParam) { int res = 0; SpriteVar *var = (SpriteVar *)TaskGetVar(body, sizeof(SpriteVar), MEM_APP); switch(msg) { case MSG_CREATE: { char *name = (char *)StkRefFrameP(0); var->obj = (Sprite *)StkRefFrameP(1); sParam *param = (sParam *)StkRefFrameP(2); int delay = StkRefFrameI(3); char id_str[ID_MAXLEN]; sprintf(id_str, "%s.delay", name); delay += ParamGetReal(param, id_str) * FRAME_RATE; if(delay > 0) TaskSleep(body, delay); sprintf(id_str, "%s.frame", name); var->frame = ParamGetReal(param, id_str) * FRAME_RATE; sprintf(id_str, "%s.slow", name); var->slow = ParamGetReal(param, id_str); sprintf(id_str, "%s.start", name); if(ParamIsExists(param, id_str)) { var->pos_start = *ParamGetFVec2(param, id_str); } else { var->pos_start = var->obj->pos; } sprintf(id_str, "%s.end", name); if(ParamIsExists(param, id_str)) { var->pos_end = *ParamGetFVec2(param, id_str); } else { var->pos_end = var->obj->pos; } var->obj->pos = var->pos_start; sprintf(id_str, "%s.s_sc", name); if(ParamIsExists(param, id_str)) { var->scale_start = *ParamGetFVec2(param, id_str); } else { var->scale_start = var->obj->scale; } sprintf(id_str, "%s.e_sc", name); if(ParamIsExists(param, id_str)) { var->scale_end = *ParamGetFVec2(param, id_str); } else { var->scale_end = var->obj->scale; } var->obj->scale = var->scale_start; } break; case MSG_KILL: { } break; case MSG_STEP: { var->count += 1; float d = (float)var->count / (float)var->frame; if(var->slow) d = d * d; else d = (2.0f - d) * d; var->obj->pos.x = var->pos_start.x + (var->pos_end.x - var->pos_start.x) * d; var->obj->pos.y = var->pos_start.y + (var->pos_end.y - var->pos_start.y) * d; var->obj->scale.x = var->scale_start.x + (var->scale_end.x - var->scale_start.x) * d; var->obj->scale.y = var->scale_start.y + (var->scale_end.y - var->scale_start.y) * d; res = (var->count == var->frame); } break; case MSG_GAME_TITLE_SKIP_EFFECT: { TaskAwake(body); var->count = var->frame - 1; } break; } return res; }
static int mainProc(sTaskBody *body, int msg, int lParam, int rParam) { int res = 0; TitleVar *var = (TitleVar *)TaskGetVar(body, sizeof(TitleVar), MEM_APP); switch(msg) { case MSG_CREATE: { sParam *param = ParamRead(PATH_DATA"/title.param"); var->param = param; var->texture = ParamGetTex(param, "texture"); for(int i = 0; i < LOGO_CHARANUM; i += 1) { char id_str[ID_MAXLEN]; sprintf(id_str, "%d", i + 1); SpriteSetup(&var->logo[i], id_str, param); } SpriteSetup(&var->game, "game", param); SpriteSetup(&var->start, "start", param); SpriteSetup(&var->copyright, "copy", param); SpriteSetup(&var->ngs, "ngs", param); SpriteSetup(&var->cursor[0], ">", param); SpriteSetup(&var->cursor[1], "<", param); var->cursor_pos[0] = var->cursor[0].pos; var->cursor_pos[1] = var->cursor[1].pos; var->start_fade = ParamGetReal(param, "start_fade"); FVector2 *scale = ParamGetFVec2(param, "start_scale"); var->start_scale = scale->x; var->game.scale.x = var->game.scale.y = var->start_scale; var->start.scale.x = var->start.scale.y = var->start_scale; var->start_cur = FALSE; var->started = FALSE; var->abort_count = ParamGetReal(param, "title_count") * FRAME_RATE; SpriteSetup(&var->speker, "vol", param); SpriteSetup(&var->vol[0], "vol1", param); SpriteSetup(&var->vol[1], "vol2", param); SpriteSetup(&var->vol[2], "vol3", param); SpriteSetup(&var->vol_var[0], "v_var1", param); SpriteSetup(&var->vol_var[1], "v_var2", param); if(lParam) SndEffectReq("title", 15, 0.8f); if(!rParam) { int delay = ParamGetReal(param, "title_delay") * FRAME_RATE; if(delay > 0) TaskSleep(body, delay); for(int i = 0; i < LOGO_CHARANUM; i += 1) { char id_str[ID_MAXLEN]; sprintf(id_str, "%ds", i + 1); createSpriteTask(&var->logo[i], id_str, var->param, delay); } var->start_delay = ParamGetReal(param, "start_delay") * FRAME_RATE; var->game.disp = FALSE; var->start.disp = FALSE; var->copyright.disp = FALSE; var->ngs.disp = FALSE; var->cursor[0].disp = FALSE; var->cursor[1].disp = FALSE; var->speker.disp = FALSE; for(int i = 0; i < 3; i += 1) { var->vol[i].disp = FALSE; } for(int i = 0; i < 2; i += 1) { var->vol_var[i].disp = FALSE; } } else { createLogoTask(var->logo, 1 * FRAME_RATE); var->start_delay = 0; setupVolume(var); } BOOL exec = rParam; if(exec) exec = !InputGetBtnP(MOUSE_LEFT); InputSetAppExec(INP_CH0, exec); /* SHOTの暴発を避けるため、若干回りくどい */ } break; case MSG_KILL: { if(var->chg_gain) { sParam *settings = MainGetSettings(); ParamSetReal(settings, "gain", SndGetMasterGain()); WriteGameSettings(settings); } ParamDestroy(var->param); } break; case MSG_PREPROC: { if(!var->started && (var->start_delay == 0)) { BOOL slider = sliderVolume(var); if(slider && var->abort_count < (1 * FRAME_RATE)) var->abort_count = 1 * FRAME_RATE; if(!slider && var->abort_count > 0) var->abort_count -= 1; } } break; case MSG_STEP: { if(var->started) { switch(var->start_eft_mode) { case 0: { var->start_count -= 1; float alpha = (var->start_count & 0x2) ? 1.0f : 0.5f; if(var->start_count == 0) { var->start_eft_mode += 1; var->start_count = ParamGetReal(var->param, "end_delay") * FRAME_RATE; for(int i = 0; i < LOGO_CHARANUM; i += 1) { char id_str[ID_MAXLEN]; sprintf(id_str, "%de", i + 1); createSpriteTask(&var->logo[i], id_str, var->param, 0); } createSpriteTask(&var->game, "game", var->param, 0); createSpriteTask(&var->start, "start", var->param, 0); createSpriteTask(&var->copyright, "copy", var->param, 0); createSpriteTask(&var->ngs, "ngs", var->param, 0); createSpriteTask(&var->speker, "vol", var->param, 0); createSpriteTask(&var->vol[0], "vol1", var->param, 0); createSpriteTask(&var->vol[1], "vol2", var->param, 0); createSpriteTask(&var->vol[2], "vol3", var->param, 0); createSpriteTask(&var->vol_var[0], "v_var1", var->param, 0); createSpriteTask(&var->vol_var[1], "v_var2", var->param, 0); SndEffectReq("title_fin", 0.4f * FRAME_RATE, 0.3f); alpha = 1.0f; } var->game.col.alpha = alpha; var->start.col.alpha = alpha; } break; case 1: { var->start_count -= 1; if(var->start_count <= 0) { InputSetAppBtnExec(INP_CH0, TRUE); TaskPostMsgAll(TASK_PRI_NONE, MSG_GAME_GAMESTART, 0, 0); res = 1; } } break; } } else if(var->start_delay > 0) { BOOL disp = var->start_delay -= 1; BOOL abort = InputGetBtnTD(MOUSE_LEFT | MOUSE_D_LEFT); if(abort) { disp = FALSE; TaskPostMsgAll(TASK_PRI_03, MSG_GAME_TITLE_SKIP_EFFECT, 0, 0); var->start_delay = 0; } if(!disp) { createLogoTask(var->logo, 1 * FRAME_RATE); var->game.disp = TRUE; var->start.disp = TRUE; var->copyright.disp = TRUE; var->ngs.disp = TRUE; var->cursor[0].disp = TRUE; var->cursor[1].disp = TRUE; var->speker.disp = TRUE; for(int i = 0; i < 2; i += 1) { var->vol_var[i].disp = TRUE; } setupVolume(var); if(!abort) InputSetAppExec(INP_CH0, TRUE); } } else { if(InputGetBtnTU(MOUSE_LEFT | MOUSE_D_LEFT)) { InputSetAppExec(INP_CH0, TRUE); /* ボタンが離されるまで入力禁止 */ } int x = InputGetMouseX(); int y = InputGetMouseY(); /* かなり強引な方法 */ BOOL start = FALSE; sBox box = {{ 180 -10, 330 - 10 }, {328 + 10, 362 + 10} }; /* box.inf.x = 180 - 10; */ /* box.inf.y = 330 - 10; */ /* box.sup.x = 328 + 10; */ /* box.sup.y = 362 + 10; */ FVector2 *scale = ParamGetFVec2(var->param, "start_scale"); if(MathBoxCrossPoint(x, y, &box)) { start = TRUE; var->start_scale += (scale->y - var->start_scale) * 0.4f; var->cursor[0].col.alpha -= 0.08f; var->cursor[1].col.alpha -= 0.08f; var->start_count = 0; } else { var->start_scale += (scale->x - var->start_scale) * 0.3f; var->cursor[0].col.alpha += 0.025f; var->cursor[1].col.alpha += 0.025f; var->start_count += 1; } var->game.scale.x = var->game.scale.y = var->start_scale; var->start.scale.x = var->start.scale.y = var->start_scale; if(var->cursor[0].col.alpha < 0.0f) { var->cursor[0].col.alpha = 0.0f; var->cursor[1].col.alpha = 0.0f; } else if(var->cursor[0].col.alpha > 1.0f) { var->cursor[0].col.alpha = 1.0f; var->cursor[1].col.alpha = 1.0f; } float alpha = 0.5f + cosf((float)var->start_count * var->start_fade) * 0.5f; var->game.col.alpha = alpha; var->start.col.alpha = alpha; { float ofs = fabsf(sinf((float)g.time * 0.08f)) * 8.0f; var->cursor[0].pos.x = var->cursor_pos[0].x - ofs; var->cursor[1].pos.x = var->cursor_pos[1].x + ofs; } if(var->start_cur != start) { if(start) SndEffectReq("start_touch", 0, 1.0f); InputSetAppBtnExec(INP_CH0, !start); var->start_cur = start; } if(start && InputGetBtnTD(MOUSE_LEFT | MOUSE_D_LEFT)) { SndStop("bgm"); SndEffectReq("start_push", 0, 1.0f); var->started = TRUE; var->start_eft_mode = 0; var->start_scale = 1.5f; var->start_count = ParamGetReal(var->param, "start_count") * FRAME_RATE; var->cursor[0].disp = FALSE; var->cursor[1].disp = FALSE; TaskPostMsgAll(TASK_PRI_03, MSG_GAME_TITLE_LOGOEFT_FIN, 0, 0); } else { if(var->abort_count == 0) { TaskDeleteAll(TASK_PRI_03); TaskPostMsgAll(TASK_PRI_NONE, MSG_GAME_TITLE_FIN, 0, 0); res = 1; } } } #ifdef DEBUG if((!res) && (InputGetKey() == 'd')) { TaskDeleteAll(TASK_PRI_03); TaskPostMsgAll(TASK_PRI_NONE, MSG_GAME_START, TRUE, 0); res = 1; } #endif } break; case MSG_DRAW: { for(int i = 0; i < LOGO_CHARANUM; i += 1) { SpriteDraw(&var->logo[i], var->texture); } SpriteDraw(&var->game, var->texture); SpriteDraw(&var->start, var->texture); SpriteDraw(&var->copyright, var->texture); SpriteDraw(&var->ngs, var->texture); SpriteDraw(&var->cursor[0], var->texture); SpriteDraw(&var->cursor[1], var->texture); SpriteDraw(&var->speker, var->texture); for(int i = 0; i < 3; i += 1) { SpriteDraw(&var->vol[i], var->texture); } SpriteDraw(&var->vol_var[0], var->texture); SpriteDraw(&var->vol_var[1], var->texture); } break; } return res; }
static int mainProc(sTaskBody *body, int msg, int lParam, int rParam) { int res = 0; RankingVar *var = (RankingVar *)TaskGetVar(body, sizeof(RankingVar), MEM_APP); switch(msg) { case MSG_CREATE: { var->param = ParamRead(PATH_DATA"/ranking.param"); var->ranking = ReadGameSettings(); RankingInfo *info = (RankingInfo *)StkRefFrameP(0); var->score = info->score; var->boss = info->boss; var->weapon = info->weapon; var->playend = lParam; FVector2 *value = ParamGetFVec2(var->param, "ranking_count"); var->abort_count = ((lParam) ? value->y : value->x) * FRAME_RATE; var->fade_in = ParamGetReal(var->param, "fade_in") * FRAME_RATE; var->input_delay = ParamGetReal(var->param, "input_delay") * FRAME_RATE; RankingScore *rankingScore = var->rankingScore; for(int i = 0; i < RANKING_MAX; i++) { char id_str[ID_MAXLEN]; sprintf(id_str, "%d.name", i + 1); char *name = ParamGetStr(var->ranking, id_str); strcpy(rankingScore->name, name); sprintf(id_str, "%d.score", i + 1); rankingScore->score = ParamGetReal(var->ranking, id_str); sprintf(id_str, "%d.boss", i + 1); rankingScore->boss = ParamGetReal(var->ranking, id_str); sprintf(id_str, "%d.weapon", i + 1); rankingScore->weapon = ParamGetReal(var->ranking, id_str); rankingScore += 1; } if(var->playend) { RankingScore *rankingScore = var->rankingScore; int index = RANKING_MAX; for(int i = 0; i < RANKING_MAX; i += 1) { if(var->score >= rankingScore->score) { index = i; break; } rankingScore += 1; } for(int i = RANKING_MAX - 1; i > index; i -= 1) { var->rankingScore[i] = var->rankingScore[i - 1]; } if(index < RANKING_MAX) { var->rank_in = TRUE; var->rank_in_index = index; rankingScore->score = var->score; rankingScore->boss = var->boss; rankingScore->weapon = var->weapon; strcpy(rankingScore->name, " "); SndEffectReq("rank_in", ParamGetReal(var->param, "se_delay") * FRAME_RATE, 1.0f); } } } break; case MSG_KILL: { ParamDestroy(var->ranking); ParamDestroy(var->param); } break; case MSG_STEP: { BOOL abort = InputGetBtnTD(MOUSE_LEFT | MOUSE_D_LEFT); BOOL inkey = FALSE; BOOL key_input = var->rank_in; if(var->fade_in > 0) { var->fade_in -= 1; float fade_in = ParamGetReal(var->param, "fade_in") * FRAME_RATE; var->alpha = (fade_in - (float)var->fade_in) / fade_in; } if(var->input_delay > 0) { var->input_delay -= 1; abort = FALSE; key_input = FALSE; } if(key_input) { char input = InputGetKey(); if(input == '"') input = '\''; /* 苦肉の策 */ RankingScore *rankingScore = &var->rankingScore[var->rank_in_index]; if(input == 0xd) { abort = TRUE; } else if((var->cursor > 0) && (input == ASCII_BS || input == ASCII_DEL)) { var->cursor -= 1; rankingScore->name[var->cursor] = ' '; inkey = TRUE; } else if((var->cursor < 3) && (input >= 0x20) && (input <= 0x7e)) { rankingScore->name[var->cursor] = input; var->cursor += 1; inkey = TRUE; } } else if(var->abort_count > 0) { var->abort_count -= 1; } if(inkey || abort) SndEffectReq("rank_key", 0, 1.0f); res = ((var->abort_count == 0) || abort); if(res) { if(var->rank_in) { recordRanking(var); } TaskPostMsgAll(TASK_PRI_NONE, MSG_GAME_RANKING_FIN, 0, 0); } } break; case MSG_DRAW: { FontPrintF(174, 115, PRIO_COCKPIT, "$A%f$$F1$C1R $C7A N K I N $C2G", var->alpha); RankingScore *rankingScore = var->rankingScore; for(int i = 0; i < RANKING_MAX; i += 1) { char *name = rankingScore->name; int score = rankingScore->score; int boss = rankingScore->boss; if(var->rank_in && (var->rank_in_index == i)) { char id_str[ID_MAXLEN]; sprintf(id_str, "%d.rank_str", i + 1); char *rank_str = ParamGetStr(var->param, id_str); int col = (g.time % 7) + 1; FontPrintF(115, 165 + 24 * i, PRIO_COCKPIT, "$A%f$$F1$C%d%s %s %7d B-%-2d", var->alpha, col, rank_str, name, score, boss); char cur[5] = " "; cur[var->cursor] = (var->input_delay == 0) ? '_' : ' '; FontPrintF(115, 167 + 24 * i, PRIO_COCKPIT, "$A%f$$F1$C%d %s", var->alpha, col, cur); } else { char id_str[ID_MAXLEN]; sprintf(id_str, "%d.rank_hdr", i + 1); char *rank_hdr = ParamGetStr(var->param, id_str); sprintf(id_str, "%d.rank_str", i + 1); char *rank_str = ParamGetStr(var->param, id_str); FontPrintF(115, 165 + 24 * i, PRIO_COCKPIT, "$A%f$$F1%s%s $C7%s %7d $C8B$C7-%-2d", var->alpha, rank_hdr, rank_str, name, score, boss); } rankingScore += 1; } } break; } return res; }
static int objProc(sOBJ *obj, sParam *param, int msg, int lParam, int rParam) { int res = 0; ObjVar *var = (ObjVar *)ObjGetVar(obj, sizeof(ObjVar)); switch(msg) { case MSG_CREATE: { var->level = lParam; var->target_flag = (u_int)rParam; var->param = (sParam *)StkRefFrameP(0); var->pos = *(FVector2 *)StkRefFrameP(1); var->vct = *(FVector2 *)StkRefFrameP(2); var->dir = StkRefFrameF(3); float powofs = StkRefFrameF(4); var->radius = ParamGetReal(param, "radius"); var->speed = ParamGetReal(param, "speed"); var->power = PowerConvertInterValue(ParamGetReal(param, "power") * powofs); FVector4 *col; col = ParamGetFVec4(param, "col1"); SetRGBA(&var->col1, col->x, col->y, col->z, col->w); col = ParamGetFVec4(param, "col2"); SetRGBA(&var->col2, col->x, col->y, col->z, col->w); var->disp_size = ParamGetFVec2(param, "disp_size"); FVector2 vct; MathCalcVector(&vct, var->dir, var->speed); var->vct.x += vct.x; var->vct.y += vct.y; ObjSetPos(obj, var->pos.x, var->pos.y); ObjSetDir(obj, var->dir); ObjSetVct(obj, var->vct.x, var->vct.y); } break; case MSG_KILL: { } break; case MSG_STEP: { #if 0 GameFieldRange(&var->pos); #endif var->pos.x += var->vct.x; var->pos.y += var->vct.y; ObjSetPos(obj, var->pos.x, var->pos.y); ObjSetDir(obj, var->dir); ObjSetVct(obj, var->vct.x, var->vct.y); res = FieldClip(&var->pos, 20.0f); if(res) { ObjKillReq(obj); } else { /* TODO:非常に重い処理なので解決策を考える */ BOOL kill = sendDamage(obj, var->target_flag, &var->pos, &var->vct, var->radius, var->power); if(kill) { ObjKillReq(obj); } } } break; case MSG_DRAW: { sGRPOBJ *grp; grp = GRPOBJ_FILLCIRCLE(PRIO_SHOT); GrpSetPos(grp, var->disp_x, var->disp_y); GrpSetRot(grp, var->dir); GrpSetRGBA(grp, var->col1.red, var->col1.green, var->col1.blue, var->col1.alpha); GrpSetSize(grp, var->disp_size->x, var->disp_size->x); GrpSetLineNum(grp, 8); GrpSetSmooth(grp, TRUE); grp = GRPOBJ_FILLCIRCLE(PRIO_SHOT); GrpSetPos(grp, var->disp_x, var->disp_y); GrpSetRot(grp, var->dir); GrpSetRGBA(grp, var->col2.red, var->col2.green, var->col2.blue, var->col2.alpha); GrpSetSize(grp, var->disp_size->y, var->disp_size->y); GrpSetLineNum(grp, 6); GrpSetSmooth(grp, TRUE); #ifdef DEBUG if(isDispDebugInfo()) { sGRPOBJ *grp = GRPOBJ_CIRCLE(PRIO_DEBUG_PRINT); GrpSetPos(grp, var->disp_x, var->disp_y); GrpSetSize(grp, var->radius, var->radius); GrpSetLineNum(grp, 12); GrpSetRGBA(grp, 1.0f, 1.0f, 0.0f, 1.0f); GrpSetDrawSize(grp, 1.0f); } #endif } break; case MSG_GAME_CAMERA: { FVector2 *pos = (FVector2 *)StkRefFrameP(0); var->disp_x = var->pos.x - pos->x; var->disp_y = var->pos.y - pos->y; } break; } return res; }