Sie sind auf Seite 1von 1

Nombre de archivo: boton.h Pelota .

cpp

#include <cstdlib> #include <cstdlib>


#include <graphics.h> #include <graphics.h>
#include <windows.h> #include <windows.h>
using namespace std; #include "boton.h"
using namespace std;
class boton
{ int main()
int xi, xf, yi, yf; { boton a;
public: int x=3,xi=4,y=3,yi=4;
void posicion (int a, int b, int c, int d) initwindow(700,500);
{ xi=a; xf=c; yi=b; yf=d;} setbkcolor(1); cleardevice();

int prueba (void) while(true)


{ if (mousex()>xi&&mousex()<xf&&mousey()>yi&&mousey()<yf&&ismouseclick(WM_LBUTTONDOWN)) {
{ clearmouseclick(WM_LBUTTONDOWN); clearmouseclick(WM_MOUSEMOVE); return 1; }
else { clearmouseclick(WM_LBUTTONDOWN); clearmouseclick(WM_MOUSEMOVE); return 0;} if(x>640||x<1) {xi=-xi;}
} if(y>440||y<1) {yi=-yi;}
x+=xi; y+=yi;
void estado(char *nom, char *nom2)
{ a.posicion(1+x,1+y,60+x,60+y);
If (mousex()>xi && mousex()<xf && mousey()>yi && mousey()<yf) a.estado("pelota.bmp","pelota.bmp");
{ readimagefile (nom, xi, yi, xf, yf); } if(a.prueba()) {break;}
else { readimagefile (nom2,xi,yi,xf,yf);}
} }
};
}

/*
void clearmouseclick( int kind );
void clearresizeevent( );
void getmouseclick( int kind, int& x, int& y );
bool ismouseclick( int kind );
bool isresizeevent( );
int mousex( );
int mousey( );
void registermousehandler( int kind, void h( int, int ) );
void setmousequeuestatus( int kind, bool status=true );

* WM_MOUSEMOVE -- mouse movement


* WM_LBUTTONDBLCLK -- left mouse button double-click
* WM_LBUTTONDOWN -- left mouse button pushed down
* WM_LBUTTONUP -- left mouse button released up
* WM_MBUTTONDBLCLK -- middle mouse button double-click (might not work!)
* WM_MBUTTONDOWN -- middle mouse button pushed down (might not work!)
* WM_MBUTTONUP -- middle mouse button released up (might not work!)
* WM_RBUTTONDBLCLK -- right mouse button double-click
* WM_RBUTTONDOWN -- right mouse button pushed down
* WM_RBUTTONUP -- right mouse button released up
*/

Das könnte Ihnen auch gefallen