elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Audio en allegro
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Audio en allegro  (Leído 1,266 veces)
AlvaroGPE

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Audio en allegro
« en: 2 Junio 2019, 20:23 pm »

Hola, estoy diseñando un videojuego en allegro y hasta ahora todo corre perfectamente pero tengo un problema con la musica de fondo.

Al estar tecleando para controlar el personaje la musica de repente se deja de reproducir, solo al estar controlando el personaje, si no muevo el personaje entonces todo esta bien.

Como puedo solucionar este problema??

dejo el código que estoy diseñando gracias.

#include <allegro.h>
#define ancho 1280
#define alto 720

using namespace std;

int main()
{
    int x=-593, y=0, z=80, up=0, pos=0, fx=0, sx=0, s=0;
    allegro_init();
   install_keyboard();
   set_volume(230, 200);

    if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL)!=0)
        {
            allegro_message("Error: inicializando sistema de sonido\n%s\n", allegro_error);
            return 1;
        }

   set_color_depth(32);
   set_gfx_mode(GFX_AUTODETECT_WINDOWED, ancho, alto, 0, 0);

    BITMAP *cargando = load_bitmap("cargando.bmp", NULL);
    draw_sprite(screen,cargando,0,0);
    SAMPLE *soundstart = load_wav("soundstart.wav");
    play_sample(soundstart,200,150,1000,0);
    SAMPLE *soundjump = load_wav("soundjump.wav");
   BITMAP *buffer = create_bitmap(ancho,alto);
    BITMAP *fondo1 = load_bitmap("fondo1.bmp", NULL);
    BITMAP *choque = load_bmp("fondolim.bmp",NULL);
    BITMAP *skin1 = load_bitmap("skin1.bmp", NULL);
    BITMAP *skin2 = load_bitmap("skin2.bmp", NULL);
    SAMPLE *soundtrack=load_wav("soundtrack.wav");
    stop_sample(soundstart);
    play_sample(soundtrack,200,150,1000,0);
    clear_to_color(buffer, 0xaaaaaa);
    blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
    masked_blit(skin1, buffer, 89, 0, 0, 570-y, 89, 140);
    blit(buffer, screen, 0, 0, 0, 0, 1280, 720);


    while (!key[KEY_ESC])
    {
        //control de animación
        if (x%15==0){s=s+89;}
        if (s==356) {s=0;}
        if (x>0) {fx=x; sx=0;}
        else {fx=0; sx=x;}

        //control en y
        if ((key[KEY_W]||key[KEY_SPACE]||key[KEY_UP])&&up==0&&y==z-80){play_sample(soundjump,100,100,500,0); up=1;}
        if (y==z){up=0;}
        if (up==1){y++;}
        else {if (y>z-80){y--;}}
        if (getpixel( choque, 650+x, 710-y) == 0x0000ff) {z=y+80;}
        else {if (z>80){z--;}}

        //control en x
        if (key[KEY_D]||key[KEY_RIGHT])
            {
                pos=0;
                if (getpixel( choque, 662+x, 710-y) != 0xff0000){x++;}
            }
        if (key[KEY_A]||key[KEY_LEFT])
            {
                pos=1;
                if (getpixel( choque, 658+x, 710-y) != 0xff0000){x--;}
            }

        //control de movimiento
        if (pos==0)
            {
                if (up==0)
                    {
                        if (y>z-80)
                            {
                                blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                masked_blit(skin1, buffer, 363, 0, 598+sx, 570-y, 93, 140);
                            }
                        else
                            {
                                if (key[KEY_D]||key[KEY_RIGHT])
                                    {
                                        blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                        masked_blit(skin1, buffer, s, 0, 598+sx, 570-y, 89, 140);
                                    }
                                else
                                {
                                    blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                    masked_blit(skin1, buffer, 89, 0, 598+sx, 570-y, 89, 140);
                                }
                            }
                    }
                if (up==1)
                    {
                        blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                        masked_blit(skin1, buffer, 466, 0, 598+sx, 570-y, 93, 140);
                    }
            }
        if (pos==1)
            {
                if (up==0)
                    {
                        if (y>z-80)
                            {
                                blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                masked_blit(skin2, buffer, 365, 0, 598+sx, 570-y, 93, 140);
                            }
                        else
                            {
                                if (key[KEY_A]||key[KEY_LEFT])
                                    {
                                        blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                        masked_blit(skin2, buffer, s, 0, 598+sx, 570-y, 89, 140);
                                    }
                                else
                                {
                                    blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                                    masked_blit(skin2, buffer, 89, 0, 598+sx, 570-y, 89, 140);
                                }
                            }
                    }
                if (up==1)
                    {
                        blit(fondo1, buffer, fx, 0, 0, 0, 1280, 720);
                        masked_blit(skin2, buffer, 469, 0, 598+sx, 570-y, 93, 140);
                    }
            }
        //control de imagen
        blit(buffer, screen, 0, 0, 0, 0, 1280, 720);
    }

    destroy_bitmap(buffer);
    destroy_sample(soundstart);
    destroy_sample(soundtrack);
    destroy_sample(soundjump);

    return 0;
}
END_OF_MAIN();


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
problemas de audio en codeblock usando allegro
Programación C/C++
Software Download 1 2,138 Último mensaje 25 Mayo 2012, 18:18 pm
por Software Download
Allegro
Programación C/C++
josevc 5 2,852 Último mensaje 29 Mayo 2019, 01:50 am
por AlvaroGPE
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines