Пример #1
0
void record_monst(cCreature *which_m)
{
	short r1;
	char str[60];
	
	r1 = get_ran(1,1,100);
	r1 = (r1 * 7) / 10;
	
	if ((which_m->x_width > 1) || (which_m->y_width > 1)) {
		ASB("Capture Soul: Monster is too big.");
		}
	else if ((r1 > charm_odds[which_m->level / 2]) || (which_m->spec_skill == 12)
		|| (which_m->m_type == 3)) {
		monst_spell_note(which_m->number,10);
		play_sound(68);
		}
		else {
			monst_spell_note(which_m->number,24);
			r1 = get_ran(1,0,3);
			if (univ.party.imprisoned_monst[r1] == 0)
				univ.party.imprisoned_monst[r1] = which_m->number;
				else {
					r1 = get_ran(1,0,3);
					univ.party.imprisoned_monst[r1] = which_m->number;
					}
			ASB("Capture Soul: Success!");
			sprintf((char *)str,"  Caught in slot %d.",r1 + 1);
			add_string_to_buf((char *)str);
			play_sound(53);
			}
}
Пример #2
0
static void
check_game_state (void)
{
  if (is_line_at (player, row, column)) {
    gameover = TRUE;
    winner = player;
    switch (get_n_human_players ()) {
    case 1:
      if (is_player_human ()) {
	play_sound (SOUND_YOU_WIN);
      } else {
	play_sound (SOUND_I_WIN);
      }
      break;
    case 0:
    case 2:
      play_sound (SOUND_PLAYER_WIN);
      break;
    }
    blink_winner (6);
  } else if (moves == 42) {
    gameover = TRUE;
    winner = NOBODY;
    play_sound (SOUND_DRAWN_GAME);
  }
}
Пример #3
0
int main( int argc, char* argv[])
{
    //check argument
    if ( argc != 2 )
    {
	fprintf(stderr, "[PLAY]: %s <filename>.wav \n", argv[0]);
	exit(1);
    }

    play_init(LIST, NOWAIT, NONDISP);
    play_read_filelist(argv[1]);

    play_sound("start");
    sleep(1);
    play_sound("stop");
    sleep(1);
    play_sound("left");
    sleep(1);
    play_sound("right");
    sleep(1);

    play_sync();
    play_close();
    return 1;
}
Пример #4
0
void play_ambient_sound(){ // TODO: Maybe add a system for in-town ambient sounds
	if(overall_mode == MODE_TOWN) {
		for(int i = 0; i < univ.town.monst.size(); i++) {
			if(party_can_see_monst(i))
				check_if_monst_seen(univ.town.monst[i].number, univ.town.monst[i].cur_loc);
		}
		return;
	}
	static const short drip[2] = {78,79}, bird[3] = {76,77,91};
	if(overall_mode != MODE_OUTDOORS) return; // ambient sounds are outdoors only at the moment
	if(get_ran(1,1,100) > 10) return; // 10% chance per move of playing a sound
	short sound_to_play;
	switch(univ.out->ambient_sound){
		case AMBIENT_DRIP:
			sound_to_play = get_ran(1,0,1);
			play_sound(-drip[sound_to_play]);
			break;
		case AMBIENT_BIRD:
			sound_to_play = get_ran(1,0,2);
			play_sound(-bird[sound_to_play]);
			break;
		case AMBIENT_CUSTOM:
			sound_to_play = univ.out->out_sound;
			play_sound(-sound_to_play);
			break;
		case AMBIENT_NONE:
			break; // obviously, do nothing
	}
}
Пример #5
0
void init_sound() {
	play_sound ( 1000 );
	sleep ( 1 );
	play_sound ( 990 );
	sleep ( 1 );
	play_sound ( 1000 );
	sleep ( 1 );
	nosound();
	exit();
}
Пример #6
0
// seg001:05EC
void __pascal far pv_scene() {
	init_princess();
	saveshad();
	if (fade_in_1()) return;
	init_vizier();
	savekid();
	if (proc_cutscene_frame(2)) return;
	play_sound(sound_50_story_2_princess); // story 2: princess waiting
	do {
		if (proc_cutscene_frame(1)) return;
		//idle();
	} while(check_sound_playing());
	cutscene_frame_time = 8;
	if (proc_cutscene_frame(5)) return;
	play_sound(sound_4_gate_closing); // gate closing
	do {
		if (proc_cutscene_frame(1)) return;
	} while(check_sound_playing());
	play_sound(sound_51_princess_door_opening); // princess door opening
	if (proc_cutscene_frame(3)) return;
	seqtbl_offset_shad_char(98); // princess turn around [PV1]
	if (proc_cutscene_frame(5)) return;
	seqtbl_offset_kid_char(96); // Jaffar walk [PV1]
	if (proc_cutscene_frame(6)) return;
	play_sound(sound_53_story_3_Jaffar_comes); // story 3: Jaffar comes
	seqtbl_offset_kid_char(97); // Jaffar stop [PV1]
	if (proc_cutscene_frame(4)) return;
	if (proc_cutscene_frame(18)) return;
	seqtbl_offset_kid_char(96); // Jaffar walk [PV1]
	if (proc_cutscene_frame(30)) return;
	seqtbl_offset_kid_char(97); // Jaffar stop [PV1]
	if (proc_cutscene_frame(35)) return;
	seqtbl_offset_kid_char(102); // Jaffar conjuring [PV1]
	cutscene_frame_time = 7;
	if (proc_cutscene_frame(1)) return;
	seqtbl_offset_shad_char(99); // princess step back [PV1]
	if (proc_cutscene_frame(17)) return;
	hourglass_state = 1;
	flash_time = 5;
	flash_color = 15; // white
	do {
		if (proc_cutscene_frame(1)) return;
		//idle();
	} while(check_sound_playing());
	seqtbl_offset_kid_char(100); // Jaffar end conjuring and walk [PV1]
	hourglass_sandflow = 0;
	if (proc_cutscene_frame(6)) return;
	play_sound(sound_52_story_4_Jaffar_leaves); // story 4: Jaffar leaves
	if (proc_cutscene_frame(24)) return;
	hourglass_state = 2;
	if (proc_cutscene_frame(9)) return;
	seqtbl_offset_shad_char(113); // princess look down [PV1]
	if (proc_cutscene_frame(28)) return;
	fade_out_1();
}
Пример #7
0
/* Break a brick: */
void
World::trybreakbrick(float x, float y, bool small, Direction col_side)
{
  Level* plevel = get_level();
  
  Tile* tile = gettile(x, y);
  if (tile->brick)
    {
      if (tile->data > 0)
        {
          /* Get a distro from it: */
          add_bouncy_distro(((int)(x + 1) / 32) * 32,
                                  (int)(y / 32) * 32);

          // TODO: don't handle this in a global way but per-tile...
          if (!counting_distros)
            {
              counting_distros = true;
              distro_counter = 5;
            }
          else
            {
              distro_counter--;
            }

          if (distro_counter <= 0)
            {
              counting_distros = false;
              plevel->change(x, y, TM_IA, tile->next_tile);
            }

          play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
          player_status.score = player_status.score + SCORE_DISTRO;
          player_status.distros++;
        }
      else if (!small)
        {
          /* Get rid of it: */
          plevel->change(x, y, TM_IA, tile->next_tile);
          
          /* Replace it with broken bits: */
          add_broken_brick(tile, 
                                 ((int)(x + 1) / 32) * 32,
                                 (int)(y / 32) * 32);
          
          /* Get some score: */
          play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
          player_status.score = player_status.score + SCORE_BRICK;
        }
    }
  else if(tile->fullbox)
    tryemptybox(x, y, col_side);
}
Пример #8
0
void
Upgrade::collision(void* p_c_object, int c_object, CollisionType type)
{
  Player* pplayer = NULL;

  if(type == COLLISION_BUMP) {
    if(c_object == CO_PLAYER)
      pplayer = (Player*) p_c_object;
    bump(pplayer);
    return;
  }

  switch (c_object)
    {
    case CO_PLAYER:
      /* Remove the upgrade: */

      /* p_c_object is CO_PLAYER, so assign it to pplayer */
      pplayer = (Player*) p_c_object;

      /* Affect the player: */

      if (kind == UPGRADE_GROWUP)
        {
          play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
          pplayer->grow();
        }
      else if (kind == UPGRADE_ICEFLOWER)
        {
          play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
          pplayer->grow();
          pplayer->got_coffee = true;
        }
      else if (kind == UPGRADE_HERRING)
        {
          play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER);
          pplayer->invincible_timer.start(TUX_INVINCIBLE_TIME);
          World::current()->play_music(HERRING_MUSIC);
        }
      else if (kind == UPGRADE_1UP)
        {
          if(player_status.lives < MAX_LIVES) {
            player_status.lives++;
            play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
          }
        }

      remove_me();
      return;
    }
}
Пример #9
0
void MelnormeShot::calculate()
{
	STACKTRACE;
	if (released) {
		Shot::calculate();
	} else {
		SpaceObject::calculate();
	}
	if (!exists()) return;
	frame_step += frame_time;
	if (frame_step >= frame_size) {
		frame_step -= frame_size;
		frame++;
		if (frame == frame_count) {
			frame = 0;
			if ((!released) && (charge_phase < 3)) {
				charge_frame++;
				if (charge_frame == 5) {
					charge_frame = 0;
					charge_phase++;
					damage_factor *= 2;
					armour *= 2;
					range += RangeUp;
					play_sound(data->sampleWeapon[0]);
				}
			}
		}
	}
	sprite_index = (charge_phase * 10) + frame;
	if (!released) {
		if (!ship || !ship->fire_weapon) {
			//			vx = cos(angle) * v;
			//			vy = sin(angle) * v;
			vel = v * unit_vector(angle);
			released = TRUE;
			play_sound(data->sampleSpecial[0]);
		} else {
			angle = ship->get_angle();
			//			x = ship->normal_x() + (cos(angle) * (ship->width() / 2.0));
			//			y = ship->normal_y() + (sin(angle) * (ship->height() / 2.0));
			pos = ship->normal_pos() + 0.5 * product(unit_vector(angle), ship->get_size());
			//			vx = ship->get_vx();
			//			vy = ship->get_vy();
			vel = ship->get_vel();

		}
	}
	return;
}
Пример #10
0
void
keys_keys ()
{
  static int      lscan_code;
  int             scan_code;
  scan_code = GetKey ();
  if (!scan_code && lscan_code)
    {
      keys[player][keynum] = lscan_code;
      keynum++;
#ifdef SOUND
      if (ssound)
	play_sound (S_CREATOR2);
#endif
      if (keynum > (rotation[player] ? 2 : 3))
	{
	  player++;
	  keynum = 0;
	  if (player > lastplayer)
	    {
	      change_menu ();
	      gamemode = MENU;
	    }
	}
    }
  lscan_code = scan_code;
}
Пример #11
0
// detects bullet hits
void Game::detectHits(bool gameMuted) {
    // loop through each bullet and detect
    // collsion against each enemy
    for(int i = 0; i < this->player.shots.size(); i++) {
        for(int j = 0; j < this->enemies.size(); j++) {
            // if the two elements intersect
            if(intersects(this->player.shots[i], this->enemies[j])) {
                this->player.shots.erase(this->player.shots.begin() + i);
                this->enemies.erase(this->enemies.begin() + j);
                this->PLAYER_SCORE += 10;
                if(!gameMuted)
                    play_sound("impact.wav");
                break;
            }
        }
    }

    // loop through enemy bullets and detect
    // collision against player
    for(int i = 0; i < this->enemyShots.size(); i++ ) {
        if(intersects(this->enemyShots[i], this->player)) {
            this->enemyShots.erase(this->enemyShots.begin() + i);
            this->PLAYER_LIVES--;
        }
    }
}
Пример #12
0
void os_start_sample (int number, int volume, int repeats, zword eos)
{
  /* INCOMPLETE */

  sigset_t sigchld_mask;
  struct sigaction sa;

  os_prepare_sample(number);
  if (! sound_buffer)
    return;
  os_stop_sample(0);

  sigemptyset(&sigchld_mask);
  sigaddset(&sigchld_mask, SIGCHLD);
  sigprocmask(SIG_BLOCK, &sigchld_mask, NULL);

  child_pid = fork();

  if (child_pid < 0) {          /* error in fork */
    perror("fork");
    return;
  }
  else if (child_pid == 0) {    /* child */
    sigprocmask(SIG_UNBLOCK, &sigchld_mask, NULL);
    play_sound(volume, repeats);
  }
  else {                        /* parent */
    sa.sa_handler = sigchld_handler;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
    sigaction(SIGCHLD, &sa, NULL);

    sigprocmask(SIG_UNBLOCK, &sigchld_mask, NULL);
  }
}/* os_start_sample */
Пример #13
0
static void* _delete_enemy(ListAnchor *enemies, List* enemy, void *arg) {
	Enemy *e = (Enemy*)enemy;

	if(e->hp <= 0 && e->hp != ENEMY_IMMUNE && e->hp != ENEMY_BOMB) {
		play_sound("enemydeath");

		for(int i = 0; i < 10; i++) {
			tsrand_fill(2);

			PARTICLE(
				.sprite = "flare",
				.pos = e->pos,
				.timeout = 10,
				.rule = linear,
				.draw_rule = Fade,
				.args = { (3+afrand(0)*10)*cexp(I*afrand(1)*2*M_PI) },
			);
		}

		PARTICLE(.proto = pp_blast, .pos = e->pos, .timeout = 20, .draw_rule = Blast, .flags = PFLAG_REQUIREDPARTICLE);
		PARTICLE(.proto = pp_blast, .pos = e->pos, .timeout = 20, .draw_rule = Blast, .flags = PFLAG_REQUIREDPARTICLE);
		PARTICLE(.proto = pp_blast, .pos = e->pos, .timeout = 15, .draw_rule = GrowFade, .flags = PFLAG_REQUIREDPARTICLE);

		for(Projectile *p = global.projs.first; p; p = p->next) {
			if(p->type == PROJ_ENEMY && !(p->flags & PFLAG_NOCOLLISION) && cabs(p->pos - e->pos) < 64) {
				spawn_and_collect_item(e->pos, ITEM_PIV, 1);
			}
		}
	}
Пример #14
0
void TauFiendPWave::inflict_damage(SpaceObject *other)
{
	STACKTRACE;
	play_sound(explosionSample);
	add(new TauFiendPEffect(this, (Ship*)other, explosionSprite, emp_fs, delay));
	state = 0;
}
Пример #15
0
void TauFiend::calculate_fire_special()
{
	STACKTRACE;
	if (cooling_count > 0) cooling_count -= frame_time;
	if ((!fire_special) || (batt == 0)) {
		if (charge_count >= 0)
			charge_count -= frame_time;
	}
	else    if ((fire_special) && (cooling_count <= 0)) {
		if (charge_count < charge_time) {
			charge_count += frame_time;
			residual_drain += frame_time * (double)special_drain / charge_time;
		} else {
			cooling_count = cooling_time;
			charge_count = -1;
			play_sound(data->sampleSpecial[0]);
			add(new TauFiendPWave(Vector2(0, 30), angle, specialVelocity, specialRange, this,
				data->spriteSpecialExplosion, specialRelativity, specialSap, specialDuration));
		}
	}
	int a = (int)floor(residual_drain);
	batt -= a;
	if (batt < 0) batt = 0;
	residual_drain -= a;
	if (residual_drain < 0) residual_drain = 0;
}
Пример #16
0
void
CSoundFX::PlaySoundFX (UINT IDButton, UINT IDWindow, BOOL UseDefault /*= TRUE*/)
{
   LPCSTR   fn;
   int      i;

   for (i = 0; i < NUM_SOUNDFX; i++)
   {
      if (SoundIndex >= NUM_SOUNDFX)
         SoundIndex = 0;

      if ((Sound [SoundIndex].WindowID == IDWindow) && (Sound [SoundIndex].ControlID == IDButton))
         break;
      
      SoundIndex ++;
   } 

   if (i >= NUM_SOUNDFX)   // Didn't find it, use default sound (maybe)
   {
      if (UseDefault != TRUE)
         return;

      fn = FileName [0];
   }
   else
      fn = FileName [Sound [SoundIndex].FileNameIndex];

   CString csName = GetGlobalPathManager()->ExpandPath((char *)fn);
   play_sound ((LPSTR)(LPCSTR)csName, 0, NULL, FALSE);
}
Пример #17
0
void play_note(){
	if(notes[note_index].freq==WAIT_FREQ){
		stop_sound();
	} else {
		play_sound(notes[note_index].freq);
	}
}
Пример #18
0
void Dodger::check_if_eating(int new_cell)
{
    if (new_cell == Level::apple
            || new_cell == Level::sberry
            || new_cell == Level::cherry) {
        level.food_count--;
        level.data[player_line][player_col] = Level::grid;

        play_sound(sounds.chomp);

        switch (new_cell) {
        case Level::apple:
            score += 20;
            break;
        case Level::sberry:
            score += 30;
            break;
        case Level::cherry:
            score += 50;
            break;
        }

        score_panel.set_score(score);
        if (score > high_score) {
            high_score = score;
            score_panel.set_high_score(high_score);
        }
    }
}
Пример #19
0
int EarthlingCruiserMk3::activate_special()
{
	STACKTRACE;
	bool fire = false;;
	SpaceObject *o;
	double rng = 1e40;
	SpaceObject *tgt = NULL;

								 //!!!
	pos -= unit_vector(angle) * 6;
	Query q;
	for (q.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
	bit(LAYER_CBODIES), specialRange); q.current; q.next()) {
		o = q.currento;
		if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))
		&& (distance(o) < rng)) {
			tgt = o;
			rng = distance(o);
		}
	}
	q.end();
								 //!!!
	pos += unit_vector(angle) * 6;

	if (tgt) {
		game->add(new EarthlingCruiserMk3Beam(this, Vector2(0,-6), specialRange,
			specialDamage, specialDamageShots, specialFrames, tgt));
		play_sound(data->sampleSpecial[0]);
		fire = true;
	}

	return(fire);
}
Пример #20
0
bool handle_lever(location w) {
	if(cChoiceDlog("basic-lever",{"pull", "leave"}).show() == "leave")
		return false;
	play_sound(94);
	alter_space(w.x,w.y,univ.scenario.ter_types[univ.town->terrain(w.x,w.y)].trans_to_what);
	return true;
}
Пример #21
0
// seg001:041C
void __pascal far end_sequence_anim() {
	disable_keys = 1;
	if (!is_sound_on) {
		turn_sound_on_off(0x0F);
	}
	copy_screen_rect(&screen_rect);
	play_sound(sound_26_embrace); // arrived to princess
	init_ending_princess();
	saveshad();
	init_ending_kid();
	savekid();
	if (proc_cutscene_frame(8)) return;
	seqtbl_offset_shad_char(seq_108_princess_turn_and_hug); // princess turn and hug [PV2]
	if (proc_cutscene_frame(5)) return;
	seqtbl_offset_kid_char(seq_13_stop_run); // stop run
	if (proc_cutscene_frame(2)) return;
	Kid.frame = 0;
	if (proc_cutscene_frame(39)) return;
	init_mouse_1();
	savekid();
	if (proc_cutscene_frame(9)) return;
	seqtbl_offset_kid_char(seq_101_mouse_stands_up); // mouse stands up
	if (proc_cutscene_frame(41)) return;
	fade_out_1();
	while (check_sound_playing()) idle();
}
Пример #22
0
void player_hit(unsigned char hp) {
  if (player_active.blink>0)
    return;
  if (player_active.hp > hp) {
    player_active.hp -= hp;
    play_sound(S_PLAYEREXPLOSION);
  }
  else {
    player_active.hp = 0;
    player_active.alive = PLAYER_DEAD;
    play_sound(S_GAMEOVER);
    gba_sprite_hide(&(player_active.sprite));
  }
  player_active.blink = PLAYER_BLINK_MAX;
  player_active.blinkcycle = PLAYER_BLINK_CYCLE*2;
}
Пример #23
0
static void
process_move3 (gint c)
{
  play_sound (SOUND_DROP);

  vstr[++moves] = '1' + c;
  vstr[moves + 1] = '0';

  check_game_state ();

  if (gameover) {
    score[winner]++;
    scorebox_update ();
    prompt_player ();
  } else {
    swap_player ();
    if (!is_player_human ()) {
      if (player == PLAYER1) {
	vstr[0] = vlevel[p.level[PLAYER1]];
      } else {
	vstr[0] = vlevel[p.level[PLAYER2]];
      }
      c = playgame (vstr, vboard) - 1;
      if (c < 0)
	gameover = TRUE;
      g_timeout_add (SPEED_DROP,
                     (GSourceFunc) next_move, GINT_TO_POINTER (c));
    }
  }
}
Пример #24
0
void
Player::grabdistros()
{
  /* Grab distros: */
  if (!dying)
    {
      World::current()->trygrabdistro(base.x, base.y, NO_BOUNCE);
      World::current()->trygrabdistro(base.x+ 31, base.y, NO_BOUNCE);

      World::current()->trygrabdistro(base.x, base.y + base.height, NO_BOUNCE);
      World::current()->trygrabdistro(base.x+ 31, base.y + base.height, NO_BOUNCE);

      if(size == BIG)
        {
          World::current()->trygrabdistro(base.x, base.y + base.height / 2, NO_BOUNCE);
          World::current()->trygrabdistro(base.x+ 31, base.y + base.height / 2, NO_BOUNCE);
        }

    }

  /* Enough distros for a One-up? */
  if (player_status.distros >= DISTROS_LIFEUP)
    {
      player_status.distros = player_status.distros - DISTROS_LIFEUP;
      if(player_status.lives < MAX_LIVES)
        ++player_status.lives;
      /*We want to hear the sound even, if MAX_LIVES is reached*/
      play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
    }
}
Пример #25
0
int TauFiend::handle_damage(SpaceLocation *source, int normal, int direct)
{
	STACKTRACE;
	double alpha;
	if (source->isLine()) {
		Vector2 dpos =
			min_delta(source->normal_pos() + ((SpaceLine*)source)->edge(), map_size);
		//double dx = min_delta(source->normal_x() + ((SpaceLine*)source)->edge_x(), normal_x(), X_MAX);
		//double dy = min_delta(source->normal_y() + ((SpaceLine*)source)->edge_y(), normal_y(), Y_MAX);
		//alpha = fabs(normalize(atan3(dy, dx) * 180 / PI - angle, 360));
		alpha = fabs(normalize(dpos.atan() - angle, PI2));
	}
	else alpha = normalize(trajectory_angle(source) - angle, 360);
	if (alpha > 180) alpha -= 360;
	alpha = (90 - fabs(alpha)) / 90;
	alpha *= alpha;
	alpha *= alpha;
	alpha = normal * (alpha + (1-alpha)*(tw_random(1.0)) );
	int d = normal;
	normal = (int)floor(alpha);
	if (alpha - normal >= 0.5) normal ++;
	d -= normal;
	if (d > 0)
		play_sound(data->sampleExtra[random(8)]);
	return Ship::handle_damage(source, normal, direct);
}
Пример #26
0
void
Player::kill(HurtMode mode)
{
  play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);

  physic.set_velocity_x(0);

  if (mode == SHRINK && size == BIG)
    {
      if (got_coffee)
        {
          got_coffee = false;
        }
      else
        {
          size = SMALL;
          base.height = 32;
          duck = false;
        }
      safe_timer.start(TUX_SAFE_TIME);
    }
  else
    {
      physic.enable_gravity(true);
      physic.set_acceleration(0, 0);
      physic.set_velocity(0, 7);
      if(dying != DYING_SQUISHED)
      --player_status.lives;
      dying = DYING_SQUISHED;
    }
}
Пример #27
0
/* Bounce a brick: */
void bumpbrick(float x, float y)
{
  World::current()->add_bouncy_brick(((int)(x + 1) / 32) * 32,
                         (int)(y / 32) * 32);

  play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
}
Пример #28
0
void Dodger::dead()
{
    static int death_anim = 0;

    if (death_anim == 0) {
        play_sound(sounds.dead);
        life_count--;
        score_panel.set_num_lives(life_count);
    }

    if (death_anim == death_anim_length) {
        death_anim = 0;
        if (life_count > 0) {
            // update the texture where the dodger died with whatever is on the grid
            sprites[player_line][player_col].setTexture(
                    textures.cell[level.data[player_line][player_col]]);
            new_life();
            game_state = playing;
        } else {
            game_state = game_over;
        }
    } else {
        sprites[player_line][player_col].setTexture(textures.death[death_anim]);
        death_anim++;
    }
}
Пример #29
0
void
BadGuy::kill_me(int score)
{
  if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
    return;

  dying = DYING_FALLING;
  if(kind == BAD_MRICEBLOCK) {
    set_sprite(img_mriceblock_falling_left, img_mriceblock_falling_right);
    if(mode == HELD) {
      mode = NORMAL;
      Player& tux = *World::current()->get_tux();  
      tux.holding_something = false;
    }
  }
  
  physic.enable_gravity(true);

  /* Gain some points: */
    World::current()->add_score(base.x - scroll_x, base.y,
                    score * player_status.score_multiplier);

  /* Play death sound: */
  play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
}
Пример #30
0
// -------------------------------------------------------------------
// smoke cloud
// -------------------------------------------------------------------
void t_summon_smoke::impact( t_combat_creature_ptr caster, t_map_point_2d square )
{
	t_combat_actor_ptr		 cloud;
	t_combat_actor_model_ptr model;
	t_map_point_3d			 target_point;
	t_battlefield&			 battlefield = m_battlefield;
	t_handler				 handler;
	static t_combat_actor_model_cache_set	k_model( "spells.smoke" );
	t_map_point_2d							origin;
	int										footprint_size = get_footprint_size();
	int										half_footprint = (footprint_size - 1) / 2;
	t_combat_action_message					message( *caster, get_action_text( false ) );
	t_spell_actor_animation_ptr				animation;

	model = k_model.get( battlefield.get_model_scale() );


	origin = m_target_square;
	origin.row -= half_footprint;
	origin.column -= half_footprint;
	cloud = new t_unsaved_combat_actor( &m_battlefield, model, k_combat_actor_action_cast_spell, 
		                        k_direction_northeast );
	if (battlefield.off_map( *cloud, origin ))
		return;
	handler = bound_handler( *this, &t_summon_smoke::place_smoke );
	battlefield.place_object( cloud, origin << k_battlefield_subcell_shift );

	animation = new t_spell_actor_animation( m_battlefield, *cloud, this, handler );
	animation->display_action_message( message );

	cloud->set_animation( animation );
	play_sound();
}