 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
psiko_scweek
Joined: 12 Nov 2005 Posts: 42
|
Posted: Sat Sep 30, 2006 8:25 am Post subject: Hmm...more C++ errors |
|
|
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: | /////////// 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: | /////////// 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: | /////////// CREATE THE OBJECTS ///////////
std::vector<PlayerBlocks> VerticalBlue;
MasterControl Master(0,0,NULL);
Object Background(0,0,gfx_background);
Object Titleimage(0,0,gfx_titleimage);
Object Bottomimage(0,233,gfx_bottomimage);
Object TopWall(16,120,gfx_topwall);
Object BottomWall((SCR_H)-16, 120, gfx_bottomwall);
Object LeftWall(120,10, gfx_leftwall);
Object RightWallTop(363, 16, gfx_rightwalltop);
Object RightWallBottom(363,(SCR_H)-(13+RightWallBottom.getGraphicHeight()), gfx_rightwallbottom); |
| Code: | for(int i = 0;i < NumberOfBlocks;i++)
{
VerticalBlue.push_back(PlayerBlocks(0,0,NULL));
}
/////////// SET UP THE OBJECTS ///////////
VerticalBlue[1].setGraphic(gfx_bluevertical);
VerticalBlue[1].setX((SCR_W/2)-(VerticalBlue[1].getGraphicWidth()/2));
VerticalBlue[1].setY((SCR_H/2)-(VerticalBlue[1].getGraphicHeight()/2));
VerticalBlue[1].setColor(2);
VerticalBlue[1].selected = 1;
VerticalBlue[1].direction = 1;
|
thanks all |
|
| Back to top |
|
 |
Wally

Joined: 26 Sep 2005 Posts: 672
|
Posted: Sat Sep 30, 2006 7:26 pm Post subject: |
|
|
| Code: | {
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)
{;}; <-- never seen anything like this, what is it for??
|
|
|
| Back to top |
|
 |
Aion
Joined: 24 Jul 2006 Posts: 40 Location: Montreal
|
Posted: Sat Sep 30, 2006 11:51 pm Post subject: |
|
|
| Looks weird, but only declare an empty method for the constructor. Just {} would have done the job. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|