#include <iostream>
#include <SFML\Graphics.hpp>
#include "Header\ResourceManager.h"
using namespace std;
int main()
{
bool Running = true, Shift;
sf::Shape Map;
sf::View MainView;
sf::RenderWindow Window(sf::VideoMode::GetMode(0), "Laz's Interactive Map");
MainView.SetFromRect(Window.GetDefaultView().GetRect());
MainView.Zoom(.1f);
Map.AddPoint(0,0,sf::Color(0,100,0));
Map.AddPoint(30000,0,sf::Color(0,100,0));
Map.AddPoint(30000,90000,sf::Color(0,100,0));
Map.AddPoint(0,90000,sf::Color(0,100,0));
Map.EnableFill(true);
Map.EnableOutline(true);
Map.SetOutlineWidth(100);
while (Running) {
float Offset = 20000.f * Window.GetFrameTime();
if (Window.GetInput().IsKeyDown(sf::Key::Up) && Shift == false) { cout << "Up" << endl;MainView.Move( 0, -Offset);}
if (Window.GetInput().IsKeyDown(sf::Key::Down) && Shift == false) MainView.Move( 0, Offset);
if (Window.GetInput().IsKeyDown(sf::Key::Left)) MainView.Move(-Offset, 0);
if (Window.GetInput().IsKeyDown(sf::Key::Right)) MainView.Move(Offset, 0);
if (Window.GetInput().IsKeyDown(sf::Key::LShift)) Shift = true;
else if (Window.GetInput().IsKeyDown(sf::Key::RShift)) Shift = true;
else { Shift = false; }
if (Window.GetInput().IsKeyDown(sf::Key::Up) && Shift == true) MainView.Zoom(1.005f);
if (Window.GetInput().IsKeyDown(sf::Key::Down) && Shift == true) MainView.Zoom(0.994f);
Window.Clear(sf::Color::Red);
Window.SetView(MainView);
Window.Draw(Map);
for (int i = 10000; i < 90000; i += 10000) {
sf::Shape Line = sf::Shape::Line(0, i, 30000, i, 200, sf::Color::Red);
Window.Draw(Line);
}
Window.Display();
}
return 0;
}
This code looks like it should move my view. I set the view by the DefaultView.