Example #1
0
//Sounds
void ce_game::playSounds(){

	//Walk sound if not already playing
	if ((key[KEY_A] || key[KEY_D] || key[KEY_LEFT] || key[KEY_RIGHT]) && (player->isWalkingLeft || player->isWalkingRight) && !jumpSound){
		if (!walkSound){
			walkSound = true;
			play_sample(walk,255,128,1000,10000);
		}
	}else{
		walkSound = false;
		stop_sample(walk);
	}

	//Ladder sound if not already playing
	if ((key[KEY_W] || key[KEY_S] || key[KEY_UP] || key[KEY_DOWN]) && player->isClimbing && !jumpSound){
		if (!ladderSound){
			ladderSound = true;
			play_sample(ladder,255,128,1000,10000);
		}
	}else{
		ladderSound = false;
		stop_sample(ladder);
	}

	//Jump sound if not already playing
	if (player->isJumping){
		if (!jumpSound){
			jumpSound = true;
			play_sample(jump,255,128,1000,10000);
		}
	}else{
		jumpSound = false;
		stop_sample(jump);
	}
}
PlayerComponent::PlayerComponent() : Component( "PlayerComponent" )
{
  angelCounter = 200;
  xVel = yVel = 0.0;
  gravity = 0.2;
  speed = 2.5;
  angel = false;
  state = "idle";

  startX = 1717.5;
  startY = 732.5;

  windVol = 64.0;
  windPan = 128.0;
  windFreq = 300.0;

  transformCounter = 0;
  flapCounter = 0;
  deathCounter = -1;

  wind2 = load_sample( "data/sfx/wind.wav" );
  wind = load_sample( "data/sfx/wind.wav" );
  die = load_sample( "data/sfx/wind.wav" );
  play_sample( wind, windVol, windPan, windFreq, 1 );
  play_sample( wind2, windVol/1.5, 200, windFreq/2.13, 1 );
}
Example #3
0
void
sample_random_loose_floor (int room)
{
  switch (prandom (2)) {
  case 0: play_sample (loose_floor_00_sample, room);
  case 1: play_sample (loose_floor_01_sample, room);
  case 2: play_sample (loose_floor_02_sample, room);
  }
}
Example #4
0
static bool
flow (struct anim *k)
{
  struct coord nc; struct pos np, pm, ptf;

  if (k->oaction != kid_jump)
    k->i = -1, k->misstep = k->hang = false;

  bool hang_front = ((k->f.dir == LEFT) ? k->key.left : k->key.right)
    && ! k->key.up && k->key.shift;

  bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left)
    && ! k->key.up && k->key.shift;

  int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT;

  /* hang front */
  survey (_m, pos, &k->f, &nc, &pm, &np);
  survey (_tf, pos, &k->f, &nc, &ptf, &np);
  if (k->i >= 8 && k->i <= 10 && hang_front
      && (is_hangable_pos (&pm, k->f.dir)
          || is_hangable_pos (&ptf, k->f.dir))) {
    if (is_hangable_pos (&pm, k->f.dir)) k->hang_pos = pm;
    else if (is_hangable_pos (&ptf, k->f.dir)) k->hang_pos = ptf;
    pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos);
    k->hang = true;
    play_sample (hang_on_fall_sample, k->f.c.room);
    kid_hang (k);
    return false;
  }

  /* hang back */
  survey (_tf, pos, &k->f, &nc, &ptf, &np);
  if (k->i >= 8 && k->i <= 10
      && hang_back && is_hangable_pos (&ptf, back_dir)) {
    k->hang_pos = ptf;
    pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos);
    k->hang = true;
    play_sample (hang_on_fall_sample, k->f.c.room);
    kid_turn (k);
    return false;
  }

  if (k->i == 17) {
    kid_normal (k);
    return false;
  }

  select_frame (k, kid_jump_frameset, k->i + 1);

  if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +2;
  if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +6;
  if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +4;
  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +0;

  return true;
}
Example #5
0
void HitZombie(Zombie** a, int damage)
{
    (*a)->hp -= damage;
    play_sample(zombieHit,fxVol-10,((*a)->position.x/Resolution.x)*255,1000,0);
    if((*a)->hp <= 0)
    {
        play_sample(zombieDead,fxVol+10,((*a)->position.x/Resolution.x)*255,1000,0);
        KillZombie(&(*a), 1);
    }
}
Example #6
0
bool VerifCollision(struct Cobra *snake, struct Comida *comidas, int x, int y, int *xx, int *yy, int tamCobra, int *tipoCol, int *ptsComida, int *tamComida){
		 
		 //Colisão com o corpo
		 for (int i = 0;i < tamCobra;i++){
	   		if ( x >= snake[i].x && x <= snake[i].x+18 && y >= snake[i].y && y <= snake[i].y+18){				 
			   	*xx =  snake[i].x;
			   	*yy = snake[i].y;
			   *tipoCol = 1; 
		    }
		}
		
		//Colisão com obstáculos
			if(x > 740){
				 x=20; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			if(x < 20){
				 x=760; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			if(y > 540){
				 y=20; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
 			 }
			if(y < 20){
				 y=560; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			
		//Colisão com comidas
		for(int i = 0;i<10;i++){
		    if(comidas[i].visible){
				if(x >= comidas[i].x && x <= comidas[i].x+19 && y >= comidas[i].y && y <= comidas[i].y+19){
					 comidas[i].visible = false;
					 play_sample(snakeBit,255,90,1000,0);  						 
					 play_sample(comidas[i].spDie,255,90,1000,0);  				
					 *tamComida = comidas[i].taman;
					 *ptsComida = comidas[i].ponto;
					 *tipoCol = 3;
				}		
            }
		}
		
		
	return true;	
}
Example #7
0
void
guard_die_spiked (struct anim *g)
{
  if (con (&g->p)->fg != SPIKES_FLOOR) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_spiked;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  if (g->oaction != guard_die_spiked) {
    g->splash = true;
    g->death_reason = SPIKES_DEATH;

    assert (con (&g->p)->fg == SPIKES_FLOOR);
    struct spikes_floor *s = spikes_floor_at_pos (&g->p);
    s->i = 4;
    s->state = 5;
    s->inactive = true;
    s->murdered_anim = g->id;

    if (g->type == SKELETON)
      play_sample (skeleton_sample, NULL, g->id);
    else play_sample (spiked_sample, NULL, g->id);

    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }
    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;

  int dy;
  if (g->type == SKELETON) dy = +45;
  else dy = (g->f.dir == LEFT) ? +32 : +31;

  ALLEGRO_BITMAP *bitmap = get_guard_die_spiked_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap,
               &g->p, (g->f.dir == LEFT) ? +8 : +9, dy);

  g->xf.b = NULL;
}
Example #8
0
void ce_player::actorPick(ce_actor *actor){

	//Incriment score and remove actor from screen
	score += actor->points;
	actor->visible = false;

	//Play sound
	if (actor->type == cet_grain){
		play_sample(pick_grain,255,128,1000,0);
	}else if (actor->type == cet_egg){
		play_sample(pick_egg,255,128,1000,0);
	}
}
// Update
void key_manager::update(){
  // Pressing them keys
  // You haven't won
  if(!switch_flicked){
    // Got a correct letter
    if((key_queue.size() > 0) && (!joystick_enabled && key[key_queue.at(0).getValue()] && keyIsPressed == false) || (joystick_enabled && joy[0].button[key_queue.at(0).getValue()].b && buttonIsPressed == false)){
      // Nice sound
      play_sample( sounds[1],255,125,1000,0);
      key_queue.erase( key_queue.begin());

      // Add key to queue
      if( joystick_enabled){
        key_data newKey(random(0,3));
        key_queue.push_back(newKey);
      }
      else{
        key_data newKey(random(KEY_LEFT, KEY_DOWN));
        key_queue.push_back(newKey);
      }

      // Increase speed
      if( stair::scrollSpeed < stair::maxScrollSpeed)
        stair::scrollSpeed += 0.8;
    }
    else if( (keyDown() && keyIsPressed == false) || (buttonDown() && buttonIsPressed == false)){
      if(stair::scrollSpeed > 0)
        stair::scrollSpeed /= 4;
      play_sample(sounds[0],255,125,1000,0);
    }
  }
  // Stop
  else{
    stair::scrollSpeed = 0;
  }

  // Prevents held keys
  if(!joystick_enabled){
    keyIsPressed = keyDown();
  }
  if(joystick_enabled){
    buttonIsPressed = buttonDown();
  }

  // Slow stairs down
  if( stair::scrollSpeed > 0.01)
    stair::scrollSpeed -= 0.02;
  else{
    stair::scrollSpeed = 0;
  }
}
Example #10
0
static void
physics_out (struct anim *k)
{
  /* depressible floors */
  if (k->i == 2) update_depressible_floor (k, -7, -13);
  else if (k->i == 5) update_depressible_floor (k, -5, -30);
  else if (k->i == 6) update_depressible_floor (k, -4, -11);
  else keep_depressible_floor (k);

  /* sound */
  if (k->oaction == kid_run_jump)
    play_sample (step_sample, k->f.c.room);
  if (k->i == 2 || k->i == 6)
    play_sample (step_sample, k->f.c.room);
}
Example #11
0
void ce_game::end_game(){
	isPlaying = false;

	//Stop sounds
	stop_sample(walk);
	stop_sample(jump);
	stop_sample(ladder);

	//Play ending sound
	if (hasWon){
		play_sample(win,255,128,1000,0);
	}else{
		play_sample(death,255,128,1000,0);
	}
}
Example #12
0
static inline void tur_do_laser(game_data_t *gd, turret_t *turret)
{
	
	/* shoot something? */
	turret->laser_fire = 0;
	if (turret->target_monster != NULL) {

		if ((fixtoi(turret->angle) == fixtoi(turret->desired_angle)) && tur_target_within_range(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16)) {
			if (tur_target_within_sight(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16) == 1) {
				if (turret->fire_reset_count == 0) {
					turret->fire_reset_count = 1;
					turret->laser_fire = 1;
					
					stop_sample(gd->samples->gun_laser);
					play_sample(gd->samples->gun_laser, 255, 128, 1000, 0);
					
					/* register damage */
					monster_register_hit(turret->target_monster, 0.5);
				}
			}
		}

	}
	
	if (turret->fire_reset_count > 0)
		turret->fire_reset_count--;
		

	tur_rotate(turret);
	tur_target(turret);

}
Example #13
0
void move_bullets(void)
{
   BULLET *bullet = bullet_list;
   while (bullet) {
      bullet->y -= BULLET_SPEED;

      /* if the bullet is at the top of the screen, delete it */
      if (bullet->y < 8) {
         bullet = delete_bullet(bullet);
         goto bullet_updated;
      }
      else {

         /* shot an asteroid? */
         if (asteroid_collision(bullet->x, bullet->y, 20)) {
            score += 10;
            play_sample(data[BOOM_SPL].dat, 255, PAN(bullet->x), 1000, FALSE);
            /* delete the bullet that killed the alien */
            bullet = delete_bullet(bullet);
            goto bullet_updated;
         }
      }

      bullet = bullet->next;

      bullet_updated:;
   }
}
Example #14
0
void eof_mix_play_note(int note)
{
	if((note < EOF_MAX_VOCAL_TONES) && eof_sound_note[note])
	{
		(void) play_sample(eof_sound_note[note], 255.0 * (eof_tone_volume / 100.0), 127, 1000 + eof_audio_fine_tune, 0);	//Play the tone at the user specified cue volume
	}
}
Example #15
0
int makeSlider(slider_t *theSlider)
{
  SAMPLE *slideNoise = makeSample("Menu_Sounds/SliderNoise.wav");
	BITMAP *bar = makeBitmap("Menu_Images/Slider.bmp");

	if (mouse_b && menu_mouseIsOverSlider(theSlider))
	{
			theSlider->position += (mouse_x - theSlider->position)/ 4;
            stop_sample(slideNoise);
            play_sample(slideNoise, 155, 0, 1000, 0);
	}
	draw_sprite(menuBuffer, bar, theSlider->position - 10, theSlider->top + 5);

    theSlider->current = (int)(((theSlider->position - theSlider->left) * theSlider->values)/theSlider->width) + 1;

    if (theSlider->current > theSlider->values)
    {
       theSlider->current = theSlider->values;
    }
    else if (theSlider->current < 1)
    {
       theSlider->current = 1;
    }
	return (theSlider->current);
}
void Basic_char::CollideWithBubble( Bubble * bubble, int scrnwdth, int scrnhght, DATAFILE * pop ) // CHECK FOR COLLISION WITH THE SMALL BUBBLE
{

    if( alive )
    {

    int distance = 0;

    int margin_x = bubble -> GetX() - x;
    int margin_y = bubble -> GetY() - y;

	// THE MARGIN SHOULD BE POSITIVE
    if( margin_x < 0 )
    margin_x *= -1;
    if( margin_y < 0 )
    margin_y *= -1;

    distance = sqrt( pow( margin_x, 2 ) + pow( margin_y, 2 ) ); // THE DISTANCE BETWEEN THE CENTRES OF THE PLAYER AND THE BUBBLE 

	// IF THE DISTANCE BETWEEN THEIR CENTRES IS SMALLER THAN THE SUM OF THEIR RADII THERE IS A COLLISION
    if( distance < 16 + 32 + bubbles_collected*10 )
    {
        bubble -> Respawn( scrnwdth, scrnhght );
        bubbles_collected++;
        play_sample( (SAMPLE*)pop[0].dat, 255, 128, 1000, 0 );
    }

    }

}
Example #17
0
void comet::logic(int newMotion){
  x -= newMotion * 2;

  if(collision(x, x + width , robot_x, robot_x + robotWidth, y, y + height, robot_y, robot_y + robotHeight) && !isDead){
    if(!invincible){
      health -= 3;
      screenshake+=20;
    }
    if(sound && !invincible){
      play_sample(soundEffect,255,125,1000,0);
    }
  }

  if(isDead){
    if( particles_on){
    	//Update particles
	    for( int i = 0; i < debris.size(); i++){
	      debris.at(i).logic();
	      debris.at(i).x -= newMotion;
	    }
	  }
  }
  else{
    //Check for death
    dead();
  }
}
Example #18
0
static inline void tur_do_gun(game_data_t *gd, turret_t *turret)
{
	
	/* shoot something? */
	if (turret->target_monster != NULL) {
		if ((fixtoi(turret->angle) == fixtoi(turret->desired_angle)) && tur_target_within_range(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16)) {
			if (tur_target_within_sight(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16) == 1) {
				if (turret->fire_reset_count == 0) {
					turret->fire_reset_count = 100 / turret->fire_rate;
					bullet_add_bullet(turret, turret->target_monster, tur_get_distance(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16));	
					
					play_sample(gd->samples->gun_gun, 180, 128, 1000, 0);
					
				}
			}
		}
	}
	
	if (turret->fire_reset_count > 0)
		turret->fire_reset_count--;
		
	tur_rotate(turret);
	tur_target(turret);
				
}
Example #19
0
int MYWAVE::play() {
    voice = play_sample(wave, vol, panning, 1000, repeat);

    _playing = true;

    return 1;
}
Example #20
0
void update_mouse_hover(GUI *G)
{
	if(last_hover != G && G != NULL)
	{
		play_sample(highlight_sound, config[CFG_SFX_VOLUME], 128, 1000, 0);
	}
	last_hover = G;

	if(!info_label)
		return;
	if(!G)
		strcpy(info_label->text, "Membrane Massacre v2.0  Copyright (c) 2006-2007");
	else if(!strcmp(G->text,"Resume Game"))
		strcpy(info_label->text, "Continue your journey onward!");
	else if(!strcmp(G->text,"New Game"))
		strcpy(info_label->text, "Begin a new game in 'story' mode");
	else if(!strcmp(G->text,"Survival Mode"))
		strcpy(info_label->text, "Survive against hordes of cells to gain new ships and more..");
	else if(!strcmp(G->text,"Game Options"))
		strcpy(info_label->text, "Configure controls, graphics settings, and difficulty");
	else if(!strcmp(G->text,"Credits"))
		strcpy(info_label->text, "The fine folks who made Membrane Massacre possible");
	else if(!strcmp(G->text,"Exit"))
		strcpy(info_label->text, "Don't even THINK about it!");
}
Example #21
0
void loser(){

	SAMPLE *som;
   	som = load_sample("loser.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
Example #22
0
void escnave(){

	SAMPLE *som;
   	som = load_sample("affair.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
Example #23
0
void abertura(){

	SAMPLE *som;
   	som = load_sample("Abertura1.wav");
   	play_sample(som, 255, 128, 1000, FALSE);
   	
}
Example #24
0
void expl(){

	SAMPLE *som;
   	som = load_sample("boom.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
//move a tile to the blank space (if it's next to it)
void TileShop::moveTile(int mx, int my)
{
    Tile temp;
    int amount;
    int x = mx / 128;
    int y = my / 128;
    int indexClicked = x + 4 * y;

    if (indexClicked % 4 != 3 && tiles[indexClicked + 1].number == 0)
        amount = 1;

     else if (indexClicked % 4 != 0 && tiles[indexClicked -1].number == 0)
        amount = -1;

     else if (indexClicked > 3 && tiles[indexClicked - 4].number == 0)
        amount = -4;

     else if (indexClicked < 12 && tiles[indexClicked + 4].number == 0)
         amount = 4;

     else
        amount = 0;
    if (amount != 0)
    {
        temp = tiles[indexClicked];
        tiles[indexClicked] = tiles[indexClicked + amount];
        tiles[indexClicked + amount] = temp;
        play_sample(click, 200, 128, 1000,false );
        moves++;
    }


}
Example #26
0
void playerLose()
{

     
    SAMPLE *death = load_sample("Death.wav");
     
 
     BITMAP *loseBackground = NULL;
     loseBackground = load_bitmap("Spider Victor 3D.bmp", NULL); 
     BITMAP *explosion = NULL;
     explosion = load_bitmap("Explosion.bmp", NULL);
     BITMAP *spider = NULL;
     spider = load_bitmap("Spider1.bmp", NULL); 
     
     
  
     playerIsDead = 1;
     clear_bitmap(buffer);
     draw_sprite(buffer, loseBackground, 0, 0);     
     draw_sprite(buffer, explosion, turretX - 20, turretY - 20);
     draw_sprite(buffer, spider, spiderX[j], spiderY[j]);
     currentImage = 2;
     play_sample(death, 255, 0, 500, 0);
     return;
     
     


     
}
Example #27
0
void reverseVerticalDirection() /* reverse the ball’s up-down direction */
{
   if ( ( direction % 2 ) == 0 ) /* "down" directions are even numbers */
      ++direction; /* make the ball start moving up */
   else /* "up" directions are odd numbers */
      --direction; /* make the ball start moving down */
   play_sample( boing, 255, 128, 1000, 0 ); /* play "boing" sound once */
} /* end function reverseVerticalDirection */
Example #28
0
void active_crazy_alarm()
{
  play_sample(datafile[SAMP_ALARM].dat, 255, 128, 1000, TRUE);
  alarm_crazy_time = 0;
  alarm_crazy_switch = 0;
  alarm_time_blue = 0;
  alarm_time_red = -1;
}
Example #29
0
void active_red_alarm(int msec)
{
  if (alarm_crazy_time < 0) {
    alarm_time_red = 0;
    alarm_msec_red = msec;
    play_sample(datafile[SAMP_ALARM].dat, 64, 128, 1000, FALSE);
  }
}
Example #30
0
		void Play_SFX(unsigned char i)
		{
			#ifdef DEBUG
				fprintf(stderr, "Play sound effect %d loaded in memory\n", i);
			#endif
			
			play_sample(sfx_id[i], 128, 128, 1000, 0);
		}