Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <SFML/Graphics.hpp>
- #include <string>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include <memory>
- using namespace std;
- class TileMap
- {
- public:
- sf::RenderWindow App;
- sf::RenderWindow App2;
- sf::View View;
- vector<int> MapData;
- vector<int> VisualMap;
- vector<sf::Sprite> Sprites;
- vector<sf::Sprite> VisualSprites;
- vector<sf::Image> Images;
- vector<sf::Image> VisualImages;
- vector<sf::Shape> Shapes;
- vector<string> MapTypes;
- int MapWidth, MapHeight, ImageSize;
- string MapType, MapName;
- //Drawing Functions
- void Fill(int, int,int);
- //void Draw(int, int, int);//Done
- void Inputs();
- //void Inputs(vector<TileMap>&);//Done
- void LoadImages();//Done
- void LoadVisualImages();
- void LoadSprites();//Done
- void LoadVisualSprites();
- void SaveFile();//Done
- void LoadFile();//Done
- void LoadVisualFile();
- void GetEvents();//Done
- void Display();
- void VisualDisplay();
- //void SaveCalc();
- //void SendCalc();//This will be the last thing to be implemented
- TileMap();//Type of Map
- //TileMap(string, string);
- //~TileMap();
- protected:
- private:
- int ImgListNum, selectedimage, selectedimage2;
- void FillBlock(int,int,int,int,int);
- bool FillInput(int, int, int);
- };
- int main()
- {
- TileMap Maps;
- while(Maps.App.IsOpened())
- {
- //cout << "Ok";
- Maps.GetEvents();
- Maps.Inputs();
- Maps.App.Clear();
- Maps.App2.Clear(sf::Color::White);
- if(Maps.MapType == "visual")
- Maps.Display();
- else
- Maps.VisualDisplay();
- }
- return 0;
- }
- void TileMap::LoadImages()
- {
- stringstream PictureName;
- bool exist = true;
- int ImageNum = 0;
- sf::Image tempImage;
- while(exist)
- {
- PictureName << "data/images/" << MapType << "/" << ImageNum << ".png";
- if(tempImage.LoadFromFile(PictureName.str().c_str()))
- {
- Images.push_back(tempImage);
- Images[ImageNum].SetSmooth(false);
- }
- else
- exist = false;
- //cout << "\n" << PictureName.str().c_str() << "\n";
- PictureName.str(string());
- ImageNum++;
- }
- return;
- }
- void TileMap::LoadVisualImages()
- {
- stringstream PictureName;
- bool exist = true;
- int ImageNum = 0;
- sf::Image tempImage;
- while(exist)
- {
- PictureName << "data/images/visual/" << ImageNum << ".png";
- if(tempImage.LoadFromFile(PictureName.str().c_str()))
- {
- VisualImages.push_back(tempImage);
- VisualImages[ImageNum].SetSmooth(false);
- }
- else
- exist = false;
- //cout << "\n" << PictureName.str().c_str() << "\n";
- PictureName.str(string());
- ImageNum++;
- }
- return;
- }
- void TileMap::Inputs()
- //void TileMap::Inputs()
- {
- float Time, Offset;
- Time = App.GetFrameTime();
- const sf::Input& Input = App.GetInput();
- const sf::Input& Input2 = App2.GetInput();
- if (Input.IsMouseButtonDown(sf::Mouse::Left) || Input.IsMouseButtonDown(sf::Mouse::Right))
- {
- sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY());
- int x=MousePos.x/ImageSize;
- int y=MousePos.y/ImageSize;
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- if (x > MapWidth - 1)
- x = MapWidth - 1;
- if (y > MapHeight - 1)
- y = MapHeight - 1;
- if (Input.IsMouseButtonDown(sf::Mouse::Left))
- MapData[x + (y * MapWidth)] = selectedimage;//Used to "draw" on the screen
- else if (Input.IsMouseButtonDown(sf::Mouse::Right))
- MapData[x + (y * MapWidth)] = selectedimage2;
- }
- if ((Input.IsKeyDown(sf::Key::Numpad0) || Input.IsKeyDown(sf::Key::Num0)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 0 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad1) || Input.IsKeyDown(sf::Key::Num1)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 1 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad2) || Input.IsKeyDown(sf::Key::Num2)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 2 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad3) || Input.IsKeyDown(sf::Key::Num3)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 3 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad4) || Input.IsKeyDown(sf::Key::Num4)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 4 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad5)|| Input.IsKeyDown(sf::Key::Num5)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 5 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad6) || Input.IsKeyDown(sf::Key::Num6)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 6 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad7) || Input.IsKeyDown(sf::Key::Num7)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 7 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad8) || Input.IsKeyDown(sf::Key::Num8)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 8 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad9) || Input.IsKeyDown(sf::Key::Num9)) && !(Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage = 9 + ImgListNum;
- if ((Input.IsKeyDown(sf::Key::Numpad0) || Input.IsKeyDown(sf::Key::Num0)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 0 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad1) || Input.IsKeyDown(sf::Key::Num1)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 1 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad2) || Input.IsKeyDown(sf::Key::Num2)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 2 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad3) || Input.IsKeyDown(sf::Key::Num3)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 3 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad4) || Input.IsKeyDown(sf::Key::Num4)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 4 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad5)|| Input.IsKeyDown(sf::Key::Num5)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 5 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad6) || Input.IsKeyDown(sf::Key::Num6)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 6 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad7) || Input.IsKeyDown(sf::Key::Num7)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 7 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad8) || Input.IsKeyDown(sf::Key::Num8)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 8 + ImgListNum;
- else if ((Input.IsKeyDown(sf::Key::Numpad9) || Input.IsKeyDown(sf::Key::Num9)) && (Input.IsKeyDown(sf::Key::LControl)) || Input.IsKeyDown(sf::Key::RControl))
- selectedimage2 = 9 + ImgListNum;//used to select images
- if (Input.IsKeyDown(sf::Key::E))//Erases where the mouse is
- {
- sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY());
- int x=MousePos.x/ImageSize;
- int y=MousePos.y/ImageSize;
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- if (x > MapWidth - 1)
- x = MapWidth - 1;
- if (y > MapHeight - 1)
- y = MapHeight - 1;
- if (Input.IsMouseButtonDown(sf::Mouse::Left))
- MapData[x + (y * MapWidth)] = -1;//Used to "draw" on the screen
- else if (Input.IsMouseButtonDown(sf::Mouse::Right))
- MapData[x + (y * MapWidth)] = -1;
- }
- if (Input.IsKeyDown(sf::Key::Right) && ((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl))))
- ImgListNum += 10;//Used to page between image tiles
- else if (Input.IsKeyDown(sf::Key::Left) && ((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl))))
- ImgListNum -= 10;
- //if(Input.)
- if (ImgListNum > (signed int)Sprites.size() - 10)
- ImgListNum = Sprites.size() - 10;
- if (ImgListNum < 0)
- ImgListNum = 0;
- Offset=Time*640;
- if (Input.IsKeyDown(sf::Key::Left))
- View.Move(-Offset, 0);
- if (Input.IsKeyDown(sf::Key::Right))
- View.Move(Offset,0);
- if (Input.IsKeyDown(sf::Key::Up))
- View.Move(0,-Offset);
- if (Input.IsKeyDown(sf::Key::Down))
- View.Move(0,Offset);//Pans the camera
- if (Input.IsKeyDown(sf::Key::A))
- View.Move(-Offset, 0);
- if (Input.IsKeyDown(sf::Key::D))
- View.Move(Offset,0);
- if (Input.IsKeyDown(sf::Key::W))
- View.Move(0,-Offset);
- if (Input.IsKeyDown(sf::Key::S))
- View.Move(0,Offset);
- if ((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl)) && Input.IsKeyDown(sf::Key::S))
- SaveFile();
- if ((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl)) && Input.IsKeyDown(sf::Key::L))
- LoadFile();
- /*if ((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl)) && Input.IsKeyDown(sf::Key::O))
- {
- Maps.push_back(TileMap());
- for(int i; i < Maps.size(); i++)
- Maps[i].LoadSprites();
- }*/
- if (Input2.IsMouseButtonDown(sf::Mouse::Left))
- {
- sf::Vector2f MousePos = App2.ConvertCoords(Input2.GetMouseX(), Input2.GetMouseY());
- selectedimage = MousePos.y/ImageSize + ImgListNum;
- }
- if (Input2.IsMouseButtonDown(sf::Mouse::Right))
- {
- sf::Vector2f MousePos = App2.ConvertCoords(Input2.GetMouseX(), Input2.GetMouseY());
- selectedimage2 = MousePos.y/ImageSize + ImgListNum;
- }
- if((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl)) && Input.IsKeyDown(sf::Key::F) && Input.IsMouseButtonDown(sf::Mouse::Left))
- {
- sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY());
- int x=MousePos.x/ImageSize;
- int y=MousePos.y/ImageSize;
- Fill(x,y,selectedimage);
- }
- else if((Input.IsKeyDown(sf::Key::LControl) || Input.IsKeyDown(sf::Key::RControl)) && Input.IsKeyDown(sf::Key::F) && Input.IsMouseButtonDown(sf::Mouse::Right))
- {
- sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY());
- int x=MousePos.x/ImageSize;
- int y=MousePos.y/ImageSize;
- Fill(x,y,selectedimage2);
- }
- return;
- }
- void TileMap::LoadSprites()
- {
- Sprites.resize(Images.size());
- for(int i = 0; i < Sprites.size(); i++)
- Sprites[i].SetImage(Images[i]);
- return;
- }
- void TileMap::LoadVisualSprites()
- {
- VisualSprites.resize(VisualImages.size());
- for(int i = 0; i < VisualSprites.size(); i++)
- VisualSprites[i].SetImage(VisualImages[i]);
- return;
- }
- void TileMap::LoadFile()
- {
- fstream map;
- string map_path;//Holds the path to the files
- try
- {
- map_path = "data/maps/" + MapType + "/" + MapName;
- //cout << map_path.c_str() << "\n";
- map.open(map_path.c_str(), ios::in|ios::binary);
- int memblock[2];
- //int* memblock;
- if(map.is_open())
- {
- //memblock = new int [2];
- //map.seekg(0, ios::beg);
- map.read((char*)memblock, 2 * sizeof(int));
- MapWidth = memblock[0];
- MapHeight = memblock[1];
- //delete[] memblock;
- int mapblock[MapWidth * MapHeight];
- MapData.resize(MapWidth * MapHeight);
- //map.seekg(2, ios::beg);
- map.read((char*)mapblock, MapWidth * MapHeight * sizeof(int));
- for(int i = 0; i < (MapWidth * MapHeight); i++)
- MapData[i] = mapblock[i];
- //cout << MapData[0];
- //cout << map_path.c_str();
- map.close();
- }
- }
- catch(exception& e)
- {cout << e.what() << "\n";}
- return;
- }
- void TileMap::LoadVisualFile()
- {
- fstream map;
- string map_path;//Holds the path to the files
- try
- {
- map_path = "data/maps/visual/" + MapName;
- //cout << map_path.c_str() << "\n";
- map.open(map_path.c_str(), ios::in|ios::binary);
- int memblock[2];
- //int* memblock;
- if(map.is_open())
- {
- //memblock = new int [2];
- //map.seekg(0, ios::beg);
- map.read((char*)memblock, 2 * sizeof(int));
- MapWidth = memblock[0];
- MapHeight = memblock[1];
- //delete[] memblock;
- int mapblock[MapWidth * MapHeight];
- VisualMap.resize(MapWidth * MapHeight);
- //map.seekg(2, ios::beg);
- map.read((char*)mapblock, MapWidth * MapHeight * sizeof(int));
- for(int i = 0; i < (MapWidth * MapHeight); i++)
- VisualMap[i] = mapblock[i];
- //cout << MapData[0];
- //cout << map_path.c_str();
- map.close();
- }
- }
- catch(exception& e)
- {cout << e.what() << "\n";}
- return;
- }
- void TileMap::SaveFile()
- {
- fstream map;
- string map_path;
- map_path = "data/maps/" + MapType + "/" + MapName;
- map.open(map_path.c_str(), ios::out|ios::binary);
- if(map.is_open())
- {
- int memblock[MapWidth * MapHeight + 2];
- memblock[0] = MapWidth;
- memblock[1] = MapHeight;
- for(int i = 0; i < (MapWidth * MapHeight); i++)
- memblock[i + 2] = MapData[i];
- map.write((char*)memblock, (MapWidth * MapHeight + 2) * sizeof(int));
- map.close();
- }
- return;
- }
- void TileMap::GetEvents()
- {
- sf::Event Event;
- while(App.GetEvent(Event))
- if(Event.Type == sf::Event::Closed)
- {
- App.Close();
- App2.Close();
- }
- return;
- }
- void TileMap::Display()
- {
- LoadSprites();
- sf::FloatRect Rect = View.GetRect();
- //for (int y = (Rect.Top / 64) - 1; y < (int)(Rect.Bottom / 64) + 1; y++)
- for(int y = 0; y < MapHeight; y++)
- {
- if(y < 0)
- y = 0;
- else if (y > MapHeight - 1)
- y = MapHeight - 1;
- //for (int x = (Rect.Left / 64) - 1; x < (int)(Rect.Right / 64) + 1; x++)
- for(int x = 0; x < MapWidth; x++)
- {
- if(x < 0)
- x = 0;
- else if (x > MapWidth - 1)
- x = MapWidth - 1;
- if (MapData[x + (y * MapWidth)] != -1)
- {
- Sprites[MapData[x + (y * MapWidth)]].SetPosition(x * ImageSize, y * ImageSize);
- App.Draw(Sprites[MapData[x + (y * MapWidth)]]);
- }
- }
- }
- App.Draw(Shapes[0]);
- for(int i = 0; i < 10; i++)
- {
- Sprites[i + ImgListNum].SetPosition(0, i * ImageSize);
- //cout << i + ImgListNum;
- App2.Draw(Sprites[i + ImgListNum]);
- }
- Shapes[1].SetPosition(0, ImageSize * (selectedimage - ImgListNum));
- Shapes[2].SetPosition(0, ImageSize * (selectedimage2 - ImgListNum));
- for(int i = 1; i < Shapes.size(); i++)
- App2.Draw(Shapes[i]);
- App.Display();
- App2.Display();
- return;
- }
- void TileMap::VisualDisplay()
- {
- sf::FloatRect Rect = View.GetRect();
- //for (int y = (Rect.Top / 64) - 1; y < (int)(Rect.Bottom / 64) + 1; y++)
- for(int y = 0; y < MapHeight; y++)
- {
- if(y < 0)
- y = 0;
- else if (y > MapHeight - 1)
- y = MapHeight - 1;
- //for (int x = (Rect.Left / 64) - 1; x < (int)(Rect.Right / 64) + 1; x++)
- for(int x = 0; x < MapWidth; x++)
- {
- if(x < 0)
- x = 0;
- else if (x > MapWidth - 1)
- x = MapWidth - 1;
- if (VisualMap[x + (y * MapWidth)] != -1)
- {
- VisualSprites[VisualMap[x + (y * MapWidth)]].SetPosition(x * ImageSize, y * ImageSize);
- App.Draw(VisualSprites[VisualMap[x + (y * MapWidth)]]);
- }
- if (MapData[x + (y * MapWidth)] != -1)
- {
- Sprites[MapData[x + (y * MapWidth)]].SetPosition(x * ImageSize, y * ImageSize);
- App.Draw(Sprites[MapData[x + (y * MapWidth)]]);
- }
- }
- }
- App.Draw(Shapes[0]);
- for(int i = 0; i < 10; i++)
- {
- Sprites[i + ImgListNum].SetPosition(0, i * ImageSize);
- App2.Draw(Sprites[i + ImgListNum]);
- }
- Shapes[1].SetPosition(0, ImageSize * (selectedimage - ImgListNum));
- Shapes[2].SetPosition(0, ImageSize * (selectedimage2 - ImgListNum));
- for(int i = 1; i < Shapes.size(); i++)
- App2.Draw(Shapes[i]);
- App.Display();
- App2.Display();
- return;
- }
- TileMap::TileMap()
- {
- bool load = false;
- MapTypes.push_back("visual");
- MapTypes.push_back("collision");
- MapTypes.push_back("transitional");
- MapTypes.push_back("events");
- MapTypes.push_back("NPC");
- int choice = -1;
- while(choice < 0 || choice > MapTypes.size())
- {
- system("cls");
- cout << "Map Type";
- for(int i = 0; i < MapTypes.size(); i++)
- cout << "\n" << i << ":\t" << MapTypes[i];
- cout << "\n(1, 2, 3, 4...): ";
- cin >> choice;
- }
- MapType = MapTypes[choice];
- cout << "Do you want to load a map? (1/0)";
- cin >> load;
- if(load)
- {
- cout << "Name of Map to Load: ";
- cin >> MapName;
- LoadFile();
- }
- else
- {
- cout << "Name of New Map: ";
- cin >> MapName;
- cout << "Input Map Size (X Y): ";
- cin >> MapWidth >> MapHeight;
- MapData.resize(MapWidth * MapHeight, -1);
- }
- cout << "Input Image Size: ";
- cin >> ImageSize;
- App.Create(sf::VideoMode(1088, 832), MapType + " - " + MapName);
- App2.Create(sf::VideoMode(64, 640), "Images");
- App.UseVerticalSync(true);
- App2.UseVerticalSync(true);
- View.SetFromRect(sf::FloatRect(0,0,1088,832));
- App.SetView(View);
- LoadImages();
- cout << "Images Loaded\n";
- LoadSprites();
- if(MapType != "visual")
- {
- LoadVisualFile();
- LoadVisualImages();
- LoadVisualSprites();
- }
- cout << "Sprites Loaded\n";
- selectedimage = 0;
- selectedimage2 = 1;
- ImgListNum = 0;
- Shapes.push_back(sf::Shape::Rectangle(0,0,(MapWidth * ImageSize), (MapHeight * ImageSize),sf::Color(255,255,255,0),4,sf::Color(0,0,255,127)));
- Shapes.push_back(sf::Shape::Rectangle(0,0,ImageSize,ImageSize,sf::Color(255,255,255,0),4,sf::Color(0,0,255,127)));
- Shapes.push_back(sf::Shape::Rectangle(0,0,ImageSize,ImageSize,sf::Color(255,255,255,0),4,sf::Color(0,255,0,127)));
- }
- void TileMap::Fill(int arg1, int arg2, int value)
- {
- //int arg3 = -1, arg4 = -1, hold1, hold2;
- //const sf::Input& Input = App.GetInput();
- bool ButtonDown = true;
- sf::Event Event;
- while(ButtonDown)
- {
- while (App.GetEvent(Event))
- {
- if(Event.Type == sf::Event::MouseButtonReleased)
- {
- ButtonDown = false;
- cout << "released";
- }
- }
- }
- while (!ButtonDown)
- {
- //cout << "Stuck";
- ButtonDown = FillInput(arg1, arg2, value);
- App.Clear();
- if(MapType == "visual")
- Display();
- else
- VisualDisplay();
- }
- return;
- }
- void TileMap::FillBlock(int x1, int y1, int x2, int y2, int value)
- {
- for(int i = y1; i < y2; i++)
- for(int n = x1; n < x2; n++)
- MapData[n + (i * MapWidth)] = value;
- return;
- }
- bool TileMap::FillInput(int arg1, int arg2, int value)
- {
- const sf::Input& Input = App.GetInput();
- float Time, Offset;
- Time = App.GetFrameTime();
- if (Input.IsMouseButtonDown(sf::Mouse::Left) || Input.IsMouseButtonDown(sf::Mouse::Right))
- {
- sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY());
- int arg3=MousePos.x/ImageSize;
- int arg4=MousePos.y/ImageSize;
- if (arg3 < 0)
- arg3 = 0;
- if (arg4 < 0)
- arg4 = 0;
- if (arg3 > MapWidth - 1)
- arg3 = MapWidth - 1;
- if (arg4 > MapHeight - 1)
- arg4 = MapHeight - 1;
- if(arg1 < arg3)
- {
- int hold1 = arg1;
- arg1 = arg3;
- arg3 = hold1;
- }
- if(arg2 < arg4)
- {
- int hold2 = arg2;
- arg2 = arg4;
- arg4 = hold2;
- }
- FillBlock(arg1,arg2,arg3,arg4,value);
- cout << "fill\n";
- return true;
- }
- Offset=Time*640;
- if (Input.IsKeyDown(sf::Key::Left))
- View.Move(-Offset, 0);
- if (Input.IsKeyDown(sf::Key::Right))
- View.Move(Offset,0);
- if (Input.IsKeyDown(sf::Key::Up))
- View.Move(0,-Offset);
- if (Input.IsKeyDown(sf::Key::Down))
- View.Move(0,Offset);//Pans the camera
- if (Input.IsKeyDown(sf::Key::A))
- View.Move(-Offset, 0);
- if (Input.IsKeyDown(sf::Key::D))
- View.Move(Offset,0);
- if (Input.IsKeyDown(sf::Key::W))
- View.Move(0,-Offset);
- if (Input.IsKeyDown(sf::Key::S))
- View.Move(0,Offset);
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement