Advertisement
RianeSN

zombies_main.cpp

Aug 19th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include "pch.h"
  2. #include "zombie_main.h"
  3. #include <sstream>
  4. #include <iostream>
  5. #include <string>
  6. #include <cstdlib>
  7. #include <SFML/Graphics.hpp>
  8.  
  9.  
  10. #define NOMINMAX
  11.  
  12. using namespace sf;
  13. using namespace std;
  14.  
  15. int begin_zombies() {
  16.     cout << "Beginning Zombie game.";
  17.  
  18.     int windowWidth = 800;
  19.     int windowHeight = 600;
  20.     sf::ContextSettings settings;
  21.     settings.antialiasingLevel = 8;
  22.     RenderWindow window(VideoMode(windowWidth, windowHeight), "Undead Rising", sf::Style::Default, settings);
  23.  
  24.     Text hud;
  25.     Text message;
  26.     Font font;
  27.     font.loadFromFile("fonts/DS-DIGI.ttf");
  28.     hud.setFont(font);
  29.     hud.setCharacterSize(20);
  30.     hud.setFillColor(sf::Color::White);
  31.     message.setFont(font);
  32.     message.setCharacterSize(14);
  33.     message.setFillColor(sf::Color::Red);
  34.     message.setPosition(1, 75); // from left, from top
  35.  
  36.     while (window.isOpen())
  37.     {
  38.         Event event;
  39.         while (window.pollEvent(event))
  40.         {
  41.             if (event.type == Event::Closed)
  42.                 window.close();
  43.         }
  44.         if (Keyboard::isKeyPressed(sf::Keyboard::Escape))
  45.         {
  46.             window.close();
  47.         }
  48.  
  49.         std::stringstream hud_text;
  50.         hud_text << "This is the generic zombie game.";
  51.         hud.setString(hud_text.str());
  52.  
  53.         window.clear(Color(0, 0, 0, 255));
  54.         window.draw(hud);
  55.         window.display();
  56.  
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement