Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <SFML/Graphics.hpp>
- #include "gamex.h"
- #include "loading screen.h"
- #include <string>
- #include <SFML/Network.hpp>
- using namespace sf;
- using namespace std;
- int main(){
- //loading();
- bool SCREEN_SHAKE = false;
- RenderWindow window(VideoMode(1200, 630), "Hastro", Style::Close | Style::Titlebar);
- RectangleShape black(Vector2f(350, 1000));
- window.setFramerateLimit(64);
- Texture tex;
- tex.loadFromFile("Images//earth.jpg");
- // cam shake
- /*View view(FloatRect(1200 , 630 , 1200 , 630 ));*/
- //view.setCenter(1200 / 2, 630 / 2);
- black.setFillColor(Color(0, 0, 0, 200));
- Sprite BG(tex);
- // TEXT support
- Text txt, txta, txtb, txtc;
- Font font;
- font.loadFromFile("Font//Quicksand-Regular.otf");
- txt.setFont(font);
- txt.setString("Anxoira ");
- txt.setCharacterSize(50);
- txt.setOrigin(-10, -100);
- txta.setFont(font);
- txta.setString("Play ");
- txta.setCharacterSize(20);
- txtb.setOrigin(-10, -220);
- txtb.setFont(font);
- txtb.setString("Settings ");
- txtb.setCharacterSize(20);
- txtc.setOrigin(-10, -270);
- txtc.setFont(font);
- txtc.setString("Quit");
- txtc.setCharacterSize(20);
- txta.setOrigin(-10, -170);
- Texture sunt;
- sunt.loadFromFile("Images//sun.png");
- Sprite Sun(sunt);
- Sun.setOrigin(-150, -250);
- float a = 4;
- float b = 1;
- Sun.setScale(4, 1);
- float pos = 10;
- Sun.setColor(Color(255, 255, 255, 100));
- while (window.isOpen()) {
- Clock clock;
- sf::View view(sf::FloatRect(std::rand() % 50, (std::rand() + 1) % 50, 1200, 630));
- if (SCREEN_SHAKE == true) {
- } if (SCREEN_SHAKE == false) {
- view.setCenter(1200 / 2, 630 / 2);
- }
- if (SCREEN_SHAKE == true) {
- if (clock.getElapsedTime().asSeconds() < 1) {
- SCREEN_SHAKE = false;
- }
- }
- // Mouse buttons
- if (txta.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
- txta.setFillColor(Color::Red);
- if (Mouse::isButtonPressed(Mouse::Left)) {
- SCREEN_SHAKE = true;
- txta.setFillColor(Color(100, 0, 50, 255));
- }
- }
- else
- {
- txta.setFillColor(Color::White);
- }
- if (txtb.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
- txtb.setFillColor(Color::Red);
- if (Mouse::isButtonPressed(Mouse::Left)) {
- txtb.setFillColor(Color(100, 0, 50, 255));
- }
- }
- else
- {
- txtb.setFillColor(Color::White);
- }
- if (txtc.getGlobalBounds().contains(window.mapPixelToCoords(Mouse::getPosition(window)))) {
- txtc.setFillColor(Color::Red);
- if (Mouse::isButtonPressed(Mouse::Left)) {
- txtc.setFillColor(Color(100, 0, 50, 255));
- window.close();
- printf("Console app has been deleted.");
- }
- }
- else
- {
- txtc.setFillColor(Color::White);
- }
- Event evnt;
- if (window.pollEvent(evnt)) {
- if (evnt.type == evnt.Closed) {
- window.close();
- }
- }
- window.clear();
- window.draw(BG);
- window.setView(view);
- window.draw(black);
- window.draw(txt);
- window.draw(txta);
- window.draw(txtb);
- window.draw(txtc);
- window.draw(Sun);
- window.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement