Advertisement
RianeSN

main.cpp

Aug 19th, 2020 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include "pch.h"
  2. #include "pong.h"
  3. #include "zombies.h"
  4. #include <sstream>
  5. #include <iostream>
  6. #include <string>
  7. #include <cstdlib>
  8. #include <SFML/Graphics.hpp>
  9. #define NOMINMAX
  10.  
  11. using namespace sf;
  12.  
  13. int main()
  14. {
  15.     int windowWidth = 800;
  16.     int windowHeight = 600;
  17.     sf::ContextSettings settings;
  18.     settings.antialiasingLevel = 8;
  19.     RenderWindow window(VideoMode(windowWidth, windowHeight), "Main Menu", sf::Style::Default, settings);
  20.     window.setFramerateLimit(60);
  21.  
  22.     Text hud;
  23.     Font font;
  24.     font.loadFromFile("fonts/DS-DIGI.ttf");
  25.     hud.setFont(font);
  26.     hud.setCharacterSize(20);
  27.     hud.setFillColor(sf::Color::White);
  28.  
  29.     while (window.isOpen())
  30.     {
  31.         Event event;
  32.         while (window.pollEvent(event))
  33.         {
  34.             if (event.type == Event::Closed)
  35.                 window.close();
  36.         }
  37.         if (Keyboard::isKeyPressed(sf::Keyboard::Escape))
  38.         {
  39.             window.close();
  40.         }
  41.  
  42.         else if (Keyboard::isKeyPressed(Keyboard::1))
  43.         {
  44.             begin_pong(); // This calls the 'begin' function in Pong
  45.         }
  46.         else if (Keyboard::isKeyPressed(Keyboard::2))
  47.         {
  48.             begin_zombies(); // This calls the 'begin' function in Zombies
  49.         }
  50.  
  51.         std::stringstream ss;
  52.         ss << "Press 1 to play Pong" << std::endl << "Press 2 to play Zombies";
  53.  
  54.         hud.setString(ss.str());
  55.  
  56.         window.clear(Color(0, 0, 0, 255));
  57.         window.draw(hud);
  58.  
  59.         window.display();
  60.         }
  61.  
  62.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement