void draw_score() { glDisable(GL_TEXTURE_RECTANGLE_ARB); glBegin(GL_QUADS); glColor3f(0.0, 0.0, 0.0); glVertex2i( 0, 57); glVertex2i(90, 57); glVertex2i(90, 75); glVertex2i( 0, 75); glVertex2i( 0, -4); glVertex2i(90, -4); glVertex2i(90, 0); glVertex2i( 0, 0); glEnd(); glEnable(GL_TEXTURE_RECTANGLE_ARB); glColor3f(1.0, 1.0, 1.0); ST score_k_num = score_init((score - (score % 1000)) / 1000); ST score_c_num = score_init(((score % 1000) - (score % 100)) / 100); ST score_d_num = score_init(((score % 100) - (score % 10)) / 10); ST score_u_num = score_init((score % 10) - (score % 1)); Sprite::draw("alp_s", 9.0, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("alp_c", 11.1, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("alp_o", 13.2, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("alp_r", 15.3, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("alp_e", 17.4, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("num_" + score_k_num, 20.0, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("num_" + score_c_num, 22.1, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("num_" + score_d_num, 24.2, 60, 2.0, 2.0, 0.0f, true); Sprite::draw("num_" + score_u_num, 26.3, 60, 2.0, 2.0, 0.0f, true); }
int main(void) { t_game game; if (!(WIN_VALUE % 2) && initscr()) { glob = &game; init(&game); setwins(&game); score_init(&game); while ((game.size = menu(&game) + 3) > 5) put_score(&game); if (game.size > 3 && game.size < 6) { set_plateau(&game); if (start(&game)) put_msg(game.msgbar, " GAME BEGIN", 2); play(&game); refresh(); } ft_exit("ya", &game); } else ft_putendl("Game_2048: Initialisation failed."); return (0); }
void main(){ vdp_init(); port_init(); psg_init(); scene_type = SCENE_DEMO; while(373){ stage = 0; /* リセットしないとデモでぷんぷん丸が滑り続ける */ current_player = 0; while(373){ scene_type = SCENE_DEMO; title_init(); title_main(); if(scene_type == SCENE_LOAD) break; if(scene_type == SCENE_SOUND_TEST){ sound_test_init(); sound_test_main(); scene_type = SCENE_DEMO; }else{ intro_main(); } } intro_main(); score_init(); level = 0; /* cheat */ if(ports[0].button & BUTTON_UP) stage = 1; if(ports[0].button & BUTTON_LEFT) stage = 2; if(ports[0].button & BUTTON_RIGHT) stage = 3; if(ports[0].button & BUTTON_DOWN){ scene_type = SCENE_ALL_CLEAR; }else{ while(373){ game_init(); map_show(); game_set_bgm(); game_main(); game_swap_players(); psg_init(); /* game over when there is no players */ if((players_continue[0] == 0) && (players_continue[1] == 0)){ break; } } } if(scene_type == SCENE_ALL_CLEAR){ stage = 0; /* リセットしないとデモでぷんぷん丸が滑り続ける */ current_player = 0; intro_ending_main(); /* intro loop */ ending_main(); /* ending loop */ } gameover_main("- GAME OVER -"); } }
int main(int argc, char *argv[]) { if(interface_init() != 0 || sound_init() != 0) return -1; if(argc < 2) { printf("No input song directory\n"); return -1; } if(FOF_load(argv[1]) != 0) { printf("Unable to open FOF song from folder.\n"); return -1; } score_init(); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_JoystickOpen(0); controller_xplorer(&joystick); //Start game sound_play(); u32 start_ticks = SDL_GetTicks(); bool quit = false; while(!quit) { static SDL_Event event; while(SDL_PollEvent(&event)) { controller_event_t controller_event; switch(event.type) { case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_q) quit=true; break; case SDL_QUIT: quit=true; break; case SDL_JOYBUTTONDOWN: send_controller_event(joystick.convert_button(event.jbutton.button, BUTTON_DOWN)); break; case SDL_JOYBUTTONUP: send_controller_event(joystick.convert_button(event.jbutton.button, BUTTON_UP)); break; case SDL_JOYHATMOTION: send_controller_event(joystick.convert_hat(event.jhat.hat, event.jhat.value)); break; default: break; } } static unsigned int delta_ticks, ticks, cur_ticks; ticks = SDL_GetTicks(); cur_ticks = SDL_GetTicks(); delta_ticks = cur_ticks - ticks; ticks = cur_ticks; u32 game_ticks = ticks - start_ticks; interface_time(game_ticks); score_time(game_ticks); if(game_ticks > scene.length) break; SDL_Delay(5); interface_draw(); static unsigned int frames = 0; static int t0 = 0; ++frames; int t = SDL_GetTicks(); if (t - t0 >= 1000) { //printf("%d frames in %d milliseconds = %g frames/second\n", Frames, (t - t0), Frames * 1000.0f / (t-t0)); //char foo[256]; fps = frames * 1000.0f / (t-t0); //sprintf(foo, "%s, %g fps", argv[1], frames * 1000.0f / (t-t0)); //SDL_WM_SetCaption(foo, NULL); t0 = t; frames = 0; } } FOF_close(); SDL_JoystickClose(0); interface_quit(); sound_quit(); return 0; }
void fast(unsigned* out_feat, Param &x_out, Param &y_out, Param &score_out, Param in, const float thr, const float feature_ratio, const unsigned edge) { try { static std::once_flag compileFlags[DeviceManager::MAX_DEVICES]; static std::map<int, Program*> fastProgs; static std::map<int, Kernel*> lfKernel; static std::map<int, Kernel*> nmKernel; static std::map<int, Kernel*> gfKernel; int device = getActiveDeviceId(); std::call_once( compileFlags[device], [device] () { std::ostringstream options; options << " -D T=" << dtype_traits<T>::getName() << " -D ARC_LENGTH=" << arc_length << " -D NONMAX=" << static_cast<unsigned>(nonmax); if (std::is_same<T, double>::value || std::is_same<T, cdouble>::value) { options << " -D USE_DOUBLE"; } cl::Program prog; buildProgram(prog, fast_cl, fast_cl_len, options.str()); fastProgs[device] = new Program(prog); lfKernel[device] = new Kernel(*fastProgs[device], "locate_features"); nmKernel[device] = new Kernel(*fastProgs[device], "non_max_counts"); gfKernel[device] = new Kernel(*fastProgs[device], "get_features"); }); const unsigned max_feat = ceil(in.info.dims[0] * in.info.dims[1] * feature_ratio); // Matrix containing scores for detected features, scores are stored in the // same coordinates as features, dimensions should be equal to in. cl::Buffer *d_score = bufferAlloc(in.info.dims[0] * in.info.dims[1] * sizeof(float)); std::vector<float> score_init(in.info.dims[0] * in.info.dims[1], (float)0); getQueue().enqueueWriteBuffer(*d_score, CL_TRUE, 0, in.info.dims[0] * in.info.dims[1] * sizeof(float), &score_init[0]); cl::Buffer *d_flags = d_score; if (nonmax) { d_flags = bufferAlloc(in.info.dims[0] * in.info.dims[1] * sizeof(T)); } const int blk_x = divup(in.info.dims[0]-edge*2, FAST_THREADS_X); const int blk_y = divup(in.info.dims[1]-edge*2, FAST_THREADS_Y); // Locate features kernel sizes const NDRange local(FAST_THREADS_X, FAST_THREADS_Y); const NDRange global(blk_x * FAST_THREADS_X, blk_y * FAST_THREADS_Y); auto lfOp = make_kernel<Buffer, KParam, Buffer, const float, const unsigned, LocalSpaceArg> (*lfKernel[device]); lfOp(EnqueueArgs(getQueue(), global, local), *in.data, in.info, *d_score, thr, edge, cl::Local((FAST_THREADS_X + 6) * (FAST_THREADS_Y + 6) * sizeof(T))); CL_DEBUG_FINISH(getQueue()); const int blk_nonmax_x = divup(in.info.dims[0], 64); const int blk_nonmax_y = divup(in.info.dims[1], 64); // Nonmax kernel sizes const NDRange local_nonmax(FAST_THREADS_NONMAX_X, FAST_THREADS_NONMAX_Y); const NDRange global_nonmax(blk_nonmax_x * FAST_THREADS_NONMAX_X, blk_nonmax_y * FAST_THREADS_NONMAX_Y); unsigned count_init = 0; cl::Buffer *d_total = bufferAlloc(sizeof(unsigned)); getQueue().enqueueWriteBuffer(*d_total, CL_TRUE, 0, sizeof(unsigned), &count_init); //size_t *global_nonmax_dims = global_nonmax(); size_t blocks_sz = blk_nonmax_x * FAST_THREADS_NONMAX_X * blk_nonmax_y * FAST_THREADS_NONMAX_Y * sizeof(unsigned); cl::Buffer *d_counts = bufferAlloc(blocks_sz); cl::Buffer *d_offsets = bufferAlloc(blocks_sz); auto nmOp = make_kernel<Buffer, Buffer, Buffer, Buffer, Buffer, KParam, const unsigned> (*nmKernel[device]); nmOp(EnqueueArgs(getQueue(), global_nonmax, local_nonmax), *d_counts, *d_offsets, *d_total, *d_flags, *d_score, in.info, edge); CL_DEBUG_FINISH(getQueue()); unsigned total; getQueue().enqueueReadBuffer(*d_total, CL_TRUE, 0, sizeof(unsigned), &total); total = total < max_feat ? total : max_feat; if (total > 0) { size_t out_sz = total * sizeof(float); x_out.data = bufferAlloc(out_sz); y_out.data = bufferAlloc(out_sz); score_out.data = bufferAlloc(out_sz); auto gfOp = make_kernel<Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, KParam, const unsigned, const unsigned> (*gfKernel[device]); gfOp(EnqueueArgs(getQueue(), global_nonmax, local_nonmax), *x_out.data, *y_out.data, *score_out.data, *d_flags, *d_counts, *d_offsets, in.info, total, edge); CL_DEBUG_FINISH(getQueue()); } *out_feat = total; x_out.info.dims[0] = total; x_out.info.strides[0] = 1; y_out.info.dims[0] = total; y_out.info.strides[0] = 1; score_out.info.dims[0] = total; score_out.info.strides[0] = 1; for (int k = 1; k < 4; k++) { x_out.info.dims[k] = 1; x_out.info.strides[k] = total; y_out.info.dims[k] = 1; y_out.info.strides[k] = total; score_out.info.dims[k] = 1; score_out.info.strides[k] = total; } bufferFree(d_score); if (nonmax) bufferFree(d_flags); bufferFree(d_total); bufferFree(d_counts); bufferFree(d_offsets); } catch (cl::Error err) { CL_TO_AF_ERROR(err); throw; } }