elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13] 14 15 16 17 18 19 20 21 22 23
121  Programación / Programación C/C++ / Reservar memoria con new a una clase con varios elementos y constructor. en: 17 Febrero 2012, 02:05 am
Buenas quería saber cual es el problema de esto.

Personaje *enemy= new[10] Personaje(app,"img/enemy.png");

Me da este error.
error: expected identifier before '[' token|
|3|error: expected `,' or `;' before "Personaje"|
 
Lo que pienso es que no se puede reservar memoria dándole un constructor.
Pongo aquí el código por si me estoy equivocando.
main.cpp
Código
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. #include <SFML/Window.hpp>
  5. #include <SFML/Graphics.hpp>
  6. #include "personaje.hpp"
  7. #include "rsc/gui.hpp"
  8.  
  9. int main(int *argc,char *argv[]){
  10.    sf::Clock _tiempo;
  11.    sf::Event evento;
  12.    sf::Event eventovacio;
  13.    int _wapp=640;
  14.    int _happ=480;
  15.    float FPS=60;
  16.    float ftime;
  17.    app.Create(sf::VideoMode(640,480,32),"Invasores del Espacio");
  18.    _Declaracion();//botones
  19.    while(1){
  20.        if(_wapp!=app.GetWidth()||_happ!=app.GetHeight()){
  21.            _wapp=app.GetWidth();
  22.            _happ=app.GetHeight();
  23.            app.Close();
  24.            app.Create(sf::VideoMode(_wapp,_happ,32),"RESOLUTION CHANGED");
  25.        }
  26.        ftime=_tiempo.GetElapsedTime();
  27.        if(ftime>1.0/FPS){
  28.            _Eventos(app,evento);
  29.            _Video(app,evento);
  30.            _tiempo.Reset();
  31.            //para que solo ocurra 1 evento seguido
  32.            evento=eventovacio;
  33.        }
  34.    }
  35. }
gui.hpp
Código
  1. sf::RenderWindow app;
  2. Personaje *pj=new Personaje(app,"img/nave.png",true,100,100);
  3. Personaje *enemy= new [10]Personaje(app,"img/enemy.png");
  4. void _Declaracion()
  5. {
  6. };
  7. void _Eventos(sf::RenderWindow &app,sf::Event &evento)
  8. {
  9.    app.GetEvent(evento);
  10.    if(evento.Type==sf::Event::KeyPressed && evento.Key.Code == 256 || evento.Type== sf::Event::Closed)exit(1);
  11.    if(evento.Type==sf::Event::KeyPressed && evento.Key.Code == 'p'){
  12.    cout << "\n:::.PAUSED.:::\n";
  13.    while(1){
  14.        app.GetEvent(evento);
  15.        if(evento.Type==sf::Event::KeyPressed && evento.Key.Code == 'p')break;
  16.        if(evento.Type==sf::Event::KeyPressed && evento.Key.Code == 256 || evento.Type== sf::Event::Closed)exit(1);
  17.        }
  18.    }
  19.  
  20. }
  21. void _Video(sf::RenderWindow &app,sf::Event &evento)
  22. {
  23.    pj->Print();
  24.    app.Display();
  25. };
  26.  
personaje.hpp
Código
  1. class Personaje {
  2.    private:
  3.        sf::RenderWindow *_app;
  4.        sf::Sprite _S;
  5.        sf::Image _I;
  6.        bool _ON;
  7.    public:
  8.        Personaje(sf::RenderWindow&,char*);
  9.        Personaje(sf::RenderWindow &,char*,bool,float,float);
  10.        sf::Sprite GetSprite() {return _S; }
  11.        void Print() {if(_ON==true)_app->Draw(GetSprite());}
  12. };
  13. Personaje::Personaje(sf::RenderWindow &app,char *name){
  14.    _app=&app;
  15.    _ON=false;
  16.    _I.LoadFromFile(name);
  17.    _I.SetSmooth(false);
  18.    _S.SetImage(_I);
  19. };
  20. Personaje::Personaje(sf::RenderWindow &app,char *name,bool on,float x,float y){
  21.    _app=&app;
  22.    _ON=on;
  23.    _I.LoadFromFile(name);
  24.    _I.SetSmooth(false);
  25.    _S.SetImage(_I);
  26.    _S.SetPosition(x,y);
  27. };

PD: Espero solución gracias :)
122  Programación / Programación C/C++ / Duda con new en: 15 Febrero 2012, 18:47 pm
Cuando uso el operador new la memoria se reserva siempre en el heap? osea da igual donde declare la variables?
123  Foros Generales / Foro Libre / Mi vida de ordenador se hace ABURRIDA. Necesito ayuda en: 15 Febrero 2012, 01:14 am
Mi vida de ordenador se hace ABURRIDA. Necesito ayuda
Necesito entretenerme con algo No juegos . No programación algo nuevo.
124  Informática / Software / Instalar un SO en un pendrive (No hacer un liveCD) en: 14 Febrero 2012, 16:14 pm
Hola quería saber si para instalar un SO en mi pendrive de 8GB en este caso WinXP ese necesario hacer algo especial con la USB o se puede hacer directamente como si fuera un HD conectarlo y yasta.
Si necesito algo me podrías decir que?.
Actualmente estoy buscando por you tube. pero todo es Como instalar desde...usb
Yo quiero usar el Pen Como SO. xD poder instalarle programas y tal. no se si me explico.

SAludos
125  Programación / Programación C/C++ / [C++] Simple code que crea un rectángulo en consola (Source para nuevos) en: 14 Febrero 2012, 13:38 pm
 ;D
Buenas Aquí dejo un code limpio para novatos.

Código
  1. #include <iostream>
  2. using namespace std;
  3. class Rectangulo {
  4.    private:
  5.        int x,y,w,h;
  6.    public:
  7.        Rectangulo(int _x, int _y,int _w ,int _h) : x(_x),y(_y),w(_w),h(_h){}
  8.        void Ver();
  9.  
  10. };
  11. void Rectangulo::Ver(){
  12.    for(int j=0;j<20;j++){
  13.        for(int i=0;i<60;i++){
  14.            if((i>=x && i<x+w) && (j>=y && j<y+h))cout << '#';
  15.            else cout << ' ';
  16.        }
  17.        cout << '\n' ;
  18.    }
  19. };
  20. int main(int *argc,char *argv[]){
  21.    Rectangulo *C =new Rectangulo(30,2,10,10);
  22.    C->Ver();
  23.    delete C;
  24.    return 0;
  25. };
126  Informática / Software / Programa de macros "para pulsar una tecla y que escriba una palabra" en: 13 Febrero 2012, 21:42 pm
Hola estoy buscando lo siguiente. Programa de macros "para pulsar una tecla y que escriba una palabra"

Es más que nada para poner en f1 mi contraseña vamos xDD no tener que escribri los 1x caracteres que tengo cada 2 minutos xDD
127  Programación / Programación C/C++ / 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.  
128  Seguridad Informática / Materiales y equipos / Colocacion buena de una antena direccional.(Ayuda) en: 30 Enero 2012, 15:19 pm
Hoy me ha llegado mi antenita wifi rejilla de 24 dbi xDD.

Dudas tiene que estar muy direccionada al ap?
Es que me cuesta  solo me entra un 4-7% de señal y me va como si tuviera la anterior que tenia puesta que es una antena planal de 14 DBi que le entraba una señal de entre 7-12%

Aunque tiene una cosa mal colocada que puede ser que sea eso :) "cabeza chorlito que soy" es que en cuanto la e recibido me puesto a montarla como no tienen manual pues :)...

A ver si me podéis explicar como hay que colocar perfectamente mi antenita en angulo hacia el otro puntos etc. el ap creo que puede ser una antena omnidirrecional o planar no lo sé. El dipolo es lo central? eso debe de ir horizontal o vertical?
esta a 2 km aprox.

Esta es la antena.http://www.comprawifi.com/antenas-cables/2-4-ghz/rejilla/antena-de-rejilla-24dbi-con-inclinador/prod_845.html
tengo que decir que la estoy usando en el router Linksys WRT54G/GL/GS. con el router recojo la señal y la bajo por cable a mi pc. el router tiene un pigtail comercial de unos 10-20 cm poquito. + el cable tocho de la antena que es más o menos de la misma longitud sera para no perder señal.

PD: Estoy conectado con la que me comprado pero tengo muy poca señal   :)   .

PD2: Me duele mucho el dinero gastado para coger peor la señal -.- .
129  Programación / Programación General / Crear una linea recta de (x1,y1) hasta (x2,y2) (Ayuda) en: 30 Enero 2012, 01:36 am
Hola compañeros ando de culo con este tema por que no tengo ni idea de geometria ni de poligonos, me tenido que poner a estudiarlo :).

Pero como muchas veces me atasco en algo muy sencillo y me quedo ciego.

Esto programando la función para mi juego y trata la función de la trayectoria de un proyectil, pero no caigo en la función que debería de ser para sacar esa recta.

Pongamos unas coordenadas a ver si alguien me lo resuelve;

EJEMPLO
Origen x=10, y=10;
Destino x=230, y=40;


Saludos.
130  Media / Juegos y Consolas / Me recomiendas algun juego de estrategia POTENTE en: 10 Julio 2011, 00:09 am
Necesito algun juego de estrategia wapo que la IA tenga inteligencia  buena que no sea siempre construir y atacar. que hagan estrategias y esas cosas ...

Me gusta el command and coquer 2 pero la IA es penosa. me recomiendan alguno acepto de todos si es potente en graficos mejor.
SALUDOS.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13] 14 15 16 17 18 19 20 21 22 23
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines