Quick Fill of a Rectangle?

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.

Quick Fill of a Rectangle?

Post by ibly31 »

I'm working on the collision for my RPG. The way I'm going to come at it is to have an array of SDL_Rects, and test each one per loop. In the editor, I'm making you draw with the Middle Scroll Wheel. (clicking). To show where the rectangle is that you drew, I'm making it fill the rectangle.

Does anyone have the code snippet to fill a rectangle? I know the SDL_FillRect(), but it needs a surface, and its really messy.

Can SDL_Rects be filled on the screen? Or are they just fo' data?
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
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Quick Fill of a Rectangle?

Post by Moosader »

coordinates is a SDL_Rect,
destination is a SDL_Surface
r, g, b are ints
SDL_FillRect( destination, &coordinates, SDL_MapRGB( destination->format, r, g, b ) );

I think they can be used on the screen,not totally sure. I think I did it once.
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: Quick Fill of a Rectangle?

Post by ibly31 »

<-- COMPLETELY IGNORE THIS, I AM AN IDIOT-->

Oh! *dst shoulda been a flag... Um, how do you use Uint 8? It's like 0xA for black, why can't they just use RGB...? What is the Uint 8 code for Red? {255,0,0} red.

<-- END IGNORATION PLOX :3 -->

EDIT: Is there a way to have a Red border, with transparent inside? I kinda need to see whats behind it to make good collision.
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
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Quick Fill of a Rectangle?

Post by Moosader »

SDL_DrawRect( SDL_Surface *destination, SDL_Rect *rect, Uint32 color );


google.
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: Quick Fill of a Rectangle?

Post by programmerinprogress »

Also consider adding The SDL DocWiki: http://www.libsdl.org/cgi/docwiki.cgi to your bookmarks aswell, you wouldn't believe how much time i've saved finding something in here, top notch :)
---------------------------------------------------------------------------------------
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
Post Reply