The project errors out and states that ofImage and ofPoint do not name a type, but this is how they were coded in the tutorial. Any help on what I did wrong?
This is in the Player.h file. Should it be in Player.cpp?
#ifndef PLAYER_H
#define PLAYER_H
class player
{
public:
//Used to store the height width and speed variables for the player.
float height, width, speed;
//Int used for lives to ensure that lives are always a full number.
int lives;
//This stores the player's position in an ofPoint.
ofPoint pos;
//These bools check to see what inputs are currently pressed.
//Using bools as OpenFrameworks has issues detecting multiple inputs
bool is_left_pressed, is_right_pressed, is_down_pressed, is_up_pressed;
void setup(ofImage * _img);
void update();
void draw();
void shoot();
void calculate_movement();
bool check_can_shoot();
//points towards the sprite for the player.
ofImage * img;
};
#endif // PLAYER_H
Hi @Chubbulus , this is a constructor for class player. It doesn’t look like you declared it in player.h. If player::player() is going to remain an empty function, you can just omit it from your player.cpp file. The compiler will supply a default constructor when one is not defined. Sometimes including an empty constructor like this can cause some issues, so I find its better to omit them if they’re empty functions.
I figured out what the issue was. The guide I was following completley misses adding anything to player.cpp which led to the issue. After digging through some other code and with some help from another forum user, I figured out how the CPP files are supposed to work and the issue was that the functions had nothing defined within player.cpp, as the guide missed that file completley
Hey sure and glad you have it working. I learned a ton from this chapter of ofBook when I was learning c++ and OF. It’s a big one! It covers some really fun things (like OSC), and it’s a larger project with lots of classes and more complexity.
So have fun and just post again in the forum if you have other questions as you go along.