okay thanks for the reply. I believe it's where I'm putting the *.
so I have Image.h and Image.cpp, I already have my draw functions for rendering a background image, and a sprite. Now I'm trying to use my function that I have from the main.cpp and implement it in the class. Here's the errors I'm getting:
Code:
C:\Users\Cody\Desktop\Anotherattempatclasses\src\Image.cpp||In function 'SDL_Surface Image::* getImage(std::string, int)':|
C:\Users\Cody\Desktop\Anotherattempatclasses\src\Image.cpp|55|error: cannot convert 'SDL_Surface*' to 'SDL_Surface Image::*' in return|
C:\Users\Cody\Desktop\Anotherattempatclasses\src\Image.cpp|56|warning: control reaches end of non-void function|
||=== Build finished: 1 errors, 1 warnings ===|
Image.h
Code:
#ifndef IMAGE_H
#define IMAGE_H
#include <string>
#include "sdl\sdl.h"
#define BMP_IMAGE 0
#define JPEG_IMAGE 1
class Image
{
public:
Image();
virtual ~Image();
void addSurface(int, int, SDL_Surface*, SDL_Surface*);
void drawSprite(int, int, int, int, int, int, SDL_Surface*, SDL_Surface*);
protected:
private:
};
#endif // IMAGE_H
Image.cpp
Code:
#include "Image.h"
Image::Image()
{
//ctor
}
Image::~Image()
{
//dtor
}
void Image::addSurface(int x, int y, SDL_Surface* source, SDL_Surface* dest)
{
SDL_Rect box;
box.x = x;
box.y = y;
SDL_BlitSurface(source, NULL, dest, &box);
}
void Image::drawSprite(int srcX, int srcY, int dstX, int dstY, int width, int height, SDL_Surface* source, SDL_Surface* dest)
{
SDL_Rect src;
src.x = srcX;
src.y = srcY;
src.w = width;
src.h = height;
SDL_Rect dst;
dst.x = dstX;
dst.y = dstY;
dst.w = width;
dst.h = height;
SDL_BlitSurface(source, &src, dest, &dst);
}
SDL_Surface Image::*getImage(std::string filename, int imageType)
{
SDL_Surface* image;
switch(imageType)
{
case BMP_IMAGE:
image = SDL_LoadBMP(filename.c_str());
break;
case JPEG_IMAGE:
break;
}
if(image == NULL)
{
return NULL;
}
image = SDL_DisplayFormat(image);
return image;
}
Thanks... And looking at the errors now they do not really make sense to me because it's about the return, but it worked fine in the main.cpp