SHARE
TWEET

asdasdasdasd

a guest May 25th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4. #include <iostream>
  5. #include <SFML/Graphics.hpp>
  6. #include "gamex.h"
  7. #include "loading screen.h"
  8. #include <string>
  9. #include <SFML/Network.hpp>
  10.  
  11.  
  12.  
  13. using namespace sf;
  14. using namespace std;
  15.  
  16. int main(){
  17.    
  18.     //loading();
  19.     bool SCREEN_SHAKE = false;
  20.     RenderWindow window(VideoMode(1200, 630), "Hastro", Style::Close | Style::Titlebar);
  21.     RectangleShape black(Vector2f(350, 1000));
  22.     window.setFramerateLimit(64);
  23.     Texture tex;
  24.     tex.loadFromFile("Images//earth.jpg");
  25.     // cam shake
  26.     /*View view(FloatRect(1200 , 630 , 1200 , 630 ));*/
  27.     //view.setCenter(1200 / 2, 630 / 2);
  28.    
  29.     black.setFillColor(Color(0, 0, 0, 200));
  30.     Sprite BG(tex);
  31.  
  32.     // TEXT support
  33.  
  34.     Text txt, txta, txtb, txtc;
  35.     Font font;
  36.     font.loadFromFile("Font//Quicksand-Regular.otf");
  37.     txt.setFont(font);
  38.     txt.setString("Anxoira ");
  39.     txt.setCharacterSize(50);
  40.     txt.setOrigin(-10, -100);
  41.     txta.setFont(font);
  42.     txta.setString("Play ");
  43.     txta.setCharacterSize(20);
  44.     txtb.setOrigin(-10, -220);
  45.     txtb.setFont(font);
  46.     txtb.setString("Settings ");
  47.     txtb.setCharacterSize(20);
  48.     txtc.setOrigin(-10, -270);
  49.     txtc.setFont(font);
  50.     txtc.setString("Quit");
  51.     txtc.setCharacterSize(20);
  52.     txta.setOrigin(-10, -170);
  53.     Texture sunt;
  54.     sunt.loadFromFile("Images//sun.png");
  55.     Sprite Sun(sunt);
  56.     Sun.setOrigin(-150, -250);
  57.     float  a = 4;
  58.     float  b = 1;
  59.     Sun.setScale(4, 1);
  60.     float pos = 10;
  61.     Sun.setColor(Color(255, 255, 255, 100));
  62.     while (window.isOpen()) {
  63.         Clock clock;
  64.    
  65.  
  66.         sf::View view(sf::FloatRect(std::rand() % 50, (std::rand() + 1) % 50, 1200, 630));
  67.  
  68.         if (SCREEN_SHAKE == true) {
  69.    
  70.  
  71.         } if (SCREEN_SHAKE == false) {
  72.  
  73.             view.setCenter(1200 / 2, 630 / 2);
  74.  
  75.         }
  76.         if (SCREEN_SHAKE == true) {
  77.  
  78.             if (clock.getElapsedTime().asSeconds() < 1) {
  79.  
  80.                 SCREEN_SHAKE = false;
  81.  
  82.             }
  83.  
  84.     }
  85.        
  86.         // Mouse buttons
  87.         if (txta.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
  88.             txta.setFillColor(Color::Red);
  89.             if (Mouse::isButtonPressed(Mouse::Left)) {
  90.            
  91.            
  92.                 SCREEN_SHAKE = true;
  93.            
  94.                 txta.setFillColor(Color(100, 0, 50, 255));
  95.    
  96.             }
  97.  
  98.  
  99.         }
  100.         else
  101.         {
  102.             txta.setFillColor(Color::White);
  103.         }
  104.         if (txtb.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
  105.             txtb.setFillColor(Color::Red);
  106.             if (Mouse::isButtonPressed(Mouse::Left)) {
  107.  
  108.                 txtb.setFillColor(Color(100, 0, 50, 255));
  109.  
  110.             }
  111.  
  112.  
  113.         }
  114.         else
  115.         {
  116.             txtb.setFillColor(Color::White);
  117.         }
  118.  
  119.         if (txtc.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
  120.             txtc.setFillColor(Color::Red);
  121.             if (Mouse::isButtonPressed(Mouse::Left)) {
  122.  
  123.                 txtc.setFillColor(Color(100, 0, 50, 255));
  124.                 window.close();
  125.  
  126.                 printf("Console app has been deleted.");
  127.             }
  128.  
  129.  
  130.         }
  131.         else
  132.         {
  133.             txtc.setFillColor(Color::White);
  134.         }
  135.         Event evnt;
  136.         if (window.pollEvent(evnt)) {
  137.             if (evnt.type == evnt.Closed) {
  138.  
  139.                 window.close();
  140.  
  141.             }
  142.  
  143.  
  144.         }
  145.         window.clear();
  146.  
  147.         window.draw(BG);
  148.         window.setView(view);
  149.         window.draw(black);
  150.         window.draw(txt);
  151.         window.draw(txta);
  152.         window.draw(txtb);
  153.         window.draw(txtc);
  154.         window.draw(Sun);
  155.         window.display();
  156.     }
  157.  
  158.  
  159.  
  160.  
  161. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top