Random SDL_Rects resizing/deleting themselves?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Random SDL_Rects resizing/deleting themselves?

Post by ibly31 »

I'm making a map editor for a 2D RPG, and I'm using SDL_Rects for collision, so I can do custom collision for pretty much whatever I want. In the editor, you draw them with the Middle Mouse Button... For some reason, whenever I scroll away from where I drew the Rectangle... when I come back 1/20th of the time, the rectangle has resized itself, or completely deleted itself. Does anyone know of/ has had any problems relating to this, with rectangles randomly deciding to give themselves a haircut?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: Random SDL_Rects resizing/deleting themselves?

Post by programmerinprogress »

I had a similar problem once before, I believe I was colliding some SDL rects really fast into a wall, and shrank to half their size, but in all honesty, I don't know how I fixed it, and I don't have a clue what I did in the first place (but it's never happened again)
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Random SDL_Rects resizing/deleting themselves?

Post by ibly31 »

it seemed that any rects with a w/h that ends up past 1024 or 768 respectively, cuts itself down to size to fit into that, or into the screen. After like a half hour of researching through the docs, I ended up making my own class. It works perfectly now.

Code: Select all

class rect {
Public:
int x,y,w,h
};
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Random SDL_Rects resizing/deleting themselves?

Post by Arce »

It's been a looong while since I've used SDL...But I do seem to recall having a similar problem. From what I understood, you cannot move a rect offscreen...Ever. You'd be blitting off the surface. So SDL simply resizes the rect to give the appearance that it's going off the screen--basically it catches your fuckup gracefully.

Though there's always the fat chance that I don't remember correctly, am an idiot, etc, so don't quote me on this one. ;p

Have you tried googling it?
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Random SDL_Rects resizing/deleting themselves?

Post by ibly31 »

ibly31 wrote:it seemed that any rects with a w/h that ends up past 1024 or 768 respectively, cuts itself down to size to fit into that, or into the screen. After like a half hour of researching through the docs, I ended up making my own class. It works perfectly now.

Code: Select all

class rect {
Public:
int x,y,w,h
};
It works now. But thanks, that's pretty much what I guessed except a little more detailed. I'm using Visual basic to make a NPC editor, I'm suprised at how EASy it is!
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Random SDL_Rects resizing/deleting themselves?

Post by Arce »

Haha, true dat.

Start building...But without a framework. ;)

That's something we'd probably make peter pull out of his asshole.

Yes, things are always easier in BASIC languages for that reasoning...Until you begin trying to solve some of the more complex problems. Then you end up running into language limitations and would have been better off starting off in C++ or another powerful, lower-level language.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
Scoody
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Fri Feb 06, 2009 2:07 pm

Re: Random SDL_Rects resizing/deleting themselves?

Post by Scoody »

Just nitpicking a litte; since you're not using any class "things":

Code: Select all

struct rect {
  int x,y,w,h;
};
Don't start a holy war, please. :)
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Random SDL_Rects resizing/deleting themselves?

Post by dandymcgee »

Scoody wrote:Just nitpicking a litte; since you're not using any class "things":

Code: Select all

struct rect {
  int x,y,w,h;
};
Don't start a holy war, please. :)
BTW, the struct and class keywords do EXACTLY the same thing in C++. Only difference is structs are public by default where as classes are private. :)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Scoody
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Fri Feb 06, 2009 2:07 pm

Re: Random SDL_Rects resizing/deleting themselves?

Post by Scoody »

dandymcgee wrote: BTW, the struct and class keywords do EXACTLY the same thing in C++. Only difference is structs are public by default where as classes are private. :)
As I said, only nitpicking.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Random SDL_Rects resizing/deleting themselves?

Post by dandymcgee »

Scoody wrote:As I said, only nitpicking.
Same. :mrgreen:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply