Ejemplo n.º 1
0
/* before it will open. */
void drop_jumppoint (int x, int y, int player) {
    /* First search for a exit point to this jumppoint */
    struct dllist *ptr=special_list;
    struct SpecialObj *exit,*point;
    while(ptr) {
        exit = ptr->data;
        if(exit->gfx==jumppoint_gfx[1] && exit->owner == player &&
                exit->link==NULL)
            break;
        ptr=ptr->next;
    }
    if(ptr) { /* If exit point exists, create the wormhole */
        point = make_jumppoint(x,y,player,0);
        point->link = exit;
        exit->link = point;

        exit->life = point->life;
        exit->animate = point->animate;
        exit->secret = 0;
        if(game_settings.onewayjp==0) {
            exit->hitship = point->hitship;
            exit->hitprojectile = point->hitprojectile;
        }
        playwave (WAV_JUMP);
    } else { /* No exit point, create one */
        point = make_jumppoint(x,y,player,1);
        point->animate = NULL;
        point->hitship = NULL;
        point->hitprojectile = NULL;
        point->life=-1;
        point->secret = 1;
    }
    add_special(point);
}
Ejemplo n.º 2
0
static void sndPlayer(void* p){
    int i;
    int sndidx=0;
    while(1){
        playwave(snd+sndidx,SAMPLES_EMIT);
        sndidx += SAMPLES_EMIT;
        if(sndidx >= SAMPLES){
            sndidx = 0;
        }
    }
}
Ejemplo n.º 3
0
Archivo: intro.c Proyecto: callaa/luola
/* Intro screen eventloop */
static int intro_event_loop (void) {
    Uint8 needupdate, rval, isevent;
    SDL_Event Event;
    Sint8 command;
    Uint32 delay, lasttime;
    while (1) {
        if (game_settings.mbg_anim) {
            needupdate = 1;
            isevent = SDL_PollEvent (&Event);
        } else {
            needupdate = 0;
            isevent = 1;
            if (!SDL_WaitEvent (&Event)) {
                printf ("Error occured while waiting for an event: %s\n",
                        SDL_GetError ());
                exit (1);
            }
        }
        if (isevent)
            switch (Event.type) {
            case SDL_KEYDOWN:
                command = -1;
                if (intr_message.show) {
                    intr_message.show = 0;
                    if (intr_message.setkey) {
                        *intr_message.setkey = Event.key.keysym.sym;
                        intr_message.setkey = NULL;
                        return 0;
                    }
                    needupdate = 1;
                } else {
                    if (Event.key.keysym.sym == SDLK_F11)
                        screenshot ();
                    else if (Event.key.keysym.sym == SDLK_UP)
                        command = MNU_UP;
                    else if (Event.key.keysym.sym == SDLK_DOWN)
                        command = MNU_DOWN;
                    else if (Event.key.keysym.sym == SDLK_LEFT)
                        command = MNU_LEFT;
                    else if (Event.key.keysym.sym == SDLK_RIGHT)
                        command = MNU_RIGHT;
                    else if (Event.key.keysym.sym == SDLK_RETURN) {
                        if((Event.key.keysym.mod & (KMOD_LALT|KMOD_RALT)))
                            toggle_fullscreen();
                        else
                            command = MNU_ENTER;
                    }
                    else if (Event.key.keysym.sym == SDLK_ESCAPE)
                        command = MNU_BACK;
                }
                if (command >= 0) {
                    if (command != MNU_ENTER && command != MNU_BACK)
                        playwave (WAV_BLIP);
                    else
                        playwave (WAV_BLIP2);
                    rval = menu_control (&intro_menu, command);
                    if (rval == INTRO_RVAL_STARTGAME
                        || rval == INTRO_RVAL_EXIT)
                        return rval;
                    needupdate = 1;
                }
                break;
            case SDL_JOYBUTTONUP:
            case SDL_JOYBUTTONDOWN:
                joystick_button (&Event.jbutton);
                break;
            case SDL_JOYAXISMOTION:
                joystick_motion (&Event.jaxis, 0);
                break;
            case SDL_QUIT:
                exit(0);
            default:
                break;
            }
        if (!(game_settings.mbg_anim && isevent)) {
            lasttime = SDL_GetTicks ();
            if (needupdate)
                draw_intro_screen ();
            if (game_settings.mbg_anim) {
                delay = SDL_GetTicks () - lasttime;
                if (delay >= 60)
                    delay = 0;
                else
                    delay = 60 - delay;
                SDL_Delay (delay);
            }
        }
    }
    /* Never reached */
    return 0;
}
Ejemplo n.º 4
0
/* or 0 if selection was cancelled. */
int select_weapon(struct LevelFile *level) {

    int i;
    memset(screen->pixels,0,screen->pitch*screen->h);
    draw_header(screen,level->settings->mainblock.name);
    for(i=0;i<4;i++)
        if(players[i].state != INACTIVE)
            draw_weapon_bar(screen,i);

    SDL_UpdateRect(screen,0,0,0,0);

    while(1) {
        SDL_Event event;
        SDL_WaitEvent(&event);

        /* Handle event */
        if(event.type == SDL_KEYDOWN) {
            if (event.key.keysym.sym == SDLK_F11)
                screenshot ();
            else if(event.key.keysym.sym == SDLK_RETURN) {
                if((event.key.keysym.mod & (KMOD_LALT|KMOD_RALT)))
                    toggle_fullscreen();
                else
                    return 1;
            } else if(event.key.keysym.sym == SDLK_ESCAPE)
                break;
            else for(i=0;i<4;i++) {
                int update = 0;
                if(players[i].state == INACTIVE) continue;
                if(event.key.keysym.sym ==
                        game_settings.controller[i].keys[2]) {
                    players[i].specialWeapon--;
                    update=1;
                } else if (event.key.keysym.sym ==
                        game_settings.controller[i].keys[3]) {
                    players[i].specialWeapon++;
                    update=1;
                } else if (event.key.keysym.sym ==
                           game_settings.controller[i].keys[1]) {
                    players[i].standardWeapon--;
                    update=1;
                } else if (event.key.keysym.sym ==
                           game_settings.controller[i].keys[0]) {
                    players[i].standardWeapon++;
                    update=1;
                }
                if(update) {
                    SDL_Rect rect;
                    playwave(WAV_BLIP);

                    if ((int)players[i].specialWeapon < 0)
                        players[i].specialWeapon = special_weapon_count() - 1;
                    else if (players[i].specialWeapon == special_weapon_count() )
                        players[i].specialWeapon = 0;
                    if ((int) players[i].standardWeapon < 0)
                        players[i].standardWeapon = normal_weapon_count() - 1;
                    else if ((int) players[i].standardWeapon == normal_weapon_count())
                        players[i].standardWeapon = 0;

                    rect = draw_weapon_bar(screen,i);
                    SDL_UpdateRect(screen,rect.x,rect.y,rect.w,rect.h);
                }
            }
        } else if(event.type == SDL_JOYBUTTONDOWN)
            joystick_button(&event.jbutton);
        else if(event.type == SDL_JOYAXISMOTION)
            joystick_motion(&event.jaxis,1);
        else if(event.type == SDL_QUIT)
            exit(0);
    }
    return 0;
}