0 Members and 1 Guest are viewing this topic.
#include <SFML/Graphics.hpp>#include <SFML/Window.hpp>#include <SFML/System.hpp>int main(){ sf::RenderWindow App(sf::VideoMode(103,31),"Keygen",sf::Style::None); sf::Image images[4]; images[0].LoadFromFile("keygen.png"); images[1].LoadFromFile("textbox.png"); images[2].LoadFromFile("generate.png"); images[3].LoadFromFile("exit.png"); sf::Sprite sprites[4]; for(int i=0;i<4;i++) { images[i].SetSmooth(false); sprites[i].SetImage(images[i]); } sprites[1].SetPosition(6,6); sprites[2].SetPosition(31,16); sprites[3].SetPosition(75,16); bool move = false; while(App.IsOpened()) { sf::Event Event; App.GetEvent(Event); if(!move) if(App.GetInput().IsMouseButtonDown(sf::Mouse::Left)) move = true; if(move && App.GetInput().IsMouseButtonDown(sf::Mouse::Left)) App.SetPosition(App.GetInput().GetMouseX()-51,App.GetInput().GetMouseY()-15); else move = false; App.Clear(); App.Draw(sprites[0]); int mx = App.GetInput().GetMouseX(); int my = App.GetInput().GetMouseY(); if(mx >= 6 && mx <= 96 && my >= 6 && my <= 14) App.Draw(sprites[1]); else if(mx >= 31 && mx <= 73 && my >= 16 && my <= 24) App.Draw(sprites[2]); else if(mx >= 75 && mx <= 96 && my >= 16 && my <= 24) { App.Draw(sprites[3]); if((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left)) App.Close(); } App.Display(); sf::Sleep(0.010); } return 0;}
#include <SFML/Graphics.hpp>#include <SFML/Window.hpp>#include <SFML/System.hpp>int main(){ sf::RenderWindow App(sf::VideoMode(103,31),"Keygen",sf::Style::None); sf::Texture images[4]; images[0].LoadFromFile("keygen.png"); images[1].LoadFromFile("textbox.png"); images[2].LoadFromFile("generate.png"); images[3].LoadFromFile("exit.png"); sf::Sprite sprites[4]; for(int i=0;i<4;i++) { sprites[i].SetTexture(images[i]); } sprites[1].SetPosition(6,6); sprites[2].SetPosition(31,16); sprites[3].SetPosition(75,16); bool move = false; bool button = false; while(App.IsOpened()) { sf::Event Event; App.PollEvent(Event); App.Clear(); App.Draw(sprites[0]); int mx = sf::Mouse::GetPosition(App).x; int my = sf::Mouse::GetPosition(App).y; if(mx >= 6 && mx <= 96 && my >= 6 && my <= 14) App.Draw(sprites[1]); else if(mx >= 31 && mx <= 73 && my >= 16 && my <= 24) { App.Draw(sprites[2]); button = true; } else if(mx >= 75 && mx <= 96 && my >= 16 && my <= 24) { App.Draw(sprites[3]); if((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left)) App.Close(); button = true; } else button = false; App.Display(); if(move && button == false) App.SetPosition(sf::Mouse::GetPosition().x-51,sf::Mouse::GetPosition().y-10); if((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left)) move = true; if((Event.Type == sf::Event::MouseButtonReleased) && (Event.MouseButton.Button == sf::Mouse::Left)) move = false; sf::Sleep(0.010); } return 0;}