| Ver tema anterior :: Ver siguiente tema | | Autor | Mensaje |
|---|
gui2485_kawakx
Registrado: 22 Ene 2006 Mensajes: 59 Ubicación: Korn, Bs As, Argentina.
| Publicado: 25/02/2007 5:18 am | | | Título: Me podrian decir porque no funciona esto?...Graph... |
| Resulta que ayer se me ocurrio como hacer el juego que tenes q hacer lineas de a 4 en el tablero, lo iba a hacer simplemente con la CRT pero por cuestiones de aprender mas se me ocurrio investigar la libreria grafica de pascal.
Ya relativamente la domino pero tengo un problema con las funciones de la crt, no se que pasa, no funcionan ni readkey ni keypressed y todo eso y no tengo otra forma de ingresar datos por teclado porque graph no tiene rutinas para eso....
eh visto varios ejemplos y las utilizan a readkey pero a mi me compila y todo, aprieto una tecla y no pasa nada.... alguien sabria porque es? desde ya gracias.
Dejo el code
| Cita: |
Program InterGraf01;
Uses CRT,SysUtils,Graph;
Const //Colores Black=0;Blue=1;Green=2;Cyan=3;Red=4;Magenta=5;Brown=6;LightGray=7; DarkGray=8;LightBlue=9;LightGreen=10;LightCyan=11;LightRed= 12; LightMagenta=13;Yellow=14;White=15;
//Ventanas LongVentana = 475; AnchoVentanaDerecha = 630;
//Rangos; Ancho = 7; Alto = 8;
//Otros RadioFichasX= 17; RadioFichasY= 17;
Type TFicha=Char;
TJugador = Record Nick:String; Jugadas:Integer; End;
//Matriz de juego; TTablero = Array[1..Ancho,1..Alto] Of TFicha;
//Variables Globales; Var gd,gm:SmallInt; //Manejador Grafico y Manejador de color respectivamente; Tablero:TTablero; Win:Boolean; Player01,Player02:TJugador; car:CHar; //------------------------------------------------------------------------------ Procedure InicializarModoGrafico;
Begin gm:=Detect; //tmb podemos usar gm:=Detect; gd:=Detect; // //tmb podemos usar gm:=Detect;
{gm:=vgahi; //tmb podemos usar gm:=Detect; gd:=vga; // //tmb podemos usar gm:=Detect; }
InitGraph(gd,gm,''); if GraphResult <> grOk then begin Writeln('Driver ',gd,' Modo Grafico ',gm,' No Soportado'); Halt(1); end;
End;
//------------------------------------------------------------------------------
Procedure InicializarTablero(Var Tablero:TTablero);
Var i,j:Integer;
Begin
For i:=1 To Ancho Do For j:=1 To Alto Do Tablero[i,j]:= '0';
End;
//------------------------------------------------------------------------------ Procedure Ambiente;
Var Vent01Activa,Vent02Activa:Boolean;
Begin
//Dibujamos Ventana de la izquierda; Setviewport(5,5,220,LongVentana,Vent01Activa); SetFillStyle(1,Brown); Bar(5,5,220,LongVentana); SetFillStyle(1,Black); Bar(15,15,205,LongVentana-10);
//Coloco titulos en ventana izquierda; SetTextStyle(2,0,2);
//Dibujo VEntana Derecha; Setviewport(230,5,AnchoVentanaDerecha,LongVentana,Vent02Activa); //Dibujamos Ventana de la izquierda; SetFillStyle(1,Brown); Bar(0,5,400,LongVentana); SetFillStyle(1,Black); Bar(10,15,390,LongVentana-10);
ENd;
//------------------------------------------------------------------------------ Procedure DibujarTablero(Tablero:TTablero);
Var i,j,XActual,YActual:Integer;
Begin
//Creo El Rectangulo Azul: SetColor(White); SetFillStyle(1,Blue); Bar(30,380,370,20);
//Rotulo del fichero; SetFillStyle(0,Black); Bar(40,50,360,30); SetTextStyle(2,0,1); OutTextXY(45,35,'1 2 3 4 5 6 7 8');
//INicializo Variables; XActual:=60; YActual:=80;
//Tablero[1,2]:='1'; //Tablero[6,4]:='2';
For i:=1 To Ancho Do
Begin For j:=1 To Alto Do Begin
Case (Tablero[i,j]) Of '0':Begin SetColor(White); SetFillStyle(0,Black); FillEllipse(XActual,YActual,RadioFichasX,RadioFichasY); End; '1': Begin SetColor(White); SetFillStyle(1,Red); FillEllipse(XActual,YActual,RadioFichasX,RadioFichasY); End; '2':Begin SetColor(White); SetFillStyle(1,Yellow); FillEllipse(XActual,YActual,RadioFichasX,RadioFichasY); End; End;
XActual:=XActual + 40;
End;
XActual:=60; YActual:=YActual + 40;
End;
End; //------------------------------------------------------------------------------
Procedure MeterEnTablero(Columna,Player:Integer;Var Tablero:TTablero);
Var i:Integer; Metida:Boolean;
Begin
i:=1; Metida:=False;
While (Tablero[i,Columna]='0') And (i<= Do Inc(i);
Case Player Of 1: tablero[i-1,Columna]:='1'; 2:tablero[i-1,Columna]:='2'; End; End;
//------------------------------------------------------------------------------
//Procedure Jugar(Var Player:TJugador;Var Tablero:TTablero);
//--------------------------------------------------------------------------- //PRINCIPAL //------------------------------------------------------------------------ Begin
//Inicializacion de Variables; Win:=False; InicializarTablero(Tablero); InicializarModoGrafico; Ambiente; DibujarTablero(Tablero); car:=Readkey; Closegraph; //Mata al modo grafico;
End.
|
_________________
Guillermo I'll Love Her, I Need Her, I Seed Her... She Is A Killing Maching |
| | Volver arriba | |  | gui2485_kawakx
Registrado: 22 Ene 2006 Mensajes: 59 Ubicación: Korn, Bs As, Argentina.
| Publicado: 25/02/2007 5:34 am | | | Título: |
| Otro ejemplo mas simple para mostrar que no funciona... en realidad la unica parte que falla es la del readkey y keypressed que aprieto teclas y no sucede nada... haceta llegue a pensar que puede ser drama del compilador.
| Cita: |
Program InterGraf01;
Uses CRT,SysUtils,Graph;
Const //Colores Black=0;Blue=1;Green=2;Cyan=3;Red=4;Magenta=5;Brown=6;LightGray=7; DarkGray=8;LightBlue=9;LightGreen=10;LightCyan=11;LightRed= 12; LightMagenta=13;Yellow=14;White=15;
//Variables Globales; Var gd,gm:SmallInt; //Manejador Grafico y Manejador de color respectivamente;
//------------------------------------------------------------------------------ Procedure InicializarModoGrafico;
Begin gm:=Detect; //tm podemos usar gm:=Detect; gd:=Detect;
InitGraph(gd,gm,''); if GraphResult <> grOk then begin Writeln('Driver ',gd,' Modo Grafico ',gm,' No Soportado'); Halt(1); end;
End;
Procedure Presentacion;
Var i:Integer;
Begin i:=-80; SetColor(LightGreen); SetTextStyle(6,0,2);
While i<=195 Do Begin OutTextXY(i,100,'Honda XR250 1994'); Delay(1); ClearDevice; Inc(i); End;
While Not KeyPressed Do Begin OutTextXY(i,100,'Honda XR250 1994'); Delay(0); ClearDevice; End;
End; //--------------------------------------------------------------------------- //PRINCIPAL //------------------------------------------------------------------------ Begin
InicializarModoGrafico; Presentacion; Closegraph;
End.
|
_________________
Guillermo I'll Love Her, I Need Her, I Seed Her... She Is A Killing Maching |
| | Volver arriba | |  | | |
| No puede crear mensajes No puede responder temas No puede editar sus mensajes No puede borrar sus mensajes No puede votar en encuestas
|
|
| |