Reputation: 7025
I know you may regard this post as another duplicate, while it's not. It's not a duplicate because my code is different than others, and nobody else's post (that I have seen) has solved my problem.
Here is my code:
#include "sprite.h"
SDL_Surface * SPRITE::screen;
int player;
void DrawPlayer(int x, int y) {
SDL_Rect rect = {x,y,20,20};
SDL_FillRect(SPRITE::screen, &rect, 0x00CC00);
}
DrawPlayer(20,20);
The error is on the line DrawPlayer(20,20);
Upvotes: 0
Views: 1223
Reputation: 2344
Try this:
#include "sprite.h"
SDL_Surface * SPRITE::screen;
int player;
void DrawPlayer(int x, int y) {
SDL_Rect rect = {x,y,20,20};
SDL_FillRect(SPRITE::screen, &rect, 0x00CC00);
}
int main()
{
DrawPlayer(20,20);
return 0;
}
Upvotes: 2
Reputation: 5744
You cannot have your call to DrawPlayer
outside of any method. The call must be inside a class method or a global method.
Upvotes: 2