Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <iostream>
- #include <ctime>
- #include "Lester.h"
- #include "Player.h"
- #include "SplashScreen.h"
- TileMap m_map;
- SplashScreen splashscn;
- bool splash_set = false;
- bool splash_open = false;
- void pause(int dur)
- {
- int temp = time(NULL) + dur;
- while (temp > time(NULL));
- }
- void Lester::Map()
- {
- // define the level with an array of tile indices
- const int level[] =
- {
- //Removed because of lengtha
- };
- if (!m_map.load("data/assets/map/tilemap.png", sf::Vector2u(16, 16), level, 100, 100)){}
- }
- void Lester::KeyInput()
- {
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape) || sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Q)){ window->close(); }
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))m_view->move(-4, 0);
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))m_view->move(4, 0);
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))m_view->move(0, 4);
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))m_view->move(0, -4);
- }
- void Lester::MouseInput(){}
- void Lester::Input(){}
- void Lester::PlayerSetup()
- {
- Player player = *new Player();
- sf::Sprite p_sprite(player.p_sprite);
- p_sprite.setPosition(200, 200);
- p_sprite.setTexture(player.tp_sprite);
- window->draw(p_sprite);
- }
- void Lester::Screen()
- {
- window->setView(*m_view);//Set Game View
- Map();//Call Map
- window->draw(m_map);
- PlayerSetup();
- }
- void Lester::GameScreen()
- {
- window->setView(*m_view);
- window->clear();
- Screen();
- }
- void Lester::GameLoop()
- {
- window = new sf::RenderWindow(sf::VideoMode(960, 550, 32), "Lester V:0.1");
- m_view = new sf::View(sf::FloatRect(200, 200, 300, 200));//View Port
- m_view->zoom(0.7f);//Set Zoom
- window->setFramerateLimit(60);//Set FrameRate
- window->setVerticalSyncEnabled(true);
- while (window->isOpen())
- {
- sf::Event event;
- while (window->pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- window->close();
- }
- running = true;
- while (splash_set == false){window->display();splash_set = true;}
- if (splash_set == true){ window->clear(); KeyInput(); window->clear(); PlayerSetup(); GameScreen(); window->display(); }
- //window->display();
- }
- //window->display();
- }
- void Lester::Init(){ GameLoop(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement