예제 #1
0
int Game::main_loop()
{
    // Poll for events, and handle the ones we care about.
    SDL_Event event;

    bool loop = true;
    int P_lastmove;
    while(loop)
    {
        while(tick_count < P_nextmove){
            simulate_tick();
            tick_count++;
            redraw();
            SDL_Delay(40);
            while (SDL_PollEvent(&event));
        }
        while (SDL_PollEvent(&event))
        {
            handle_event(event);
            if(getState() == GS_QUIT) loop = false;
        }

        calc_move();
        if(SDL_GetTicks() - P_lastmove > 100 and move_req())
        {
            P_lastmove = SDL_GetTicks();
            P_turn();
            redraw();
            P_nextmove = tick_count+1;
        }
        SDL_Delay(1000.0/30.0); // 30 fps
    }
    return 0;
}
예제 #2
0
void do_join (CHAR_DATA * ch, char *argument)
{
int i,j;

char arg[MSL];
argument = one_argument (argument, arg);

if(ch->infight)
{
send_to_char("You are already fighting.\n\r",ch);
return;
}

if(ch->in_room->map.closed)
{
send_to_char("Sorry, this fight is closed, but you can still watch.\n\r",ch);
return;
}

if(strlen(ch->fdisp)<1)
do_autodisp(ch," ");

if (!strcmp (arg, "blue"))
{
ch->team = TEAM_BLUE;
}
else if (!strcmp (arg, "red"))
{
ch->team = TEAM_RED;
}
else if (!strcmp (arg, "green"))
{
ch->team = TEAM_GREEN;
}
else if (!strcmp (arg, "none"))
{
ch->team = TEAM_NONE;
}
else
{
send_to_char("You need to specify a side to join (red,green,blue,none)\n\r",ch);
return;
}
calc_move(ch);

if(IS_SET (ch->in_room->room_flags, ROOM_SAFE))
DIE(ch,"No fighting here.");

if(!ch->in_room->map.init)
{
ch->in_room->map.init = TRUE;
generate_random_terrain(ch->in_room);
}


act ("$n joins the fight!", ch, NULL, NULL, TO_ROOM);
send_to_char("You join the fight!\n\r",ch);

j = number_range(1,25);
i = number_range(1,15);

while(ch->in_room->map.index[i][j].occupied == TRUE)
{
j = number_range(1,25);
i = number_range(1,15);
}

ch->AT = number_range(1,97);

ch->mposy = i;
ch->mposx = j;
ch->in_room->map.index[i][j].occupied = TRUE;
ch->infight = TRUE;
}
예제 #3
0
void set_stats(CHAR_DATA *ch) //stub
{
calc_move(ch);
}