Ejemplo n.º 1
0
/**
 * Main loop of the Powermanga game
 */
void
main_loop (void)
{
  Sint32 pause_delay = 0;
  Sint32 frame_diff = 0;
  do
    {
      loops_counter++;
      if (!power_conf->nosync)
        {
          frame_diff = get_time_difference ();
          if (movie_playing_switch != MOVIE_NOT_PLAYED)
            {
              pause_delay =
                wait_next_frame (MOVIE_FRAME_RATE - frame_diff + pause_delay,
                                 MOVIE_FRAME_RATE);
            }
          else
            {
              pause_delay =
                wait_next_frame (GAME_FRAME_RATE - frame_diff + pause_delay,
                                 GAME_FRAME_RATE);
            }
        }
      /* handle Powermanga game */
      if (!update_frame ())
        {
          quit_game = TRUE;
        }
      /* handle keyboard and joystick events */
      display_handle_events ();

      /* update our main window */
      display_update_window ();

#ifdef USE_SDLMIXER
      /* play music and sounds */
      sound_handle ();
#endif
    }
  while (!quit_game);
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    signal(SIGINT, finish);
    initscr();
    keypad(stdscr, TRUE);
    nonl();
    cbreak();
    noecho();
    nodelay(stdscr, 1);
    server = NULL;
    console = new Console(COLS, LINES);
    load_textures(1);
    my_ship = NULL;
    std::list<Sector *> sectors;

    server = new NetServer(DEFAULT_PORT, "initialD");
    nickname = "SERVER";
    servername = "localhost";

    std::string input("");

    std::list<Sector *>::iterator i;

    server->setup_master();
    sectors.push_front(server);
    
    while(1){
        // Select loop here
        wait_next_frame();

        int key = getch();
        if(key != ERR){
            if(key == 13){
                std::string line;
                line = "> " + input;
                console->log(line);
                input = "";
            }else {
                input += (char)key;
            }
        }
        server->do_frame();

        for(i = sectors.begin() ; i != sectors.end(); ++i){
            (*i)->frameupdate_with_collisions();
        }
        console->render();
        mvaddstr(LINES-1, 0, input.c_str());
        refresh();
    }

    finish(0);
}