i'm working on an intake assignment for a game development course but i'm stuck with an annoying error by visual studio after splitting my code into classes. The error states LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
So it should be something wrong in my main function. I've looked around and the most logical reason seemt to be wrong subsystem but that's set to console application. Here's my code:
Main.cpp:
#include <Box2D/Box2D.h>
#include <SFML/Graphics.hpp>
#include "Game.hpp"
int main() {
Game game; //Sets up the game
game.populateWorld();
while (game.window.isOpen()) {
game.checkEvents();
game.drawBodies();
game.m_Player->movePlayer();
}
return 0;
}
Game.hpp:
#ifndef Game_hpp
#define Game_hpp
#include <SFML/Graphics.hpp>
#include "World.hpp"
#include "Player.hpp"
class Game {
public:
Game();
void checkEvents();
void drawBodies();//Displays the bodies and keeps the view centered
//Public data members to be used by other classes
sf::Texture backGroundTexture;
sf::Texture playerTex;
sf::Texture platformTex;//Doesn't have a sprite declared since multiple copy's will be made
sf::Sprite backGround;
sf::Sprite player;
sf::View view;
sf::RenderWindow window;
const float m_Scale;//Number of pixels per meter
Player* m_Player = NULL;
World* m_World = NULL;
void populateWorld();
private:
void loadResources();//Loads resources and applies them where needed
};
#endif // !Game_hpp
World.hpp:
#ifndef World_hpp
#define World_hpp
#include <Box2D/Box2D.h>
class World {
public:
//Public member functions
World(const float scale);
~World();
void step();
b2Body* spawnPlayer(float x, float y);
//Public data members
b2World* world = NULL; //Points to the entire world! Handle with care ;)
void createPlatform(b2Vec2 point);
private:
//Private data members
b2Vec2 gravity;
const float m_Scale;
//Declaring step values
float32 m_TimeStep;
int32 m_VelocityIterators;
int32 m_PositionIterators;
};
#endif // !World_hpp
Player.hpp:
#ifndef Player_hpp
#define Player_hpp
#include <Box2D/Box2D.h>
#include "World.hpp"
class Player{
public:
Player(World* world, const float scale, float x, float y);
void movePlayer();
b2Body* m_PlayerBody;//A pointer to the player Character's body needed for the movement
private:
World* m_World;
const float m_Scale;
};
#endif // !Player_hpp
Hope anyone can point me in the right direction with what's going wrong :)