Rectangle problem with leaving screen (SDL)
Posted: Sat Jun 18, 2005 11:09 am
After I finally got my ass up and began SDL learning, I made my first program. The whole thing is a rectangle based shooter, similar to my Blitz "Prick Fight".
The problem is, when I move a rectangle off screen, it permanently removes the portion that I moved off the screen. I do not yet know weather it actually modifies my width and height or if it stops drawing half the rectangle, but has anyone had a similar problem? If so, do you know what is wrong? Is my best bet just making a boundary 5 or so pixels from the edge of the screen to prevent peeps from leaving it? If so, what about bullets, which are also rectangles? That would look gay if they just disappear near the edge of the screen…
I'll do some fprintf's and tell you if it actually changes my x,y,w and h.
If it does change the size, I can just update it when the player re-enter's the screen, but that would make it a hassle to change the player size....
As I currently have it, the player does not have his own X and Y. The player class has a public SDL_Rect object inside it, which has X,Y,W,H as members. Do you think I should make the players have private X,Y,W,H and every time the rectangle's X,Y,W, and H are not equal to them, set them equal?
And, to make these new private members, should I just privately inherit the SDL_Rect class and add some accessors?
As I am sure you can all tell, I am not only new to SDL but also to C++ as a whole, so forgive my many questions. For anyone who actually replies, thanks a bunch. :D
The problem is, when I move a rectangle off screen, it permanently removes the portion that I moved off the screen. I do not yet know weather it actually modifies my width and height or if it stops drawing half the rectangle, but has anyone had a similar problem? If so, do you know what is wrong? Is my best bet just making a boundary 5 or so pixels from the edge of the screen to prevent peeps from leaving it? If so, what about bullets, which are also rectangles? That would look gay if they just disappear near the edge of the screen…
I'll do some fprintf's and tell you if it actually changes my x,y,w and h.
If it does change the size, I can just update it when the player re-enter's the screen, but that would make it a hassle to change the player size....
As I currently have it, the player does not have his own X and Y. The player class has a public SDL_Rect object inside it, which has X,Y,W,H as members. Do you think I should make the players have private X,Y,W,H and every time the rectangle's X,Y,W, and H are not equal to them, set them equal?
And, to make these new private members, should I just privately inherit the SDL_Rect class and add some accessors?
As I am sure you can all tell, I am not only new to SDL but also to C++ as a whole, so forgive my many questions. For anyone who actually replies, thanks a bunch. :D