Hmm...more C++ errors

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

Hmm...more C++ errors

Post by psiko_scweek »

Arlight not too sure if you remember me, I was having a bunch of problems using std::vector.

Eitherway it all boiled down to my problem laying with the fact that I had my For Loop outside of a function of my main loop (oops!). Now I can get it to compile but it wont do anything now! When I run the eboot the screen is blank.

Anyone care to look at my code and lemme know where I messed up?


Object Constructors

Code: Select all

/////////// INITIALIZE THE OBJECT STRUCTURES ///////////
class Object 
{ 
protected: 
int x, y; 
int graphicwidth;
int graphicheight;
int height, width;
int solid;
SDL_Surface *graphic;

public: 
Object(int tempx, int tempy, SDL_Surface *tempgraphic)
{;};
Object(){;};
~Object();
void step(); 
void draw(); 
void setGraphicHeight(int tempHeigt);
void setGraphicWidth(int tempWidth);
int getGraphicHeight();
int getGraphicWidth();
void setSolid(int tempSolid);
void setX(int tempX);
void setY(int tempY);
int getX();
int getY();
int direction;
void setGraphic(SDL_Surface *graphic);
};


/////////// SETUP THE OBJECTS CONSTRUCTOR ///////////
Object::Object(int tempx, int tempy, SDL_Surface *tempgraphic)
{
x = tempx;
y = tempy;
graphic = tempgraphic;
graphicwidth = graphic->w;
graphicheight = graphic->h;
solid = 0;
}


/////////// SETUP THE OBJECTS DESTRUCTOR ///////////
Object::~Object()
{
if (graphic)
   {SDL_FreeSurface(graphic);}
}
SubObjects

Code: Select all

/////////// CREATE THE BLOCK OBJECT, CHILD OF OBJECT ///////////
class PlayerBlocks : public Object{
private:
int color;

public:
PlayerBlocks(int tempx,int tempy, SDL_Surface *graphic) : Object(tempx, tempy, graphic) {;}
void setColor(int tempcolor);
int selected;
void input();
};

/////////// CREATE THE MASTERCONTROL OBJECT, CHILD OF OBJECT ///////////
class MasterControl : public Object {
public:
MasterControl(int tempx,int tempy, SDL_Surface *graphic) : Object(tempx, tempy, graphic) {;}
void input();
};
creating the objects

Code: Select all

/////////// CREATE THE OBJECTS /////////// 

std&#58;&#58;vector<PlayerBlocks> VerticalBlue;
MasterControl Master&#40;0,0,NULL&#41;;
Object Background&#40;0,0,gfx_background&#41;;
Object Titleimage&#40;0,0,gfx_titleimage&#41;;
Object Bottomimage&#40;0,233,gfx_bottomimage&#41;;
Object TopWall&#40;16,120,gfx_topwall&#41;;
Object BottomWall&#40;&#40;SCR_H&#41;-16, 120, gfx_bottomwall&#41;;
Object LeftWall&#40;120,10, gfx_leftwall&#41;;
Object RightWallTop&#40;363, 16, gfx_rightwalltop&#41;;
Object RightWallBottom&#40;363,&#40;SCR_H&#41;-&#40;13+RightWallBottom.getGraphicHeight&#40;&#41;&#41;, gfx_rightwallbottom&#41;;

Code: Select all

for&#40;int i = 0;i < NumberOfBlocks;i++&#41;
&#123;
VerticalBlue.push_back&#40;PlayerBlocks&#40;0,0,NULL&#41;&#41;;
&#125;


/////////// SET UP THE OBJECTS ///////////
VerticalBlue&#91;1&#93;.setGraphic&#40;gfx_bluevertical&#41;;
VerticalBlue&#91;1&#93;.setX&#40;&#40;SCR_W/2&#41;-&#40;VerticalBlue&#91;1&#93;.getGraphicWidth&#40;&#41;/2&#41;&#41;;
VerticalBlue&#91;1&#93;.setY&#40;&#40;SCR_H/2&#41;-&#40;VerticalBlue&#91;1&#93;.getGraphicHeight&#40;&#41;/2&#41;&#41;;
VerticalBlue&#91;1&#93;.setColor&#40;2&#41;;
VerticalBlue&#91;1&#93;.selected = 1;
VerticalBlue&#91;1&#93;.direction = 1;
thanks all
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

Code: Select all

&#123;
protected&#58;
int x, y;
int graphicwidth;
int graphicheight;
int height, width;
int solid;
SDL_Surface *graphic;

public&#58;
Object&#40;int tempx, int tempy, SDL_Surface *tempgraphic&#41;
&#123;;&#125;; <-- never seen anything like this, what is it for??
Aion
Posts: 40
Joined: Mon Jul 24, 2006 10:58 pm
Location: Montreal

Post by Aion »

Looks weird, but only declare an empty method for the constructor. Just {} would have done the job.
Post Reply