My program wont seem to compile when I want to include Player.h
inside Wall.h
, however I can include Wall.h
in Player.h
. I am confused. See code below.
Player.h:
#pragma once
#include <SDL.h>
#include "Entity.h"
#include "Vec2.h"
#include "Wall.h"
#include "Timer.h"
namespace LyingD
{
class Player : public Entity
{
public:
Player() = default;
Player(float x, float y, float w, float h, float speed, float gForceX, float gForceY);
Timer jumpTimer;
bool jumping = false;
Timer fallTimer;
bool isFalling = false;
bool onTheGround = false;
Vec2 speed;
Vec2 velocity;
Vec2 acceleration;
Vec2 gForce;
void wallCollision(Wall walls[], int numOfWalls);
void jump(Timer mainTimer, Wall walls[], int numOfWalls);
void moveUp(Timer mainTimer, Wall walls[], int numOfWalls);
void moveDown(Timer mainTimer, Wall walls[], int numOfWalls);
void moveRight(Timer mainTimer, Wall walls[], int numOfWalls);
void moveLeft(Timer mainTimer, Wall walls[], int numOfWalls);
void gravity(Timer mainTimer, Wall walls[], int numOfWalls);
};
}
Wall.h:
#pragma once
#include <iostream>
#include <SDL.h>
#include "Entity.h"
namespace LyingD
{
class Wall : public Entity
{
public:
Wall() = default;
Wall(float x, float y, float w, float h)
{
this->size = Vec2(w, h);
this->position = Vec2(x, y);
}
};
}
Entity:
#pragma once
#include "SDL.h"
#include "Vec2.h"
namespace LyingD
{
class Entity
{
public:
Entity() = default;
Entity(float x, float y, float width, float height) :
position(x, y), size(width, height) {}
Vec2 position;
Vec2 posBuffer = position;
Vec2 size;
int checkCollision(Entity object);
};
}
The errors I get are:
1>C:\Users\Gebruiker\Desktop\C++ Projects\Developed\Camera.h(28,1): error C2660: 'LyingD::Player::wallCollision': function does not take 2 arguments
1>C:\Users\Gebruiker\Desktop\C++ Projects\Developed\Player.h(29,8): message : see declaration of 'LyingD::Player::wallCollision'
It does that for every instance of Wall
.
However, it does take 2 arguments.