/** * @brief Shows the player's active missions. * * @param parent Unused. * @param str Unused. */ static void info_openMissions( unsigned int wid ) { int w, h; /* Get the dimensions. */ window_dimWindow( wid, &w, &h ); /* buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeMissions", "Close", info_close ); window_addButton( wid, -20, 40 + BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", "Abort", mission_menu_abort ); /* text */ window_addText( wid, 300+40, -60, 200, 40, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, 300+100, -60, 140, 40, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); window_addText( wid, 300+40, -100, w - (300+40+40), h - BUTTON_HEIGHT - 120, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* Put a map. */ map_show( wid, 20, 20, 300, 260, 0.75 ); /* list */ mission_menu_genList(wid ,1); }
/** * @brief Shows the player's active missions. * * @param parent Unused. * @param str Unused. */ static void info_missions_menu( unsigned int parent, char* str ) { (void) str; unsigned int wid; /* create the window */ wid = window_create( "Missions", -1, -1, MISSIONS_WIDTH, MISSIONS_HEIGHT ); window_setParent( wid, parent ); /* buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeMissions", "Back", window_close ); window_addButton( wid, -20, 40 + BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", "Abort", mission_menu_abort ); /* text */ window_addText( wid, 300+40, -60, 200, 40, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, 300+100, -60, 140, 40, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); window_addText( wid, 300+40, -100, 200, MISSIONS_HEIGHT - BUTTON_WIDTH - 120, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* Put a map. */ map_show( wid, 20, 20, 300, 260, 0.75 ); /* list */ mission_menu_genList(wid ,1); }
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 -"); } }
/** * @brief Opens the mission computer window. */ static void misn_open( unsigned int wid ) { int w, h; int y; /* Mark as generated. */ land_tabGenerate(LAND_WINDOW_MISSION); /* Get window dimensions. */ window_dimWindow( wid, &w, &h ); /* Set window functions. */ window_onClose( wid, misn_close ); /* buttons */ window_addButtonKey( wid, -20, 20, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnCloseMission", "Take Off", land_buttonTakeoff, SDLK_t ); window_addButtonKey( wid, -20, 40+LAND_BUTTON_HEIGHT, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnAcceptMission", "Accept Mission", misn_accept, SDLK_a ); /* text */ y = -60; window_addText( wid, w/2 + 10, y, w/2 - 30, 40, 0, "txtSDate", NULL, &cDConsole, "Date:\n" "Free Space:"); window_addText( wid, w/2 + 110, y, w/2 - 90, 40, 0, "txtDate", NULL, &cBlack, NULL ); y -= 2 * gl_defFont.h + 50; window_addText( wid, w/2 + 10, y, w/2 - 30, 20, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, w/2 + 70, y, w/2 - 90, 20, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); y -= 20; window_addText( wid, w/2 + 10, y, w/2 - 30, h/2-90, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* map */ map_show( wid, 20, 20, w/2 - 30, h/2 - 35, 0.75 ); misn_genList(wid, 1); /* Set default keyboard focuse to the list */ window_setFocus( wid , "lstMission" ); }
void distorsion_out(Rock_Scroll_Map *map, Rock_Screen *screen_data) { uint8_t distorsion; bool blit_status; blit_status = screen_data->blit_surface; screen_data->blit_surface = true; map_show(screen_data, map, false); for (distorsion = 1; distorsion <= DISTORSION_LEVEL; distorsion ++) { screen_pixel_distorsion(screen_data->buffer_surface, distorsion); screen_dump_buffer(screen_data, map->view_width, map->view_height); } screen_data->blit_surface = blit_status; }
/** * @brief Opens the mission computer window. */ static void misn_open( unsigned int wid ) { int w, h; int y; /* Get window dimensions. */ window_dimWindow( wid, &w, &h ); /* Set window functions. */ window_onClose( wid, misn_close ); /* buttons */ window_addButton( wid, -20, 20, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnCloseMission", "Takeoff", land_buttonTakeoff ); window_addButton( wid, -20, 40+LAND_BUTTON_HEIGHT, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnAcceptMission", "Accept Mission", misn_accept ); /* text */ y = -60; window_addText( wid, w/2 + 10, y, w/2 - 30, 40, 0, "txtSDate", NULL, &cDConsole, "Date:\n" "Free Space:"); window_addText( wid, w/2 + 110, y, w/2 - 90, 40, 0, "txtDate", NULL, &cBlack, NULL ); y -= 2 * gl_defFont.h + 50; window_addText( wid, w/2 + 10, y, w/2 - 30, 20, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, w/2 + 70, y, w/2 - 90, 20, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); y -= 20; window_addText( wid, w/2 + 10, y, w/2 - 30, h/2-90, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* map */ map_show( wid, 20, 20, w/2 - 30, h/2 - 35, 0.75 ); misn_genList(wid, 1); }
void distorsion_in(Rock_Scroll_Map *map, Rock_Screen *screen_data) { SDL_Surface *deform; SDL_Surface *buffer_backup; uint8_t distorsion; bool blit_status; deform = screen_make_surface(SCREEN_WIDTH, SCREEN_HEIGHT); // para el efecto de transición blit_status = screen_data->blit_surface; screen_data->blit_surface = true; map_show(screen_data, map, false); buffer_backup = screen_data->buffer_surface; screen_data->buffer_surface = deform; for (distorsion = DISTORSION_LEVEL; distorsion > 0; distorsion --) { SDL_BlitSurface(buffer_backup, NULL, deform, NULL); screen_pixel_distorsion(deform, distorsion); screen_dump_buffer(screen_data, map->view_width, map->view_height); } screen_data->buffer_surface = buffer_backup; screen_data->blit_surface = blit_status; SDL_FreeSurface(deform); }
/** * @brief Opens the map window. */ void map_open (void) { unsigned int wid; StarSystem *cur; int w, h, x, y, rw; /* Not under manual control. */ if (pilot_isFlag( player.p, PILOT_MANUAL_CONTROL )) return; /* Destroy window if exists. */ wid = window_get(MAP_WDWNAME); if (wid > 0) { window_destroy( wid ); return; } /* set position to focus on current system */ map_xpos = cur_system->pos.x; map_ypos = cur_system->pos.y; /* mark systems as needed */ mission_sysMark(); /* Attempt to select current map if none is selected */ if (map_selected == -1) map_selectCur(); /* get the selected system. */ cur = system_getIndex( map_selected ); /* Set up window size. */ w = MAX(600, SCREEN_W - 100); h = MAX(540, SCREEN_H - 100); /* create the window. */ wid = window_create( MAP_WDWNAME, -1, -1, w, h ); window_setCancel( wid, window_close ); window_handleKeys( wid, map_keyHandler ); /* * SIDE TEXT * * $System * * Faction: * $Faction (or Multiple) * * Status: * $Status * * Planets: * $Planet1, $Planet2, ... * * Services: * $Services * * ... * [Autonav] * [ Find ] * [ Close ] */ x = -70; /* Right column X offset. */ y = -20; rw = ABS(x) + 60; /* Right column indented width maximum. */ /* System Name */ window_addText( wid, -90 + 80, y, 160, 20, 1, "txtSysname", &gl_defFont, &cDConsole, cur->name ); y -= 10; /* Faction image */ window_addImage( wid, -90 + 32, y - 32, 0, 0, "imgFaction", NULL, 0 ); y -= 64 + 10; /* Faction */ window_addText( wid, x, y, 90, 20, 0, "txtSFaction", &gl_smallFont, &cDConsole, "Faction:" ); window_addText( wid, x + 50, y-gl_smallFont.h-5, rw, 100, 0, "txtFaction", &gl_smallFont, &cBlack, NULL ); y -= 2 * gl_smallFont.h + 5 + 15; /* Standing */ window_addText( wid, x, y, 90, 20, 0, "txtSStanding", &gl_smallFont, &cDConsole, "Standing:" ); window_addText( wid, x + 50, y-gl_smallFont.h-5, rw, 100, 0, "txtStanding", &gl_smallFont, &cBlack, NULL ); y -= 2 * gl_smallFont.h + 5 + 15; /* Presence. */ window_addText( wid, x, y, 90, 20, 0, "txtSPresence", &gl_smallFont, &cDConsole, "Presence:" ); window_addText( wid, x + 50, y-gl_smallFont.h-5, rw, 100, 0, "txtPresence", &gl_smallFont, &cBlack, NULL ); y -= 2 * gl_smallFont.h + 5 + 15; /* Planets */ window_addText( wid, x, y, 90, 20, 0, "txtSPlanets", &gl_smallFont, &cDConsole, "Planets:" ); window_addText( wid, x + 50, y-gl_smallFont.h-5, rw, 150, 0, "txtPlanets", &gl_smallFont, &cBlack, NULL ); y -= 2 * gl_smallFont.h + 5 + 15; /* Services */ window_addText( wid, x, y, 90, 20, 0, "txtSServices", &gl_smallFont, &cDConsole, "Services:" ); window_addText( wid, x + 50, y-gl_smallFont.h-5, rw, 100, 0, "txtServices", &gl_smallFont, &cBlack, NULL ); y -= 2 * gl_smallFont.h + 5 + 15; /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", window_close ); /* Find button */ window_addButton( wid, -20 - (BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnFind", "Find", map_inputFind ); /* Autonav button */ window_addButton( wid, -20 - 2*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnAutonav", "Autonav", player_autonavStartWindow ); /* * Bottom stuff * * [+] [-] Nebula, Interference */ /* Zoom buttons */ window_addButton( wid, 40, 20, 30, 30, "btnZoomIn", "+", map_buttonZoom ); window_addButton( wid, 80, 20, 30, 30, "btnZoomOut", "-", map_buttonZoom ); /* Situation text */ window_addText( wid, 140, 10, w - 80 - 30 - 30, 30, 0, "txtSystemStatus", &gl_smallFont, &cBlack, NULL ); /* * The map itself. */ map_show( wid, 20, -40, w-200, h-100, 1. ); /* Reset zoom. */ map_update( wid ); /* * Disable Autonav button if player lacks fuel. */ if ((player.p->fuel < HYPERSPACE_FUEL) || pilot_isFlag( player.p, PILOT_NOJUMP)) window_disableButton( wid, "btnAutonav" ); }
/** * @brief Opens the map window. */ void map_open (void) { unsigned int wid; StarSystem *cur; int w,h; /* Destroy window if exists. */ wid = window_get(MAP_WDWNAME); if (wid > 0) { window_destroy( wid ); return; } /* set position to focus on current system */ map_xpos = cur_system->pos.x; map_ypos = cur_system->pos.y; /* mark systems as needed */ mission_sysMark(); /* Attempt to select current map if none is selected */ if (map_selected == -1) map_selectCur(); /* get the selected system. */ cur = system_getIndex( map_selected ); /* Set up window size. */ w = MAX(600, SCREEN_W - 100); h = MAX(540, SCREEN_H - 100); /* create the window. */ wid = window_create( MAP_WDWNAME, -1, -1, w, h ); window_setCancel( wid, window_close ); /* * SIDE TEXT * * $System * * Faction: * $Faction (or Multiple) * * Status: * $Status * * Planets: * $Planet1, $Planet2, ... * * Services: * $Services * * ... * * [Close] */ /* System Name */ window_addText( wid, -20, -20, 100, 20, 1, "txtSysname", &gl_defFont, &cDConsole, cur->name ); /* Faction */ window_addImage( wid, -20-64, -60-64, "imgFaction", NULL, 0 ); window_addText( wid, -20, -60, 90, 20, 0, "txtSFaction", &gl_smallFont, &cDConsole, "Faction:" ); window_addText( wid, -20, -60-gl_smallFont.h-5, 80, 100, 0, "txtFaction", &gl_smallFont, &cBlack, NULL ); /* Standing */ window_addText( wid, -20, -100, 90, 20, 0, "txtSStanding", &gl_smallFont, &cDConsole, "Standing:" ); window_addText( wid, -20, -100-gl_smallFont.h-5, 80, 100, 0, "txtStanding", &gl_smallFont, &cBlack, NULL ); /* Security. */ window_addText( wid, -20, -140, 90, 20, 0, "txtSSecurity", &gl_smallFont, &cDConsole, "Security:" ); window_addText( wid, -20, -140-gl_smallFont.h-5, 80, 100, 0, "txtSecurity", &gl_smallFont, &cBlack, NULL ); /* Planets */ window_addText( wid, -20, -180, 90, 20, 0, "txtSPlanets", &gl_smallFont, &cDConsole, "Planets:" ); window_addText( wid, -20, -180-gl_smallFont.h-5, 80, 100, 0, "txtPlanets", &gl_smallFont, &cBlack, NULL ); /* Services */ window_addText( wid, -20, -220, 90, 20, 0, "txtSServices", &gl_smallFont, &cDConsole, "Services:" ); window_addText( wid, -20, -220-gl_smallFont.h-5, 80, 100, 0, "txtServices", &gl_smallFont, &cBlack, NULL ); /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", window_close ); /* * Bottom stuff * * [+] [-] Nebula, Asteroids, Interference */ /* Zoom buttons */ window_addButton( wid, 40, 20, 30, 30, "btnZoomIn", "+", map_buttonZoom ); window_addButton( wid, 80, 20, 30, 30, "btnZoomOut", "-", map_buttonZoom ); /* Situation text */ window_addText( wid, 140, 10, w - 80 - 30 - 30, 30, 0, "txtSystemStatus", &gl_smallFont, &cBlack, NULL ); /* * The map itself. */ map_show( wid, 20, -40, w-150, h-100, 1. ); /* Reset zoom. */ map_update( wid ); }
static PRESULT map_display_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2) { PRESULT ret = PROC_PASS; //UINT8 focusID = OSD_GetFocusID( pObj); UINT8 back_saved; OSD_RECT rect = {PREVIEW_L, PREVIEW_T, PREVIEW_W, PREVIEW_H}; struct YCbCrColor bgcolor; switch(event) { case EVN_PRE_OPEN: vdec_stop((struct vdec_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_DECV), 0, 0); OSD_ClearScreen();//-a by wangyang 2011-09-20 win_media_player_init_ex(mp_apcallback, 1); bMapDownloading = FALSE; zoom_level = 12; //api_set_preview_vpo_color(TRUE); bgcolor.uY = 16; bgcolor.uCb = 128; bgcolor.uCr = 128; api_set_vpo_bgcolor(&bgcolor); image_restore_vpo_rect();//TODO #if 0 vpo_aspect_mode((struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS,0), TV_4_3, NORMAL_SCALE); #ifdef DUAL_VIDEO_OUTPUT vpo_aspect_mode((struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS,1), TV_4_3, NORMAL_SCALE); #endif osal_task_sleep(30); if(is_cur_decoder_avc()) { h264_decoder_select(0, hde_get_mode() == VIEW_MODE_PREVIEW); } #endif // system_state = SYS_STATE_USB_MP; //osal_cache_flush_all(); image_abort(); //map_show(rect); break; case EVN_POST_OPEN: //wincom_open_subtitle(pObj,RS_MAP,0); wincom_open_help_trans(pObj, map_display_helpinfo, 2); map_show(rect, param2); break; case EVN_POST_CLOSE: map_download_abort(s_mapdisp_dl_handle); s_mapdisp_dl_handle = 0; media_player_release_ex(); #ifdef LOGO_IN_RAM api_show_Test_logo_2(internet_osd4,get_logo_h_file_size(6)); #else api_show_Test_logo( LOGO_ID_TYPE|0X0200|7); #endif wincom_close_subtitle(); break; case EVN_MSG_GOT: if (param1 == CTRL_MSG_SUBTYPE_STATUS_DOWNLOAD_FINISH) { bMapDownloading = FALSE; map_download_abort(s_mapdisp_dl_handle); s_mapdisp_dl_handle = 0; if ((int)param2 >= 0) { win_compopup_smsg_restoreback(); map_show(rect, param2); } } break; default: break; } return ret; }
int main(int n, char *cmd[]) { int c, m, i; int dx, dy; telnet_init(); if (map_init() == 0) printf("map.dat error\n"); if (n >= 2) { char buf[40]; strsncpy(userid, cmd[1], sizeof (userid)); readuservalue(userid, "worker.laststage", buf, sizeof (buf)); lastMaxStage = atoi(buf); if (lastMaxStage >= map_total) lastMaxStage = map_total - 1; stage = lastMaxStage; } if (n >= 3) strsncpy(fromhost, cmd[2], sizeof (fromhost)); if (stage == 0) { clear(); printf("»¶Ó¹âÁÙ[1;32mÍÆÏä×Ó[mÓÎÏ·¡£\r\n"); printf ("¹æÔòºÜ¼òµ¥£¬Ö»Ðè°ÑËùÓеÄ'¡õ'¶¼ÍƵ½'¡¤'ÉÏÃæÈ¥(»á±ä³ÉÂÌÉ«)¾Í¹ý¹ØÁË¡£\r\n"); printf("µ«ÍæÆðÀ´ÄѶȿÉÊÇÏ൱´óµÄ£¬²»ÒªÇáÊÓม£\r\n"); pressanykey(); goto start; } win_showrec(); clear(); printf("ÇëÓ÷½Ïò¼üÑ¡¹Ø, »Ø³µ¼üÈ·ÈÏ: %d ", stage); move(0, 14); while (1) { c = inkey(); if ((c == KEY_LEFT || c == KEY_UP) && stage > 0) stage--; if ((c == KEY_RIGHT || c == KEY_DOWN) && stage < lastMaxStage) stage++; if (c == 10 || c == 13) break; if (c == 3 || c == 4 || c == 32) quit(); move(0, 14); printf("%d ", stage); move(0, 14); } start: if (stage < 0 || stage >= map_total) stage = 0; clear(); printf("ÍÆÏä×Ó: µÚ [1;32m%d[m ¹Ø:\033[m", stage); move(20, 0); refresh(); sleep(1); start2: for (n = 0; n < 20; n++) for (m = 0; m < 30; m++) map_now[n][m] = map_data[stage][n][m]; if (!find_y_x(&now_y, &now_x)) printf("stage error\n"); map_show(); bzero(&my_history, sizeof (my_history)); while (1) { c = inkey(); if (my_history.max >= 1999) { move(21, 0); printf("ÄãÓÃÁË2000²½»¹Ã»Óйý¹Ø! GAME OVER."); quit(); } dx = 0; dy = 0; if (c == 8 && my_history.max > 0) { my_history.max--; i = my_history.max; map_move(my_history.y1[i], my_history.x1[i], my_history.y0[i], my_history.x0[i]); find_y_x(&now_y, &now_x); move(now_y, now_x); continue; } if (c == ' ') quit(); if (c == '') map_show(); if (c == 9) goto start2; if (c == KEY_UP) dy = -1; if (c == KEY_DOWN) dy = 1; if (c == KEY_LEFT) dx = -1; if (c == KEY_RIGHT) dx = 1; if (dx == 0 && dy == 0) continue; if (map_now[now_y + dy][now_x + dx] & 4) if (map_now[now_y + dy * 2][now_x + dx * 2] < 2) { map_move(now_y + dy, now_x + dx, now_y + dy * 2, now_x + dx * 2); i = my_history.max; my_history.y0[i] = now_y + dy; my_history.x0[i] = now_x + dx; my_history.y1[i] = now_y + dy * 2; my_history.x1[i] = now_x + dx * 2; my_history.max++; } if (map_now[now_y + dy][now_x + dx] < 2) { map_move(now_y, now_x, now_y + dy, now_x + dx); i = my_history.max; my_history.y0[i] = now_y; my_history.x0[i] = now_x; my_history.y1[i] = now_y + dy; my_history.x1[i] = now_x + dx; my_history.max++; } if (check_if_win()) break; find_y_x(&now_y, &now_x); move(now_y, now_x); } move(19, 0); printf("×£ºØÄã, Äã³É¹¦ÁË£¡"); steps = my_history.max; win_checkrec(); stage++; if (stage > lastMaxStage) { lastMaxStage = stage; if (strcmp(userid, "null.")) { char buf[30]; sprintf(buf, "%d", lastMaxStage); saveuservalue(userid, "worker.laststage", buf); } } goto start; }
int main(int argc, char* args[]) { if (init() == FALSE) { return 1; } if (load_files() == FALSE) { return 1; } message = TTF_RenderText_Solid(font, window_footer_str, font_color); if (message == NULL) { return 1; } Uint32 frameStart = 0; int rightMouseButtonDown = FALSE; int quit = FALSE; while (quit == FALSE) { frameStart = SDL_GetTicks(); while (SDL_PollEvent(&event)) { if (event.type == SDL_MOUSEBUTTONDOWN) { if (event.button.button == SDL_BUTTON_RIGHT) rightMouseButtonDown = TRUE; else if (event.button.button == SDL_BUTTON_LEFT) map_select_tile(event.button.x, event.button.y); } if (event.type == SDL_MOUSEBUTTONUP) { if (event.button.button == SDL_BUTTON_RIGHT) { rightMouseButtonDown = FALSE; map_move_reset(); } } if (event.type == SDL_MOUSEMOTION) { if (rightMouseButtonDown == TRUE) { map_move(event.button.x, event.button.y); } } if (event.type == SDL_KEYDOWN) { switch (event.key.keysym.sym) { case SDLK_g: map_toggle_grid(); break; case SDLK_PLUS: map_resize(1); break; case SDLK_MINUS: map_resize(-1); break; case SDLK_l: map_load(); break; default: ; } } if (event.type == SDL_QUIT) { quit = TRUE; } } SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0, 0, 0)); map_show(); apply_surface( screen_width - message->w, screen_height - message->h, message, screen ); if (SDL_Flip(screen) == -1) { return 1; } if ((SDL_GetTicks() - frameStart) < (1000 / FPS)) { SDL_Delay((1000 / FPS) - (SDL_GetTicks() - frameStart)); } } clean_up(); return 0; }
static PRESULT map_display_callback(POBJECT_HEAD pObj, VEVENT event, UINT32 param1, UINT32 param2) { PRESULT ret = PROC_PASS; UINT8 back_saved; OSD_RECT rect = {PREVIEW_L, PREVIEW_T, PREVIEW_W, PREVIEW_H}; struct YCbCrColor bgcolor; switch(event) { case EVN_PRE_OPEN: OSD_ClearScreen();//-a by wangyang 2011-09-20 win_media_player_init_ex(mp_apcallback, 1); bMapDownloading = FALSE; zoom_level = 12; //api_set_preview_vpo_color(TRUE); bgcolor.uY = 16; bgcolor.uCb = 128; bgcolor.uCr = 128; api_set_vpo_bgcolor(&bgcolor); image_restore_vpo_rect();//TODO #if 0 vpo_aspect_mode((struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS,0), TV_4_3, NORMAL_SCALE); #ifdef DUAL_VIDEO_OUTPUT vpo_aspect_mode((struct vpo_device *)dev_get_by_id(HLD_DEV_TYPE_DIS,1), TV_4_3, NORMAL_SCALE); #endif osal_task_sleep(30); if(is_cur_decoder_avc()) { h264_decoder_select(0, hde_get_mode() == VIEW_MODE_PREVIEW); } #endif // system_state = SYS_STATE_USB_MP; //osal_cache_flush_all(); image_abort(); //map_show(rect); break; case EVN_POST_OPEN: //wincom_open_subtitle(pObj,RS_MAP,0); wincom_open_help_OK_list_small(pObj, map_display_helpinfo, 2); //wincom_open_help(pObj, map_display_helpinfo, 2); libc_printf("map_dl_param2 = %d\n", param2); map_show(rect, param2); break; case EVN_PRE_CLOSE://-a by wangyang 2011-09-20 map_download_abort(s_mapdisp_dl_handle); s_mapdisp_dl_handle = 0; media_player_release_ex(); imagedec_ioctl(1, IMAGEDEC_IO_CMD_CLEAN_FRM, TRUE); //when quit win_slide, clean 2 frm buffer image_abort(); break; case EVN_POST_CLOSE: wincom_close_subtitle(); image_restore_vpo_rect();//-a by wangyang 2011-09-20 break; case EVN_MSG_GOT: if (param1 == CTRL_MSG_SUBTYPE_STATUS_DOWNLOAD_FINISH) { bMapDownloading = FALSE; map_download_abort(s_mapdisp_dl_handle); s_mapdisp_dl_handle = 0; if ((int)param2 >= 0) { win_compopup_smsg_restoreback(); map_show(rect, param2); } } break; default: break; } return ret; }
int8_t rockpush_menu(Rock_Screen *screen_data) { SDL_Event event; SDL_Surface *menu; SDL_Surface *sprite_textures; SDL_Texture *font_surface; Rock_Sprite *rocco; Rock_Scroll_Map map; Mix_Music *music; TTF_Font *menu_font; bool done = false; Uint32 init_ms; char font_path[128]; int16_t offset; int8_t orientation, total_options, option; Sint32 event_option; SDL_Joystick *joystick = NULL; Sint16 joy_event = 0, joyy = 0; if (SDL_NumJoysticks() >= 1) { joystick = SDL_JoystickOpen(0); SDL_JoystickEventState(SDL_ENABLE); } if ((menu_font = TTF_OpenFont(MENU_TTF, 34)) == NULL) { printf("Error %s\n", TTF_GetError()); exit(EXIT_FAILURE); } gfx_check_gpu(screen_data->screen); if (gfx_get_low_gpu()) sprintf(font_path, "%s", TINY_FONT_PATH); else sprintf(font_path, "%s", FONT_PATH); if ((font_surface = IMG_LoadTexture(screen_data->screen, font_path)) == NULL) { printf("La fuente bitmap no encontrada %s\n", SDL_GetError()); exit(EXIT_FAILURE); } menu = screen_make_surface(SCREEN_WIDTH, SCREEN_HEIGHT); sprite_textures = screen_make_surface(screen_data->sprites_surface->w, screen_data->sprites_surface->h); map.view_height = MINI_HEIGHT * TILE_SIZE; map.view_width = MINI_WIDTH * TILE_SIZE; map.scroll_shift = SCROLL_SHIFT / 2; map.diamonds = 0; map.level = (rand() % 15); map.points = 0; map.lives = INIT_ROCCO_LIVE; map.update_score = false; map.refresh_rocco = false; rocco = set_level_rocco(&map); rocco->active = false; map.objects_map[rocco->x_map][rocco->y_map] = EMPTY; map.rockmap[rocco->x_map][rocco->y_map] = GRASS; sprites_set_tiles_textures(); //Se hace una copia de las texturas cargadas para convertirlas a B/N SDL_BlitSurface(screen_data->sprites_surface, NULL, sprite_textures, NULL); screen_greyscale(screen_data->sprites_surface); orientation = (rand() % 4) + 2; option = offset = 0; total_options = menu_options(option, map.view_width, menu, menu_font); gfx_init(); screen_data->blit_surface = true; SDL_SetRenderDrawColor(screen_data->screen, 0, 0, 0, 255); SDL_RenderClear(screen_data->screen); if (sfx_get_active()) { music = Mix_LoadMUS(MENU_MUSIC); Mix_PlayMusic(music, -1); } while (!done) { init_ms = SDL_GetTicks(); map_show(screen_data, &map, false); map_move(&map, orientation); SDL_BlitSurface(menu, NULL, screen_data->buffer_surface, NULL); //sprites_update(&map); screen_dump_buffer(screen_data, map.view_width, map.view_height); offset ++; if (offset > 240) { orientation = (rand() % 4) + 2; offset = 0; } /* Desplazamiento de texto */ gfx_text_move(screen_data->screen, font_surface); while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { option = 0; done = true; } if (SDL_JoystickGetAttached(joystick)) joy_event = SDL_JoystickGetAxis(joystick, 0) | SDL_JoystickGetAxis(joystick, 1); if (event.type == SDL_KEYDOWN || event.type == SDL_JOYBUTTONDOWN || joy_event) { event_option = event.key.keysym.sym; if (SDL_JoystickGetAttached(joystick)) { joyy = SDL_JoystickGetAxis(joystick, 1); joy_event = SDL_JoystickGetAxis(joystick, 0) | joyy; if (SDL_JoystickGetButton(joystick, 0)) event_option = SDLK_ESCAPE; if (SDL_JoystickGetButton(joystick, 1)) event_option = SDLK_RETURN; if (joyy < -10) event_option = SDLK_UP; if (joyy > 10) event_option = SDLK_DOWN; } switch (event_option) { case SDLK_UP: if (option > 0) option --; break; case SDLK_DOWN: if (option < total_options) option ++; break; case SDLK_ESCAPE: option = -1; case SDLK_RETURN: done = true; option ++; break; } menu_options(option, map.view_width, menu, menu_font); } } while ((SDL_GetTicks() - init_ms) < TICK_RATE); } //Restauramos la copia SDL_BlitSurface(sprite_textures, NULL, screen_data->sprites_surface, NULL); SDL_SetRenderDrawColor(screen_data->screen, 0, 0, 0, 255); SDL_RenderClear(screen_data->screen); screen_data->blit_surface = false; SDL_FreeSurface(sprite_textures); SDL_DestroyTexture(font_surface); SDL_FreeSurface(menu); TTF_CloseFont(menu_font); if (SDL_JoystickGetAttached(joystick)) SDL_JoystickClose(joystick); if (sfx_get_active()) { Mix_FadeOutMusic(SFX_FADE_OUT); while (Mix_PlayingMusic()) ; Mix_FreeMusic(music); } return option; }
void rockpush_init_game(Rock_Screen *screen_data) { SDL_Event event; Rock_Sprite *object_rocco; Rock_Scroll_Map map; int16_t current_level; bool done = false; Uint32 init_ms; Uint32 move_ms; SDL_Joystick *joystick = NULL; Sint16 joy_event = 0; if (SDL_NumJoysticks() >= 1) { joystick = SDL_JoystickOpen(0); SDL_JoystickEventState(SDL_ENABLE); } map.view_height = VIEW_HEIGHT; map.view_width = VIEW_WIDTH; map.scroll_shift = SCROLL_SHIFT; map.diamonds = 0; map.level = 0; map.points = 0; map.lives = INIT_ROCCO_LIVE; map.update_score = false; map.refresh_rocco = false; map.rocco_death = false; current_level = map.level; screen_show_background(screen_data->screen); sprites_set_tiles_textures(); object_rocco = set_level_rocco(&map); set_score(&map, screen_data); if (sfx_get_active()) { sfx_set_level_music(&map); Mix_PlayMusic(map.level_music, -1); } SDL_GL_SetSwapInterval(0); distorsion_in(&map, screen_data); while (!done) { init_ms = SDL_GetTicks(); while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE) done = true; if (SDL_JoystickGetAttached(joystick)) joy_event = SDL_JoystickGetAxis(joystick, 0) | SDL_JoystickGetAxis(joystick, 1); while (event.type == SDL_KEYDOWN || event.type == SDL_JOYBUTTONDOWN || joy_event) { move_ms = SDL_GetTicks(); if (SDL_JoystickGetAttached(joystick)) { joy_event = SDL_JoystickGetAxis(joystick, 0) | SDL_JoystickGetAxis(joystick, 1); if (SDL_JoystickGetButton(joystick, 0)) done = true; if (SDL_JoystickGetButton(joystick, 1)) map.rocco_death = true; } /*if (event.key.keysym.sym == SDLK_n) map.level ++;*/ // Reinicia el nivel if (event.key.keysym.sym == SDLK_r) map.rocco_death = true; set_position(object_rocco, event, joystick); sprites_update(&map); map_show(screen_data, &map, false); screen_dump_buffer(screen_data, map.view_width, map.view_height); SDL_PollEvent(&event); if (map.update_score) { set_score(&map, screen_data); map.update_score = false; } if (map.level > current_level && map.level < TOTAL_LEVELS) { sfx_play(SFX_LEVEL); if (sfx_get_active()) { Mix_HaltMusic(); Mix_FreeMusic(map.level_music); sfx_set_level_music(&map); Mix_PlayMusic(map.level_music, -1); } distorsion_out(&map, screen_data); free(sprites); object_rocco = set_level_rocco(&map); current_level = map.level; set_score(&map, screen_data); distorsion_in(&map, screen_data); } else if (map.level >= TOTAL_LEVELS) done = true; if (map.refresh_rocco) { object_rocco = sprite_get_object(map.rocco_index); map.refresh_rocco = false; } while ((SDL_GetTicks() - move_ms) < TICK_RATE); } if (event.type == SDL_KEYUP || !joy_event) { rocco_set_action(object_rocco, WAIT_LEFT); sprites_push_off(&map); } } sprites_update(&map); map_show(screen_data, &map, false); screen_dump_buffer(screen_data, map.view_width, map.view_height); if (map.update_score) { set_score(&map, screen_data); map.update_score = false; } // Si se añaden más elementos al mapa (realloc), hay que reasignar el puntero del personaje if (map.refresh_rocco) { object_rocco = sprite_get_object(map.rocco_index); map.refresh_rocco = false; } if (map.rocco_death) { map.lives --; if (map.lives <= 0) done = true; else { free(sprites); object_rocco = set_level_rocco(&map); current_level = map.level; set_score(&map, screen_data); map.rocco_death = false; } } while ((SDL_GetTicks() - init_ms) < TICK_RATE); } if (sfx_get_active()) { Mix_HaltMusic(); Mix_FreeMusic(map.level_music); } distorsion_out(&map, screen_data); SDL_GL_SetSwapInterval(0); if (SDL_JoystickGetAttached(joystick)) SDL_JoystickClose(joystick); }