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)
| | |-+  Me aburro comenten este code.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Me aburro comenten este code.  (Leído 1,676 veces)
anonimo12121


Desconectado Desconectado

Mensajes: 1.813


Ver Perfil WWW
Me aburro comenten este code.
« en: 11 Febrero 2012, 15:47 pm »

Me aburro comenten este code.
Utilizo la libreria SFML
Código
  1. class Button
  2. {
  3.    private:
  4.        sf::Image iboton[3];
  5.        sf::Sprite spr;
  6.        sf::Vector2f siz;
  7.        sf::Vector2f pos;
  8.        sf::String text;
  9.        int MouseState;// 0 nada 1 por encima 2 click xD
  10.        bool ButtonON;
  11.        bool MouseOn;
  12.        bool ButtonPush;//boton activo true boton desactivado false
  13.        bool ButtonAction; //
  14.    public:
  15.        Button();
  16.        void CreateButton1(sf::Unicode::Text t,float x,float y,float h);
  17.        void CreateButton2(sf::Unicode::Text t,float x,float y,float h);
  18.        void PrintButton1(sf::RenderWindow &app, sf::Event &ev);
  19.        void PrintButton2(sf::RenderWindow &app, sf::Event &ev);
  20.        int GetMouseState(sf::RenderWindow &app, sf::Event &ev);
  21.        bool ButtonState();
  22.        void Reset();
  23.        void SetStateButton(bool b);
  24.        bool GetStateButton();
  25.        bool GetButtonAction();
  26.        sf::Vector2f GetPosition();
  27.        sf::Vector2f GetSize();
  28.  
  29. };
  30. Button::Button()
  31. {
  32.    ButtonON=true;
  33. }
  34. void Button::CreateButton1(sf::Unicode::Text t,float x,float y,float h)
  35. {
  36.  
  37.    iboton[0].LoadFromFile("img/button1.png");
  38.    iboton[0].SetSmooth(false);
  39.    iboton[1].LoadFromFile("img/button2.png");
  40.    iboton[1].SetSmooth(false);
  41.    iboton[2].LoadFromFile("img/button3.png");
  42.    iboton[2].SetSmooth(false);
  43.    spr.SetPosition(sf::Vector2f(x,y));
  44.    pos=spr.GetPosition();
  45.    text.SetText(t);
  46.    text.SetSize(12);
  47.    text.SetColor(sf::Color(0,0,0,255));
  48.    text.SetPosition(sf::Vector2f(pos.x+4,pos.y));
  49.    siz.x=(text.GetRect().Right-text.GetRect().Left)+8;
  50.    siz.y=h;
  51. };
  52. void Button::CreateButton2(sf::Unicode::Text t,float x,float y,float h)
  53. {
  54.    iboton[0].LoadFromFile("img/marco.png");
  55.    iboton[0].SetSmooth(false);
  56.    iboton[1].LoadFromFile("img/button2.png");
  57.    iboton[1].SetSmooth(false);
  58.    spr.SetPosition(sf::Vector2f(x,y));
  59.    pos=spr.GetPosition();
  60.    text.SetText(t);
  61.    text.SetSize(12);
  62.    text.SetColor(sf::Color(0,0,0,255));
  63.    text.SetPosition(sf::Vector2f(pos.x+4,pos.y));
  64.    siz.x=(text.GetRect().Right-text.GetRect().Left)+8;
  65.    siz.y=h;
  66. };
  67. void Button::PrintButton1(sf::RenderWindow &app, sf::Event &ev)
  68. {
  69.    if(ButtonON==true){
  70.        spr.SetImage(iboton[MouseState]);
  71.        if(siz.x<12)siz.x=12;
  72.        if(siz.y<12)siz.y=12;
  73.        for(int i=0;i< (siz.x-4)/4-1; i++)
  74.        {
  75.            spr.SetSubRect(sf::IntRect(4,0,8,4));
  76.            spr.SetPosition(4+pos.x+(4*i),pos.y);
  77.            app.Draw(spr);
  78.        }
  79.        for(int i=0;i< (siz.x-4)/4-1; i++)
  80.        {
  81.            for(int j=0;j<(siz.y-4)/4-1;j++)
  82.            {
  83.                spr.SetSubRect(sf::IntRect(4,4,8,8));
  84.                spr.SetPosition(4+pos.x+(4*i),4+pos.y+(4*j));
  85.                app.Draw(spr);
  86.            }
  87.        }
  88.        for(int j=0;j<(siz.y-4)/4-1;j++)
  89.            {
  90.                spr.SetSubRect(sf::IntRect(0,4,4,8));
  91.                spr.SetPosition(pos.x,4+pos.y+(4*j));
  92.                app.Draw(spr);
  93.                spr.SetSubRect(sf::IntRect(8,4,12,8));
  94.                spr.SetPosition(pos.x+siz.x-4,4+pos.y+(4*j));
  95.                app.Draw(spr);
  96.            }
  97.        for(int i=0;i< (siz.x-4)/4-1; i++)
  98.        {
  99.            spr.SetSubRect(sf::IntRect(4,8,8,12));
  100.            spr.SetPosition(4+pos.x+(4*i),pos.y+siz.y-4);
  101.            app.Draw(spr);
  102.        }
  103.        spr.SetSubRect(sf::IntRect(0,0,4,4));
  104.        spr.SetPosition(pos.x,pos.y);
  105.        app.Draw(spr);
  106.        spr.SetSubRect(sf::IntRect(8,0,12,4));
  107.        spr.SetPosition(pos.x+siz.x-4,pos.y);
  108.        app.Draw(spr);
  109.        spr.SetSubRect(sf::IntRect(0,8,4,12));
  110.        spr.SetPosition(pos.x,pos.y+siz.y-4);
  111.        app.Draw(spr);
  112.        spr.SetSubRect(sf::IntRect(8,8,12,12));
  113.        spr.SetPosition(pos.x+siz.x-4,pos.y+siz.y-4);
  114.        app.Draw(spr);
  115.        app.Draw(text);
  116.        spr.SetPosition(sf::Vector2f(pos.x,pos.y));
  117.    }
  118. };
  119. void Button::PrintButton2(sf::RenderWindow &app, sf::Event &evento)
  120. {
  121.    if(ButtonON==true){
  122.        if(MouseState==1 || MouseState==2)
  123.        {
  124.            if(MouseState==1)spr.SetImage(iboton[0]);
  125.            else if(MouseState==2)spr.SetImage(iboton[1]);
  126.            for(int i=0;i< (siz.x-4)/4-1; i++)
  127.            {
  128.                spr.SetSubRect(sf::IntRect(4,0,8,4));
  129.                spr.SetPosition(4+pos.x+(4*i),pos.y);
  130.                app.Draw(spr);
  131.            }
  132.            if(MouseState==2)
  133.            {
  134.                for(int i=0;i< (siz.x-4)/4-1; i++)
  135.                {
  136.                    for(int j=0;j<(siz.y-4)/4-1;j++)
  137.                    {
  138.                        spr.SetSubRect(sf::IntRect(4,4,8,8));
  139.                        spr.SetPosition(4+pos.x+(4*i),4+pos.y+(4*j));
  140.                        app.Draw(spr);
  141.                    }
  142.                }
  143.            }
  144.            for(int j=0;j<(siz.y-4)/4-1;j++)
  145.            {
  146.                spr.SetSubRect(sf::IntRect(0,4,4,8));
  147.                spr.SetPosition(pos.x,4+pos.y+(4*j));
  148.                app.Draw(spr);
  149.                spr.SetSubRect(sf::IntRect(8,4,12,8));
  150.                spr.SetPosition(pos.x+siz.x-4,4+pos.y+(4*j));
  151.                app.Draw(spr);
  152.            }
  153.            for(int i=0;i< (siz.x-4)/4-1; i++)
  154.            {
  155.                spr.SetSubRect(sf::IntRect(4,8,8,12));
  156.                spr.SetPosition(4+pos.x+(4*i),pos.y+siz.y-4);
  157.                app.Draw(spr);
  158.            }
  159.                spr.SetSubRect(sf::IntRect(0,0,4,4));
  160.                spr.SetPosition(pos.x,pos.y);
  161.                app.Draw(spr);
  162.                spr.SetSubRect(sf::IntRect(8,0,12,4));
  163.                spr.SetPosition(pos.x+siz.x-4,pos.y);
  164.                app.Draw(spr);
  165.                spr.SetSubRect(sf::IntRect(0,8,4,12));
  166.                spr.SetPosition(pos.x,pos.y+siz.y-4);
  167.                app.Draw(spr);
  168.                spr.SetSubRect(sf::IntRect(8,8,12,12));
  169.                spr.SetPosition(pos.x+siz.x-4,pos.y+siz.y-4);
  170.                app.Draw(spr);
  171.        }
  172.        if(MouseState==0)text.SetColor(sf::Color(0,0,0,255));
  173.        if(MouseState==1)text.SetColor(sf::Color(255,0,0,255));
  174.        app.Draw(text);
  175.    }
  176. };
  177. int Button::GetMouseState(sf::RenderWindow &app, sf::Event &ev)
  178. {
  179.    ButtonAction=false;
  180.    if( (app.GetInput().GetMouseX() > pos.x)  && ( app.GetInput().GetMouseX() < pos.x+siz.x)&&
  181.    (app.GetInput().GetMouseY() > pos.y)  && ( app.GetInput().GetMouseY() < pos.y+siz.y)){
  182.        if(ButtonPush==false)MouseState=1;
  183.        if(ev.Type==ev.MouseButtonPressed && ev.MouseButton.Button ==sf::Mouse::Left && ButtonPush==false){
  184.            MouseState=2;
  185.            ButtonPush=true;
  186.        }
  187.        if(ev.Type==ev.MouseButtonReleased && ev.MouseButton.Button ==sf::Mouse::Left && ButtonPush==true){
  188.            ButtonPush=false;
  189.            MouseState=1;
  190.            //if(ButtonAction==true)cout << "FAIL";
  191.            if(ButtonAction==true)ButtonAction=false;
  192.            else ButtonAction=true;
  193.        }
  194.    }
  195.    else {
  196.        MouseState=0;
  197.        ButtonPush=false;
  198.    }
  199.  
  200.    return MouseState;
  201. };
  202. void Button::Reset()
  203. {
  204.    ButtonPush=false;
  205. };
  206. bool Button::ButtonState()
  207. {
  208.    return ButtonPush;
  209. };
  210. void Button::SetStateButton(bool b)
  211. {
  212.    ButtonON=b;
  213. };
  214. bool Button::GetStateButton()
  215. {
  216.    return ButtonON;
  217. };
  218. bool Button::GetButtonAction(){
  219.    return ButtonAction;
  220. }
  221. sf::Vector2f Button::GetPosition(){
  222.    return pos;
  223. };
  224. sf::Vector2f Button::GetSize(){
  225.    return siz;
  226. };
  227.  


En línea

Página para ganar Bitcoins y Dinero: http://earnbit.hol.es/
Video de YouTube con Hack para el LoL: http://adf.ly/5033746/youtube-lolemuhack
Si quieres ganar dinero con adfly entra y registrate aquí -> http://adf.ly/?id=5033746
Xandrete

Desconectado Desconectado

Mensajes: 210



Ver Perfil
Re: Me aburro comenten este code.
« Respuesta #1 en: 12 Febrero 2012, 20:10 pm »

Ahá.



En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
¿Por que no me funciona este code? (Juego)
Scripting
esparta 0 2,064 Último mensaje 4 Noviembre 2007, 14:06 pm
por esparta
No me funciona este code (Encuesta)
Scripting
esparta 2 2,188 Último mensaje 4 Noviembre 2007, 15:34 pm
por esparta
ayuda con modificacion simple de este code « 1 2 »
Programación Visual Basic
Tengu 19 4,568 Último mensaje 21 Enero 2008, 05:47 am
por AlbertoBSD
Ayuda con este code cifrado?
Criptografía
RICKWZ 2 3,399 Último mensaje 28 Enero 2011, 15:20 pm
por RICKWZ
THREADS porque nofunciona este code para parar un thread
Java
r7pyrred 3 1,955 Último mensaje 14 Febrero 2013, 10:34 am
por r7pyrred
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines