Original Post
I am having an issue with SDL and C++ classes. Basically, I want my Player to have a class of its own, so I made this (Player.cpp):
I've got my main file, with the main () function, and the drawing functions. I wanted to call something like "Player player = new Player ();" (Java, Python and other languages allow me to do something like this).
I guessed that I would have to compile Player.cpp first, but it complains about not having a main function and whatnot.
So, I have a few questions:
- How can I have my own SDL Player class, and associate it with one or more sprites;
- I heard that I need header files to link the files, but I have no idea how;
- How to compile the different files, I am using a Makefile to build the game btw;
Thank you tons in advance.
Oh, and regarding question #1, I would also like to know how I can call the Player class from the main file so that then I can draw it.
#include <SDL/SDL.h>
class Player {
int x;
int y;
};I've got my main file, with the main () function, and the drawing functions. I wanted to call something like "Player player = new Player ();" (Java, Python and other languages allow me to do something like this).
I guessed that I would have to compile Player.cpp first, but it complains about not having a main function and whatnot.
So, I have a few questions:
- How can I have my own SDL Player class, and associate it with one or more sprites;
- I heard that I need header files to link the files, but I have no idea how;
- How to compile the different files, I am using a Makefile to build the game btw;
Thank you tons in advance.
Oh, and regarding question #1, I would also like to know how I can call the Player class from the main file so that then I can draw it.