Advertisement
Dizzy23b

Untitled

May 15th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <iostream>
  3. #include <ctime>
  4. #include "Lester.h"
  5. #include "Player.h"
  6. #include "SplashScreen.h"
  7.  
  8. TileMap m_map;
  9. SplashScreen splashscn;
  10.  
  11. bool splash_set = false;
  12. bool splash_open = false;
  13.  
  14.  
  15. void pause(int dur)
  16. {
  17.     int temp = time(NULL) + dur;
  18.  
  19.     while (temp > time(NULL));
  20. }
  21.  
  22. void Lester::Map()
  23. {
  24.     // define the level with an array of tile indices
  25.     const int level[] =
  26.     {
  27.         //Removed because of lengtha
  28.     };
  29.  
  30.     if (!m_map.load("data/assets/map/tilemap.png", sf::Vector2u(16, 16), level, 100, 100)){}
  31. }
  32. void Lester::KeyInput()
  33. {
  34.    
  35.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape) || sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Q)){ window->close(); }
  36.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))m_view->move(-4, 0);
  37.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))m_view->move(4, 0);
  38.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))m_view->move(0, 4);
  39.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))m_view->move(0, -4);
  40. }
  41. void Lester::MouseInput(){}
  42. void Lester::Input(){}
  43. void Lester::PlayerSetup()
  44. {
  45.     Player player = *new Player();
  46.     sf::Sprite p_sprite(player.p_sprite);
  47.     p_sprite.setPosition(200, 200);
  48.     p_sprite.setTexture(player.tp_sprite);
  49.    
  50.     window->draw(p_sprite);
  51. }
  52. void Lester::Screen()
  53. {
  54.     window->setView(*m_view);//Set Game View
  55.     Map();//Call Map
  56.     window->draw(m_map);
  57.     PlayerSetup();
  58. }
  59. void Lester::GameScreen()
  60. {
  61.     window->setView(*m_view);
  62.     window->clear();
  63.     Screen();
  64. }
  65. void Lester::GameLoop()
  66. {
  67.     window = new sf::RenderWindow(sf::VideoMode(960, 550, 32), "Lester V:0.1");
  68.     m_view = new sf::View(sf::FloatRect(200, 200, 300, 200));//View Port
  69.     m_view->zoom(0.7f);//Set Zoom
  70.  
  71.     window->setFramerateLimit(60);//Set FrameRate
  72.     window->setVerticalSyncEnabled(true);
  73.  
  74.     while (window->isOpen())
  75.     {
  76.  
  77.         sf::Event event;
  78.         while (window->pollEvent(event))
  79.         {
  80.             if (event.type == sf::Event::Closed)
  81.                 window->close();
  82.         }
  83.                
  84.         running = true;
  85.  
  86.         while (splash_set == false){window->display();splash_set = true;}      
  87.         if (splash_set == true){ window->clear(); KeyInput(); window->clear(); PlayerSetup(); GameScreen(); window->display(); }
  88.         //window->display();
  89.  
  90.     }
  91.     //window->display();
  92. }
  93. void Lester::Init(){ GameLoop(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement