Good day, I´m relatively new to using SFML, I watched a ton of diferent videos for class and using it with SFML, I get the idea how it works but for some reason it wont work and I have no idea why, I made 3 classes and all of them I comented out and used meanwhile some copy-paste ones as replacment.
my header file :#pragma once
#include <SFML/Graphics.hpp>
class MyMap
{
public:
MyMap(std::string &MapName, unsigned int width, unsigned int height, const int* tiles,
unsigned int StartX, unsigned int StartY, unsigned int SizeOfOne, const int NumberofObjects);
~MyMap();
/*void draw(sf::RenderWindow &window);*/
private:
sf::Sprite sprite;
};
My cpp:#include "MyMap.h"
#include "Resource.h"
MyMap::MyMap(std::string &MapName, unsigned int width, unsigned int height,const int* tiles,
unsigned int StartX,unsigned int StartY,unsigned int SizeOfOne,const int NumberofObjects)
{
sf::Sprite Osprite[10],OverlayMapS[2];
sprite.setTexture(Resource::getTexture(MapName));
for (int a = 0; a <= NumberofObjects; a++)
{
Osprite[a] = sprite;
Osprite[a].setTextureRect(sf::IntRect(StartX, SizeOfOne, StartY, SizeOfOne));
Osprite[a].setOrigin(SizeOfOne/2, SizeOfOne/2);
}
for (unsigned int i = 0; i < width; i++)
{
for (unsigned int j = 0; j < height; j++)
{
int curentObject = tiles[i + j * width];
Osprite[curentObject].setPosition(i*SizeOfOne,j*SizeOfOne);
}
}
}
MyMap::~MyMap()
{
}
and my implementation in the main [/size][/size]
const int MPC[] =
{
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3,
0, 1, 0, 0, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 0, 0,
0, 1, 1, 0, 3, 3, 3, 0, 0, 0, 1, 1, 1, 2, 0, 0,
0, 0, 1, 0, 3, 0, 2, 2, 0, 0, 1, 1, 1, 1, 2, 0,
2, 0, 1, 0, 3, 0, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1,
0, 0, 1, 0, 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
MyMap map(
window,"Map.png", 16, 12, MPC,0,0, 40,4);
It show an Error when i implement
window from my own fuction in MyMap class, I just cant get the constructor right, Can somebody help me ??