Example #1
0
File: ui.c Project: barak/gtkboard
void ui_check_who_won()
{
	char *line, *who_str = NULL;
	int who, len;
	if (!move_fout)
		return;
	fprintf (move_fout, "WHO_WON \n");
	fflush (move_fout);
	line = line_read(move_fin);
	if (g_strncasecmp(line, "ACK", 3))
	{
		// NAK ==> not implemented
		ui_gameover = FALSE;
		sb_set_score ("");
		return;
	}
	line += 4;
	line = g_strstrip(line);
	who_str = line;
	while(!isspace(*line) && *line) line++;
	while(isspace(*line)) line++;
	sb_set_score (line);
	if (!g_strncasecmp(who_str, "NYET", 4))
	{
		ui_gameover = FALSE;
		return;
	}
	ui_stopped = TRUE;
	ui_gameover = TRUE;
	if (opt_logfile)
		fprintf(opt_logfile, "RESULT: %s\n", who_str);
	if (!state_gui_active)
		ui_cleanup();
	sb_update ();
	if (game_single_player && !ui_cheated && !g_strncasecmp(who_str, "WON", 3))
	{
		gboolean retval;
		retval = prefs_add_highscore (line, sb_get_human_time ());
		if (retval)
			sound_play (SOUND_HIGHSCORE);
		else 
			sound_play (SOUND_WON);
		if (game_levels)
		{
			GameLevel *next_level = game_levels;
			while (next_level->name)
			{
				if (next_level->game == opt_game)
					break;
				next_level++;
			}
			next_level++;
			if (next_level->name)
				menu_put_level (next_level->name);
		}
	}
	if (game_single_player && !ui_cheated && !g_strncasecmp(who_str, "LOST", 4))
		sound_play (SOUND_LOST);
}
void player_equip_item(u16 inv_slot)
{
    PLAYER_EQUIPPED_ITEM = inv_slot;

    //TODO: Do these transfer to Indy?
    if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_LIGHTSABER)
        sound_play(0x1F);
    else if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_LIGHT_BLASTER || tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_HEAVY_BLASTER)
        sound_play(0x20);
    else if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_THE_FORCE)
        sound_play(0x34);
}
Example #3
0
void
player_step(Player *P, int key_left, int key_right, int key_jump)
{
    Collision C = {0};

    // Left & right.

    int dx = 0;
    if (key_right) {
        dx = +1;
    }
    if (key_left)  {
        dx = -1;
    }
    scene_entity_move_x(&GAME->scene, P->E, dx * 2, &C);

    // Jump & fall.

    static int PLAYER_JUMP[] = { 5, 4, 3, 2, 2, 1, 1, 1 };

    if (key_jump && P->grounded) {
        P->jump = 1;
        sound_play(&GAME->sound_jump);
    }

    if (!P->jump) {
        P->fall = minimum(P->fall + 1, 16);
        if (!scene_entity_move_y(&GAME->scene, P->E, P->fall, &C)) {
            if (!P->grounded) {
                sound_play(&GAME->sound_land);
                P->grounded = 1;
            }
            P->fall = 2;
        } else {
            P->grounded = 0;
        }
    } else {
        P->grounded = 0;
        P->jump++;
        if (P->jump >= array_count(PLAYER_JUMP) ||
                scene_entity_move_y(&GAME->scene, P->E, -(PLAYER_JUMP[P->jump - 1] * 2), &C) == false)
        {
            P->jump = 0;
        }
    }

    // Draw the player.
    rect_draw_push(P->E->box, 2, 10);
}
Example #4
0
void update(objectmachine_t *obj, player_t **team, int team_size, brick_list_t *brick_list, item_list_t *item_list, object_list_t *object_list)
{
    objectdecorator_t *dec = (objectdecorator_t*)obj;
    objectdecorator_enemy_t *me = (objectdecorator_enemy_t*)obj;
    objectmachine_t *decorated_machine = dec->decorated_machine;
    object_t *object = obj->get_object_instance(obj);
    int i, score;

    score = (int)expression_evaluate(me->score);

    /* player x object collision */
    for(i=0; i<team_size; i++) {
        player_t *player = team[i];
        if(actor_pixelperfect_collision(object->actor, player->actor)) {
            if(player_is_attacking(player) || player->invincible) {
                /* I've been defeated */
                player_bounce(player, object->actor);
                level_add_to_score(score);
                level_create_item(IT_EXPLOSION, v2d_add(object->actor->position, v2d_new(0,-15)));
                level_create_animal(object->actor->position);
                sound_play( soundfactory_get("destroy") );
                object->state = ES_DEAD;
            }
            else {
                /* The player has been hit by me */
                player_hit(player, object->actor);
            }
        }
    }

    decorated_machine->update(decorated_machine, team, team_size, brick_list, item_list, object_list);
}
Example #5
0
/* misc */
void handle_logic(item_t *item, item_t *other, player_t **team, int team_size, void (*stepin)(item_t*,player_t*), void (*stepout)(item_t*))
{
    int i;
    int nobody_is_pressing_me = TRUE;
    switch_t *me = (switch_t*)item;
    actor_t *act = item->actor;

    /* step in */
    for(i=0; i<team_size; i++) {
        player_t *player = team[i];

        if(pressed_the_switch(item, player)) {
            nobody_is_pressing_me = FALSE;
            if(!me->is_pressed) {
                stepin(other, player);
                sound_play( soundfactory_get("switch") );
                actor_change_animation(act, sprite_get_animation("SD_SWITCH", 1));
                me->is_pressed = TRUE;
            }
        }
    }

    /* step out */
    if(nobody_is_pressing_me) {
        if(me->is_pressed) {
            stepout(other);
            actor_change_animation(act, sprite_get_animation("SD_SWITCH", 0));
            me->is_pressed = FALSE;
        }
    }
}
Example #6
0
File: ui.c Project: barak/gtkboard
int ui_get_machine_move ()
{
	byte *move;
	if (player_to_play == HUMAN || ui_stopped)
		return FALSE;
	if (!opt_infile)
	{
		move = move_fread_ack (move_fin);
		if (!move)
		{
			sb_error ("Couldn't make move\n", TRUE);
			ui_stopped = TRUE;
			sb_update ();
			return FALSE;
		}
		if (opt_logfile)
			move_fwrite (move, opt_logfile);
	}
	else 		// file mode
	{
		//TODO: should communicate the move to the engine
		move = move_fread (opt_infile);
		if (opt_logfile)
			move_fwrite (move, opt_logfile);
	}
	board_apply_refresh (move, NULL);
	if (!game_single_player)
		cur_pos.player = (cur_pos.player == WHITE ? BLACK : WHITE);
	cur_pos.num_moves ++;
	sound_play (SOUND_MACHINE_MOVE);
	ui_check_who_won ();
	sb_update ();
	ui_send_make_move ();
	return FALSE;
}
Example #7
0
void savesnap()
{
   sound_stop();
   savesnap(-1);
   eat();
   sound_play();
}
Example #8
0
VbError_t VbExBeep(uint32_t msec, uint32_t frequency)
{
	int res;
        if (frequency) {
                res = sound_start(frequency);
        } else {
                res = sound_stop();
	}

	if (res > 0) {
		// The previous call had an error.
		return VBERROR_UNKNOWN;
	} else if (res < 0) {
		// Non-blocking beeps aren't supported.
		if (msec > 0 && sound_play(msec, frequency))
			return VBERROR_UNKNOWN;
		return VBERROR_NO_BACKGROUND_SOUND;
	} else {
		// The non-blocking call worked. Delay if requested.
		if (msec > 0) {
			mdelay(msec);
			if (sound_stop())
				return VBERROR_UNKNOWN;
		}
		return VBERROR_SUCCESS;
        }
}
Example #9
0
int game_trans_start_game() {
	sound_play(START_BEGIN, START_END);
	PLAYER_DRIVE_set_modification(mod_disable_motors_and_servos, 3);
	player_lives = GAME_LIVES;
	LASER_TAG_set_hit_LED(0);
	return 0;
}
Example #10
0
//poll input for gui2
void gui2_poll()
{
	static u32 old_joy1 = 0;
	u32 new_joy1,joy1 = 0;

	//hack to make sure key isnt held down
	if(joykeys[config.gui_keys[0]])	joy1 |= INPUT_MENU;
	if(joykeys[config.gui_keys[1]])	joy1 |= INPUT_LOADSTATE;
	if(joykeys[config.gui_keys[2]])	joy1 |= INPUT_SAVESTATE;
	if(joykeys[config.gui_keys[4]])	joy1 |= INPUT_SCREENSHOT;
	new_joy1 = joy1 & ~old_joy1;
	old_joy1 = joy1;
	//end hack
	if(new_joy1 & INPUT_MENU) {
		//dont let user exit gui if rom is not loaded
		if((pce == 0) || (pce->rom == 0))
			return;
		gui_active ^= 1;
		memset(gui_draw_getscreen(),GUI_COLOR_OFFSET,gui_draw_getscreenpitch()*gui_draw_getscreenheight());
		if(gui_active == 0)
			sound_play();
		else {
			sound_pause();
			video_copyscreen();
		}
	}
	else if(gui_active) return;
	else if(new_joy1 & INPUT_LOADSTATE)	loadstate();
	else if(new_joy1 & INPUT_SAVESTATE)	savestate();
#ifdef SCREENSHOTS
	else if(new_joy1 & INPUT_SCREENSHOT)screenshot();
#endif
}
Example #11
0
void oled_game_over(){
	oled_clear_screen();
	
	sound_play(GAMEOVER); //Play game over music
	
	char message1[] = "GAME OVER";
	//char message2[] = "YOU DIED";

	oled_goto_line(3);
	oled_changeColumn(2);
	oled_print(message1);
	
	_delay_ms(3000);
	sound_play(SILENCE); //prevent looping
	_delay_ms(1000);
}
Example #12
0
void phaser(int ship, int x, int y)
{
    int bank = weapon_get_bank(ship,x,y);
    if (bank < 0)
        return;

    int id = -1;
    int i;
    int c = 0;
    for (i=0; i<50; i++) {
        if (shots_active[i].type == WEAPON_INACTIVE) {
            if (id < 0)
                id = i;
        } else if (shots_active[i].type == WEAPON_PHASER) {
            if (shots_active[i].ship == ship && shots_active[i].bank == bank)
                c++;
        }
    }

    if (c >= ships[ship].weapons[bank] || id < 0)
        return;

    sound_play(SND_PHASER);

    shots_active[id].type = WEAPON_PHASER;
    shots_active[id].ship = ship;
    shots_active[id].bank = bank;
    shots_active[id].tx = x;
    shots_active[id].ty = y;
    shots_active[id].ticks = 0;
    shots_active[id].pos = 0;
}
Example #13
0
void main_poke()
{
   sound_stop();
   DialogBox(hIn, MAKEINTRESOURCE(IDD_POKE), wnd, pokedlg);
   eat();
   sound_play();
}
Example #14
0
void opensnap()
{
   sound_stop();
   opensnap(0);
   eat();
   sound_play();
}
Example #15
0
/* fireball 떨어질때의 행동  */
void falling_behavior(item_t *fireball, brick_list_t *brick_list)
{
    int i, n;
    float sqrsize = 2, diff = -2;
    actor_t *act = fireball->actor;
    brick_t *down;

    /* 그에 따른 움직임, 카메라 시점 */
    act->speed.x = 0.0f;
    act->mirror = (act->speed.y < 0.0f) ? IF_VFLIP : IF_NONE;
    actor_move(act, actor_particle_movement(act, level_gravity()));
    actor_change_animation(act, sprite_get_animation("SD_FIREBALL", 0));

    /* 파괴하기 위한 목표 */
    actor_corners(act, sqrsize, diff, brick_list, NULL, NULL, NULL, NULL, &down, NULL, NULL, NULL);
    actor_handle_clouds(act, diff, NULL, NULL, NULL, NULL, &down, NULL, NULL, NULL);
    if(down) {
        /* 지면에 닿을 때의 소리 */
        fireball_set_behavior(fireball, disappearing_behavior);
        sound_play( soundfactory_get("fire2") );

        /* 좀 더 작은 fireball 생성 */
        n = 2 + random(3);
        for(i=0; i<n; i++) {
            item_t *obj = level_create_item(IT_FIREBALL, act->position);
            fireball_set_behavior(obj, smallfire_behavior);
            obj->actor->speed = v2d_new(((float)i/(float)n)*400.0f-200.0f, -120.0f-random(240.0f));
        }
    }
}
Example #16
0
void start()
{
 sound_play(1000,1000);
 for(i=0;i<75;i++)
 {
  PORTB.F7=1;        //SERVO_1
  delay_us(1500);
  PORTB.F7=0;
  delay_us(18500);
 }
 for(i=0;i<75;i++)
 {
  PORTB.F4=1;        //SERVO_2
  delay_us(1500);
  PORTB.F4=0;
  delay_us(18500);
 }
 for(i=0;i<75;i++)
 {
  PORTB.F1=1;        //SERVO_3
  delay_us(1500);
  PORTB.F1=0;
  delay_us(18500);
  }
  for(i=0;i<75;i++)
 {
  PORTD.F7=1;        //SERVO_4
  delay_us(1500);
  PORTD.F7=0;
  delay_us(18500);
  }
  for(i=0;i<75;i++)
 {
  PORTD.F4=1;        //SERVO_5
  delay_us(1500);
  PORTD.F4=0;
  delay_us(18500);
  }
  for(i=0;i<75;i++)
 {
  PORTD.F3=1;        //SERVO_6
  delay_us(1500);
  PORTD.F3=0;
  delay_us(18500);
 }
 sound_play(1000,1000);
}
Example #17
0
/*
    use an entry
    submenu: set submenu
    action: return action
    range: change pos due to c (inc or dec)
    str: add or delete char
*/
int MM_UseE(int c)
{
    MEnt *me = mm.c_mn->c_e;
    switch (me->t) {
        case ME_SUB:
#ifdef SOUND
            sound_play(mm.s_clk);
#endif
            if (mm.c_mn->c_e->cb != 0)
                mm.c_mn->c_e->cb();
            mm.c_mn = (Menu*)me->smn;
            break;
        case ME_ACT:
#ifdef SOUND
            sound_play(mm.s_clk);
#endif
            if (mm.c_mn->c_e->cb != 0)
                mm.c_mn->c_e->cb();
            return me->act;
        case ME_SWT:
        case ME_RNG:
#ifdef SOUND
            sound_play(mm.s_clk);
#endif
            if (c == MM_DEC) {
        		*me->p -= me->stp;
            	if (*me->p < me->min)
           	        *me->p = me->max - ((me->max - me->min) % me->stp);
        	}	
        	else
        	    if (c == MM_INC) {
        			*me->p += me->stp;
        			if (*me->p > me->max)
        			    *me->p = me->min;
        		}	
            if (mm.c_mn->c_e->cb != 0)
                mm.c_mn->c_e->cb();
            break;
        case ME_KEY:
            *me->p = 0;
            if (mm.c_mn->c_e->cb != 0)
                mm.c_mn->c_e->cb();
            break;
    }
    return MM_NONE;
}
Example #18
0
void game_sel_skip_back( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		game_sel_hide( HIDE_TARGET_SELECTED );
		skipping = -1;
	}
}
Example #19
0
/*
 * player_hit()
 * player가 공격한다. collectibles가 없다면 죽는다.
 */
void player_hit(player_t *player, actor_t *hazard)
{
    int w = image_width(actor_image(hazard))/2, h = image_height(actor_image(hazard))/2;
    v2d_t hazard_centre = v2d_add(v2d_subtract(hazard->position, hazard->hot_spot), v2d_new(w/2, h/2));

    if(player->invincible || physicsactor_get_state(player->pa) == PAS_GETTINGHIT || player->blinking || player_is_dying(player))
        return;

    if(player_get_collectibles() > 0 || player->shield_type != SH_NONE) {
        player->actor->speed.x = 120.0f * sign(player->actor->position.x - hazard_centre.x);
        player->actor->speed.y = -240.0f;
        player->actor->position.y -= 2; /* bugfix */

        player->pa_old_state = physicsactor_get_state(player->pa);
        physicsactor_hit(player->pa);

        if(player->shield_type != SH_NONE) {
            player->shield_type = SH_NONE;
            sound_play( soundfactory_get("damaged") );
        }
        else if(!player->disable_collectible_loss) {
            float a = 101.25f, spd = 240.0f*2;
            int i, r = min(32, player_get_collectibles());
            item_t *b;
            player_set_collectibles(0);

            /* collectibles 생성 */
            for(i=0; i<r; i++) {
                b = level_create_item(IT_BOUNCINGRING, player->actor->position);
                bouncingcollectible_set_speed(b, v2d_new(-sin(a*PI/180.0f)*spd*(1-2*(i%2)), cos(a*PI/180.0f)*spd));
                a += 22.5f * (i%2);

                if(i%16 == 0) {
                    spd /= 2.0f;
                    a = 101.25f;
                }
            }

            sound_play( soundfactory_get("collectible loss") );
        }
        else
            sound_play( soundfactory_get("damaged") );
    }
    else
        player_kill(player);
}
Example #20
0
void main_maxspeed()
{
   conf.sound.enabled ^= 1;
   temp.frameskip = conf.sound.enabled? conf.frameskip : conf.frameskipmax;
   if (conf.sound.enabled) sound_play(); else sound_stop();
   sprintf(statusline, "Max speed: %s", conf.sound.enabled ? "NO" : "YES"); statcnt = 50;
   set_priority();
}
Example #21
0
LVAL xlc_snd_play(void)
{
    LVAL arg1 = xlgetarg();

    xllastarg();
    sound_play(arg1);
    return NIL;
}
Example #22
0
void game_sel_advance( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		game_sel_shuffle_back( 1 );
		scroll_direction = -1;
		step = steps-1;
	}
}
Example #23
0
void sound_active(bool s)
{
    if (s) {
        sound_load(current_file);
        sound_play();
    } else {
        sound_unload();
    }
}
Example #24
0
void sound_test()
{
	sound_initAC97();
	sound_initInterupts();
	xil_printf("Press a number between 0 and 8 to play a sound\r\n");
	while(true)
	{
		char input;
		input = getchar();
		switch (input) {
		case '0':
			sound_play(explosion_sound);
			break;
		case '1':
			sound_play(fastinvader1_sound);
			break;
		case '2':
			sound_play(fastinvader2_sound);
			break;
		case '3':
			sound_play(fastinvader3_sound);
			break;
		case '4':
			sound_play(fastinvader4_sound);
			break;
		case '5':
			sound_play(invaderkilled_sound);
			break;
		case '6':
			sound_play(shoot_sound);
			break;
		case '7':
			sound_play(ufo_highpitch_sound);
			break;
		case '8':
			sound_play(ufo_lowpitch_sound);
			break;
		case '+':
			sound_volumeUp();
			break;
		case '-':
			sound_volumeDown();
			break;
		default:
			xil_printf("Key pressed: %c (code %d)\r\n", input, (int)input);
			break;
		}
	}
}
Example #25
0
/*
 * player_breathe()
 * 호흡 (air bublle, 수중에서)
 */
void player_breathe(player_t *player)
{
    if(player->underwater && physicsactor_get_state(player->pa) != PAS_BREATHING && physicsactor_get_state(player->pa) != PAS_DROWNED && physicsactor_get_state(player->pa) != PAS_DEAD) {
        player_reset_underwater_timer(player);
        player->actor->speed = v2d_new(0, 0);
        player->pa_old_state = physicsactor_get_state(player->pa);
        physicsactor_breathe(player->pa);
        sound_play( soundfactory_get("breathing") );
    }
}
Example #26
0
/* player의 애니메이션을 업데이트한다. */
void update_animation(player_t *p)
{
    /* animations */
    if(!p->disable_animation_control) {
        switch(physicsactor_get_state(p->pa)) {
            case PAS_STOPPED:    CHANGE_ANIM(stopped);    break;
            case PAS_WALKING:    CHANGE_ANIM(walking);    break;
            case PAS_RUNNING:    CHANGE_ANIM(running);    break;
            case PAS_JUMPING:    CHANGE_ANIM(jumping);    break;
            case PAS_SPRINGING:  CHANGE_ANIM(springing);  break;
            case PAS_ROLLING:    CHANGE_ANIM(rolling);    break;
            case PAS_PUSHING:    CHANGE_ANIM(pushing);    break;
            case PAS_GETTINGHIT: CHANGE_ANIM(gettinghit); break;
            case PAS_DEAD:       CHANGE_ANIM(dead);       break;
            case PAS_BRAKING:    CHANGE_ANIM(braking);    break;
            case PAS_LEDGE:      CHANGE_ANIM(ledge);      break;
            case PAS_DROWNED:    CHANGE_ANIM(drowned);    break;
            case PAS_BREATHING:  CHANGE_ANIM(breathing);  break;
            case PAS_WAITING:    CHANGE_ANIM(waiting);    break;
            case PAS_DUCKING:    CHANGE_ANIM(ducking);    break;
            case PAS_LOOKINGUP:  CHANGE_ANIM(lookingup);  break;
            case PAS_WINNING:    CHANGE_ANIM(winning);    break;
        }
    }
    else
        p->disable_animation_control = FALSE; /* for set_player_animation (scripting) */

    /* sounds */
    ON_STATE(PAS_JUMPING) {
        sound_play( charactersystem_get(p->name)->sample.jump );
    }

    ON_STATE(PAS_ROLLING) {
        sound_play( charactersystem_get(p->name)->sample.roll );
    }

    ON_STATE(PAS_BRAKING) {
        sound_play( charactersystem_get(p->name)->sample.brake );
    }

    /* "gambiarra" */
    p->actor->hot_spot = v2d_new(image_width(actor_image(p->actor))/2, image_height(actor_image(p->actor))-20);
}
Example #27
0
void main_selectfilter()
{
   sound_stop();
   int index = DialogBoxParam(hIn, MAKEINTRESOURCE(IDD_FILTER_DIALOG), wnd, filterdlg, 0);
   eat(); sound_play(); if (index < 0) return;

   conf.render = index;
   sprintf(statusline, "Video: %s", renders[index].name); statcnt = 50;
   apply_video(); eat();
}
Example #28
0
void game_sel_retreat( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		if( game_tile_current->prev )
			game_tile_current = game_tile_current->prev;
		scroll_direction = 1;
		step = 1;
	}
}
Example #29
0
/*
 * player_drown()
 * player가 익사(수중에서)할 때 사용하는 함수. 이것은 내부에서 자동으로 호출된다.
 */
void player_drown(player_t *player)
{
    if(player->underwater && !player_is_dying(player)) {
        player->actor->position.y -= 2;
        player->actor->speed = v2d_new(0, 0);
        player->pa_old_state = physicsactor_get_state(player->pa);
        physicsactor_drown(player->pa);
        sound_play( soundfactory_get("drown") );
    }
}
Example #30
0
static void create_new_pumpkin(struct game* g, int x, int y)
{
	if (g->pumpkin_count > g->max_x * g->max_y - 2)
		return;

	pumpkin_create(&g->field[x][y], "b1", (float)x, (float)y);
	g->field[x][y].stage = PUMPKIN_CREATED;
	g->pumpkin_count++;
	LOGT("create_new_pumpkin. x: %d, y: %d, count: %d", x, y, g->pumpkin_count);
	sound_play(sound_new_pumpkin);
}