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?
Quick Fill of a Rectangle?
Moderator: Coders of Rage
- ibly31
- 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?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Moosader
- 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?
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.
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.
- ibly31
- 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?
<-- 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.
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.
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Moosader
- 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?
SDL_DrawRect( SDL_Surface *destination, SDL_Rect *rect, Uint32 color );
google.
google.
- programmerinprogress
- 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?
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
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