• Viernes 3 de Mayo de 2024, 05:46

Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Temas - 010011010

Páginas: [1]
1
C/C++ / Urgente:codigo
« en: Jueves 15 de Diciembre de 2005, 13:02 »
Citar
//librerias
#include <stdio.h>
#include <iostream.h>
#include <graphics.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
//globales y constantes
const char DERECHA=77;
const char IZQUIERDA=75;
int velball=3;
int x1=300,x2=350;
const int y1=478,y2=469;
int c1=320,c2=11;
int dirx=rand()%1,diry=1;
int vidas=5,puntos=0;
char vidasypuntos[25];
//prototipos
void instrucciones(void);
void raqueta(void);
void mover(void);
void iniciarmodografico(void);
void ball(void);
void mover_ball(void);
void recuadro(void);
void limpia(void);
void fin(void);
//main
void main()
{
 textcolor(666);
 clrscr();
 instrucciones();
 iniciarmodografico();
 recuadro();
 for(;;)
 {
  if(vidas<=0) {gotoxy(1,1);cout<<"Perdiste Loooooossssssseeeeerrr"<<endl<<"PUNTOS: "<<puntos;cin.get();closegraph();fin();}
  do
  {
   if(puntos==1000)outtextxy(315,225,"NIVEL 2"),cin.get(),puntos+=100,velball++;
   if(puntos==2000)outtextxy(315,225,"NIVEL 3"),cin.get(),puntos+=100,velball+=2;
   if(puntos==3000)outtextxy(315,225,"NIVEL 4"),cin.get(),puntos+=100,velball+=2;
   if(puntos==4000)outtextxy(315,225,"NIVEL 5"),cin.get(),puntos+=100,velball+=3;
   limpia();
   raqueta();
   ball();
   if(vidas<=0) {gotoxy(1,1);cout<<"Perdiste Loooooossssssseeeeerrr"<<endl<<"PUNTOS: "<<puntos;cin.ignore();cin.get();closegraph();fin();}
   sprintf(vidasypuntos,"VIDAS=%d PUNTOS=%d",vidas,puntos),
   outtextxy(1,1,vidasypuntos);
   mover_ball();
  }while(!kbhit());
  while(kbhit())
  {
   mover();
  };
 }
}
//definicion de funciones
void iniciarmodografico(void)
{
 int controlador=DETECT,mode,error;
 initgraph(&controlador,&mode,"c:\\tdm");
 error=graphresult();
 if(error!=grOk)
 {
  cout<<"Error al inicializar modo grafico"<<endl;
  cout<<grapherrormsg(error)<<endl;
      getch();
      exit(1);
 }
}
void instrucciones(void)
{
 cout<<"\t\t\t\tCONTROLES"<<endl;
 cout<<"\t\t\t\tLEFT...izquierda"<<endl;
 cout<<"\t\t\t\tRIGHT...derecha"<<endl;
 cout<<"\t\t\t\tENTER...Pause"<<endl;
 cout<<"\t\t\t\tx...Salir"<<endl;
 cout<<"\t\t\t\t\"ENTER\" para continuar...";
 cin.get();
 sound(980),delay(350),
 sound(150),delay(50),
 sound(165),delay(100),
 sound(700),delay(50),
 sound(250),delay(150),
 sound(1000),delay(400),
 nosound();
}
void mover(void)
{
 char move;
 move=getch();
 switch(move)
 {
  case DERECHA:x1+=15;
        x2+=15;
        if(x2>=639)
        {
  x2=637;
  x1=x2-50;
        }
        break;
   case IZQUIERDA:x1-=15;
    x2-=15;
    if(x1<=0)
    {
     x1=2;
     x2=50;
    }
    break;
   case 'x': closegraph();
      fin();
      break;
   case 13:outtextxy(315,238,"PAUSE");
    sound(500),delay(200),sound(750),delay(150),sound(1111),delay(100),nosound();
    cin.get();

 }
}
void raqueta()
{
 setfillstyle(XHATCH_FILL,WHITE);
 rectangle(x1,y1,x2,y2);
 floodfill(x2-1,y2+1,WHITE);
}
void ball()
{
 circle(c1,c2,3);
 setcolor(RED);
 circle(c1,c2,2);
 setcolor(BLACK);
 circle(c1,c2,1);
 setcolor(YELLOW);
 circle(c1,c2,0);
 setcolor(WHITE);
}
void mover_ball()
{
 delay(10);
 putch(0);
 if(dirx==1)
 {
  c1+=velball;
  if(c1>=633){sound(600),delay(50),nosound();dirx=0;cleardevice();recuadro();}
 }
 else
 {
  c1-=velball;
  if(c1<=5){sound(500),delay(50),nosound();dirx=1;cleardevice();recuadro();}
 }
 if(diry==1)
 {
  c2+=2;
  if(c2>=466&&c2<476)
  {
   for(int i=x1;i<=x2;i++)
   {
    if(c1==i)
    {
     sound(300),delay(50),sound(150),delay(50),nosound();
     puntos+=100;
     diry=0;
     cleardevice();
     recuadro();
    }
   }
  }
  if(c2>=478)
  {
   sound(900),delay(150),sound(450),delay(200),sound(50),delay(250),nosound();
   vidas-=1;
   diry=1;
   c1=rand()%639;
   c2=15;
   dirx=rand()%1;
   cleardevice();
   recuadro();
  }
 }
 else
 {
  c2-=2;
  if(c2<=11) {sound(350),delay(100),nosound();diry=1;cleardevice();recuadro();}
 }
}
void limpia()
{
 setfillstyle(SOLID_FILL,BLACK);
 setcolor(BLACK);
 bar(2,9,638,478);
 setcolor(WHITE);
}
void recuadro()
{
 setcolor(BLUE);
 rectangle(1,8,639,479);
 setcolor(WHITE);
}
void fin()
{
 textcolor(666);
 clrscr();
 cin.get();
 exit(0);
}


lo q no entiendo es q sale este error
Citar
graphics.h(19,52):Error directive: BGI graphics not supported under windows
me urge, por fis alguien me dice como o hacer q funcione
soy nuevo en esto de c

gracias

2
C/C++ / Interface Con Puertos
« en: Martes 29 de Noviembre de 2005, 02:32 »
Hola , no corre este programa alguien sabe por q?

Citar
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <dos.h>
#define outportb (unsigned int directdatos,datosalida)

unsigned int directdatos=0x378;
unsigned char datosalida;
int res=0;
void main()
{
int i;
datosalida=0x80;
for(i=8;i>=1;i--)
   {
    outportb(directdatos,datosalida);
      cout << "\n Prendio el bit =>" <<i;
      getch();
      datosalida>>1;
   }
}

gracias

Páginas: [1]