示例#1
0
int main (void) {
  /* initialize the game. */
  setup_allegro (MODE, WIDTH, HEIGHT, 16);
  setup_bmps();
  setup_player();
  scrollx = 0;
  scrolly = 0;
  
  currentmap = (MAP*)malloc (sizeof (MAP));
  currentmap->initflag = 1;
  currentmap->idnumber = TCA_13;
    
  map_handler();

  while (!key[KEY_ESC]) {
    get_input();
    move_player();
    scroll_window();
    animate_player();
    map_event_handler();
    map_handler();
    draw_player();
    blit (scrollbmp, bufferbmp, scrollx, scrolly, 0, 0, WIDTH-1, HEIGHT-1);
    print_scroll_debug_messages();
    print_player_debug_messages();

    acquire_screen();
    blit (bufferbmp, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
    release_screen();

    rest (20);
  }
  destroy_bmps();
  allegro_exit();
  return 0;
}
示例#2
0
/**************************************************************************
  Main handler for key presses
**************************************************************************/
static Uint16 main_key_down_handler(SDL_keysym Key, void *pData)
{
    static struct widget *pWidget;
    if ((pWidget = find_next_widget_for_key(NULL, Key)) != NULL) {
        return widget_pressed_action(pWidget);
    } else {
        if (Key.sym == SDLK_TAB) {
            /* input */
            popup_input_line();
        } else {
            if (map_event_handler(Key)
                    && C_S_RUNNING == client_state()) {
                switch (Key.sym) {
                case SDLK_RETURN:
                case SDLK_KP_ENTER:
                    if (LSHIFT || RSHIFT) {
                        disable_focus_animation();
                        key_end_turn();
                    } else {
                        struct unit *pUnit;
                        struct city *pCity;
                        if (NULL != (pUnit = head_of_units_in_focus()) &&
                                (pCity = tile_city(unit_tile(pUnit))) != NULL &&
                                city_owner(pCity) == client.conn.playing) {
                            popup_city_dialog(pCity);
                        }
                    }
                    return ID_ERROR;

                case SDLK_F2:
                    units_report_dialog_popup(FALSE);
                    return ID_ERROR;

                case SDLK_F4:
                    city_report_dialog_popup(FALSE);
                    return ID_ERROR;

                case SDLK_F7:
                    send_report_request(REPORT_WONDERS_OF_THE_WORLD);
                    return ID_ERROR;

                case SDLK_F8:
                    send_report_request(REPORT_TOP_5_CITIES);
                    return ID_ERROR;

                case SDLK_F9:
                    if (meswin_dialog_is_open()) {
                        meswin_dialog_popdown();
                    } else {
                        meswin_dialog_popup(TRUE);
                    }
                    flush_dirty();
                    return ID_ERROR;

                case SDLK_F11:
                    send_report_request(REPORT_DEMOGRAPHIC);
                    return ID_ERROR;

                case SDLK_F12:
                    popup_spaceship_dialog(client.conn.playing);
                    return ID_ERROR;

                default:
                    return ID_ERROR;
                }
            }
        }
    }

    return ID_ERROR;
}