Hola amigos soy nuevo en esto de Allegro tengo un problema, genero un numero aleatorio antes de iniciar allegro y todo marcha bn, pero cuando este numero entra ya con allegro iniciado el valor de esta variable cambia muchisimo y no c q pasa.
----Main----
#include <iostream>
using namespace std;
int dados(int &da);
int main(){
int d1,d2,dadoT;
srand (time (NULL));
d1 = 1 + rand() % 6;
d2 = 1 + rand() % 6;
dadoT = d1 + d2;
cout << d1 << endl;
cout << d2 << endl;
cout << dadoT << endl;
system("pause");
dados();
}
----Inicio de allegro IniAllegro.cpp----
#include <allegro.h>
void IniAllegro(){
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT,1024,768,0,0);
}
----Dado.cpp----
#include <iostream>
#include <cstdlib>
#include <allegro.h>
using namespace std;
//Procedimietos
int IniAllegro();
int dados();
int Movimiento(int &movJugador1);
BITMAP *dado1, *dado2, *dado3, *dado4, *dado5, *dado6, *Tablero, *buffer, *ficha1;
PALETTE paleta;
int d1, d2, dadoT;
int posX1=55;
int dados (int &da1, &da2){
IniAllegro();
dado1 = load_bitmap("dado1.bmp",paleta);
dado2 = load_bitmap("dado2.bmp",paleta);
dado3 = load_bitmap("dado3.bmp",paleta);
dado4 = load_bitmap("dado4.bmp",paleta);
dado5 = load_bitmap("dado5.bmp",paleta);
dado6 = load_bitmap("dado6.bmp",paleta);
set_palette(paleta);
Tablero=load_bitmap("Tablero.bmp",NULL);
buffer=load_bitmap("Tablero.bmp",NULL);
acquire_screen();
draw_sprite(screen,Tablero,0,0);
while (!key[KEY_SPACE]){
draw_sprite(screen,dado1,442,339);
draw_sprite(screen,dado2,442,339);
draw_sprite(screen,dado3,442,339);
draw_sprite(screen,dado4,442,339);
draw_sprite(screen,dado5,442,339);
draw_sprite(screen,dado6,442,339);
draw_sprite(screen,dado1,522,339);
draw_sprite(screen,dado2,522,339);
draw_sprite(screen,dado3,522,339);
draw_sprite(screen,dado4,522,339);
draw_sprite(screen,dado5,522,339);
draw_sprite(screen,dado6,522,339);
}
switch (da1){
case 1:
draw_sprite(screen,dado1,442,339);
break;
case 2:
draw_sprite(screen,dado2,442,339);
break;
case 3:
draw_sprite(screen,dado3,442,339);
break;
case 4:
draw_sprite(screen,dado4,442,339);
break;
case 5:
draw_sprite(screen,dado5,442,339);
break;
case 6:
draw_sprite(screen,dado6,442,339);
}
switch (da2){
case 1:
draw_sprite(screen,dado1,522,339);
break;
case 2:
draw_sprite(screen,dado2,522,339);
break;
case 3:
draw_sprite(screen,dado3,522,339);
break;
case 4:
draw_sprite(screen,dado4,522,339);
break;
case 5:
draw_sprite(screen,dado5,522,339);
break;
case 6:
draw_sprite(screen,dado6,522,339);
}
Movimiento(dadoT);
}
//-----------------------------------------------------------------------------------------------//
---Movimiento.cpp----
int Movimiento(int &movJugador1){
int mov,movi;
mov= movJugador1+movi;
movi=mov;
ficha1=load_bitmap("ficha1.pcx",NULL);
//draw_sprite(screen,ficha1,55,650);
switch (movi){
case 1:
draw_sprite(screen,ficha1,posX1,520);
textout_ex(screen,font,"HUEHUETENANGO",318,314,makecol(255,0,0),makecol(131,202,238));
break;
case 2:
draw_sprite(screen,ficha1,posX1,435);
textout_ex(screen,font,"QUETZALTENANGO",200,250,makecol(255,0,0),makecol(131,202,238));
break;
case 3:
draw_sprite(screen,ficha1,posX1,350);
textout_ex(screen,font,"ALTA VERAPAZ",200,260,makecol(255,0,0),makecol(131,202,238));
break;
case 4:
draw_sprite(screen,ficha1,posX1,265);
textout_ex(screen,font,"AVIAGUAT",200,270,makecol(255,0,0),makecol(131,202,238));
break;
case 5:
draw_sprite(screen,ficha1,posX1,180);
textout_ex(screen,font,"INDE",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 6:
draw_sprite(screen,ficha1,posX1,85);
textout_ex(screen,font,"CARCEL",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 7:
draw_sprite(screen,ficha1,180,85);
textout_ex(screen,font,"QUICHE",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 8:
draw_sprite(screen,ficha1,265,85);
textout_ex(screen,font,"IZABAL",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 9:
draw_sprite(screen,ficha1,350,85);
textout_ex(screen,font,"CHIMALTENANGO",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 10:
draw_sprite(screen,ficha1,350,200);
textout_ex(screen,font,"PETEN",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 11:
draw_sprite(screen,ficha1,440,200);
textout_ex(screen,font,"EL PROGRESO",150,250,makecol(255,0,0),makecol(131,202,238));
break;
case 12:
draw_sprite(screen,ficha1,525,200);
textout_ex(screen,font,"FEGUA",150,250,makecol(255,0,0),makecol(131,202,238));
break;
default:
textout_ex(screen,font,"Chorrio si Dio jajaja",150,300,makecol(255,0,0),makecol(131,202,238));
break;
}
//dados();
while (!key[KEY_ESC]){
textout_ex(screen, font, "Presione ESC para terminar", 400, 120, makecol(255, 255, 255), -1);
}
allegro_exit();
cout << movi <<endl;
system("pause");
}