Hey all, I've stumbled upon the SDL library, and lately I've been obsessed with c++.
I'm making a simple game with a spaceship that orbits around the sun, currently I'm in the beginning stages. I want to declare a Spaceship Class, and each class I want to have 2 SLD_Rect structs.
As of now I initialize the 2 SDl_Rect structs, and then in another function declare all the structs variables, but when I compile the program it just crashes.
Here is the Space Ship class.
Code:
class Spaceship
{
public:
short int mass;
SDL_Rect dest, source;
bool initialize(short int locationX, short int locationY, short int imageheight, short int imagewidth)
{
dest.x = 100;
dest.y = 100;
dest.w = imagewidth;///this needs to either have image passed into it or needs to have images height and width
dest.y = imageheight;
source.x = 0;
source.y = 0;
source.w = imagewidth;
source.h = imageheight;
return 0;
}
private:
short int stoopid;
};
Here is the Main code.
Code:
#include "SDL/SDL.h"
#include "Setupf.h"
#include "Setupf.cpp"//setup sdl video
#include "Imageloadfunc.h"
#include "Imageloadfunc.cpp"//function for loading and formatting images.
#include "Imageloadfunc.h"
#include "string"
#include "SpaceShipClass.cpp"
int main(int argc, char *argv[])//these are needed for sdl to work.
{
short int height=1000;
short int width=1000;
short int pixels=32;
SDL_Surface *screen, *image;
*screen = (Setup(height,width,pixels));///intializes video
*image = (FormatLoad("Bitty2.bmp"));//loads and formats bitmap
short int imageheight;
short int imagewidth;
imagewidth = image->w;
imageheight = image->h//both of these are passed to Original.initialize;
Spaceship Original;//the first spaceship member
Original.initialize(100,100,imageheight,imagewidth);
SDL_BlitSurface(image,&Original.source,screen,&Original.dest);
SDL_Flip(screen);
SDL_Delay(4444444);
return 0;
}
Any help would be really helpful