/** * If it fits in the highscore, prepare the new highscore * params: * score -- the new highscore */ void new_highscore_init(uint64_t new_score) { screen_clear(NULL, 0x00); int x; for(x = 0; x < SCORE_SIZE; ++x) { if(new_score > score[x].score) { break; // new highscore, and there is a spot } } if(x == SCORE_SIZE) { highscore_init(); return; // no new highscore } // Insert new highscore for(int y = SCORE_SIZE -1; y > x; --y) { score[y] = score[y -1]; } // prepare initial values of the name char *name = score[x].name; name[0] = 'A'; name[1] = 'A'; name[2] = 'A'; name[3] = '\0'; score[x].score = new_score; new_highscore.score = &score[x]; new_highscore.name_p = name; game_state = STATE_NEW_HIGHSCORE; }
void new_highscore_loop() { uint64_t ascii = readKeyCode(); screen_t scr_score; screen_init(&scr_score, 20, 10, 45, 2); // screen_clear(&scr_score, 0x00); if(ascii) { switch(ascii) { case KEY_CODE_AU: ++*new_highscore.name_p; break; case KEY_CODE_AD: --*new_highscore.name_p; break; case KEY_CODE_ENT: ++new_highscore.name_p; // Name entered if(!*new_highscore.name_p) { highscore_init(); return; } break; } } writef(&scr_score, "Your score: %c%u%c%n" "Your name: %c%s", 0x2F, new_highscore.score->score, 0x07, 0xC7, new_highscore.score->name ); }
static void init() { d_init_custom("svgestim", 800, 480, 0, "svgestim", NULL); platform=d_platform_get(); font.univox=d_font_load("univox.ttf", 32, 512, 512); font.vectroid=d_font_load("vectroid.ttf", 32, 512, 512); highscore_init(); menu_init(); game_init(); //pause_init(); map_init(); d_render_blend_enable(); }
void menu_loop() { uint64_t ascii = readKeyCode(); seed = (seed +1) % (1 << 31); if(ascii) { switch(ascii) { case KEY_CODE_1: game_init(); break; case KEY_CODE_2: highscore_init(); break; }; } }
static void init() { int i; DARNIT_INPUT_MAP map; d_init("pewpewtris", "pewpewtris", NULL); d_fs_mount_self(); d_fs_mount("music.ldi"); d_fs_mount("sounds.ldi"); config_init(); ppt.ui.offset_x = 288; ppt.ui.offset_y = 0; for (i = 0; i < 180; ppt.tile_lookup[i++] = -1); ppt.block = d_render_tilesheet_load("res/block.png", 24, 24, DARNIT_PFORMAT_RGB5A1); ppt.tile = d_render_tile_new(10 * 18, ppt.block); ppt.bbox = d_bbox_new(180); d_bbox_set_indexkey(ppt.bbox); ppt.tm = d_tilemap_new(0xFFF, ppt.block, 0xFFF, 10, 18); ppt.request_new = 0; ppt.font = d_font_load("res/font.ttf", 28, 256, 256); ui_init(); bullet_init(30); highscore_init(); state_init(); music_init(); ppt.ui.play_background = d_map_load("res/playfield_background.ldmz"); ppt.ui.menu_background = d_map_load("res/mainmenu_background.ldmz"); ppt.ui.highscore_background = d_map_load("res/highscore_background.ldmz"); /* Re-map B to space */ if (!(d_platform_get().platform & DARNIT_PLATFORM_PANDORA)) { map = d_keymapping_get(); map.b = TPW_KEY_SPACE; d_keymapping_set(map); } block_particle_init(); /* FIXME: Remove */ ppt.fps = d_text_surface_new(ppt.font, 6, 1000, 0, 0); }
void menu_func_highscore_reset(){ highscore_init(); }