### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Messages - Astrof

Pages: 1 ... 6 7 [8] 9
106
##### Graphics / Rounded Rectangles
« on: February 15, 2009, 05:38:01 am »
Here is the code (as a function):
Code: [Select]
`#define POINTS 10sf::Shape& RoundedRectangle(float x, float y, float rectWidth, float rectHeight, float radius, const sf::Color& Col, float Outline, const sf::Color& OutlineCol){ sf::Shape* rrect=new sf::Shape(); rrect->SetOutlineWidth(Outline); float X=0,Y=0; for(int i=0; i<POINTS; i++) { X+=radius/POINTS; Y=sqrt(radius*radius-X*X); rrect->AddPoint(X+x+rectWidth-radius,y-Y+radius,Col,OutlineCol); } Y=0; for(int i=0; i<POINTS; i++) { Y+=radius/POINTS; X=sqrt(radius*radius-Y*Y); rrect->AddPoint(x+rectWidth+X-radius,y+rectHeight-radius+Y,Col,OutlineCol); } X=0; for(int i=0; i<POINTS; i++) { X+=radius/POINTS; Y=sqrt(radius*radius-X*X); rrect->AddPoint(x+radius-X,y+rectHeight-radius+Y,Col,OutlineCol); } Y=0; for(int i=0; i<POINTS; i++) { Y+=radius/POINTS; X=sqrt(radius*radius-Y*Y); rrect->AddPoint(x-X+radius,y+radius-Y,Col,OutlineCol); } return *rrect; }`
I don't know if it was the most efficient way to go about doing this, but this is how my mind worked when I was coding it.  If there is a way to make this code in any way better, I'd like to know; I'm fairly new to C++ (coming from Java).  Anyone is free to use this code, modify it, etc.

107
##### Audio / Looping a music from a certain point
« on: February 14, 2009, 11:01:11 pm »
i just do a simple:
Code: [Select]
`sf::Music music;music.OpenFromFile("SolarisPhase2Theme.aif");music.SetLoop(true);music.Play();`
there seems to be like a half a second lag.

108
##### Graphics / Rounded Rectangles
« on: February 14, 2009, 10:38:04 pm »
Ok, so I (finally) made my own RoundedRectangle function.  Here are a few pics of what I have so far:

this is just the RoundedRectangle

This is a Rounded Rectangle along with a Rectangle (given the same Rectangle points).
The radius of the arcs is 15.  I use 40 points total (same as sf::Shape::Circle).  For more or less accuracy you can edit the number of points (right now is a #define statement), but for some reason you can only have an even number (I do a for loop for each corner, so with an N of 10 there's 40 points total).

Can you believe it, I actually had to use Geometry on this... :roll:

109
##### General / App.Close();//Does it free memory used by resources?
« on: February 14, 2009, 12:11:12 am »
hmm ok, thanks, I guess I'll have to be careful in my code then.

110
##### General / App.Close();//Does it free memory used by resources?
« on: February 13, 2009, 08:16:51 pm »
kinda similar to the above question, but if I have a class that stores Images and such, and I close the program (close the exe) is the memory freed? I guess this is a basic C++ question, but just want to know if I don't explicitly use delete on pointers, does the program delete the data it's using (or like does the OS know that the memory used by the now dead program is available)

111
##### General / SFML is bucking
« on: February 13, 2009, 08:13:24 pm »
i didnt mean to make fun of anyone, i just wanted to post an icanhascheezburger quote...
anyway,
can we get back on topic to his problem?

112
##### General / SFML is bucking
« on: February 13, 2009, 03:38:02 pm »
Quote from: "Nexus"
Quote from: "Daazku"
The best def. I founded.
You founded it? Ok... :mrgreen:

113
##### Audio / Looping a music from a certain point
« on: February 11, 2009, 05:15:02 am »
i thought that SFML can't support mp3?

114
##### Audio / Looping a music from a certain point
« on: February 11, 2009, 01:15:15 am »
A lot of songs have some kind of intro sequence in the beginning but then start to loop from another point of the song.  Is there a way to do this in SFML? If not, would the best alternative way be to just manually split the song, play the intro piece, then time it, play the other part then loop?  The only problem with the latter is I seem to have some kind of lag when I play musics, (it's not a loading issue, I load at a different part of the program much before execution begins.

115
##### General / Single instance of a class
« on: February 10, 2009, 05:35:02 am »
oops, just made a singleton thing....
i'll give that article a read though, thanks!

116
##### Graphics / Problems with .Draw
« on: February 08, 2009, 07:45:30 pm »
48 is the ASCII code for 0, 49 is the ASCII code for 1.  so you're probably using chars?  '0' and '1'

117
##### General / Single instance of a class
« on: February 08, 2009, 05:33:36 am »
Ok, this is more of a general C++ question.  I'm trying to use a ResourceManager class to manage resources.  However I want to keep only one instance per program (as it stores all the resources for all of the program) or atleast I want its data to not change per instance if I make multiple instances.

So basically, is there a way I can make a static reference to one instance and just pass that around?

I'm just wondering how I would use a class to manage resources.  I did this in Java programming by just making the constructor private and having one static reference, but I understand C++ is different (and that I could just use namespaces).

Anyway, I figured since the tutorial referenced a Manager class that people would have used it here.

118
##### Audio / How to use an Object Manager with sf::Music? (NonCopyable)
« on: February 07, 2009, 11:55:09 pm »
hmmm ok, I'm using the ResourceManager to hold the Objects and going to access them through the class.

I guess I don't want to modify the Images (I'll be using Sprites for that...right?)
Music I guess can change.  Fonts, I think they can be const

Anyway thanks, it did compile, now I just have to fix the linking of the boost libs (I hate setting up the linker...)

119
##### Audio / How to use an Object Manager with sf::Music? (NonCopyable)
« on: February 07, 2009, 07:11:52 am »
ok, so I do the same for Music and fonts, what do I have to do to change those? (are Images still const? what about Fonts?)

120
##### Audio / How to use an Object Manager with sf::Music? (NonCopyable)
« on: February 06, 2009, 05:25:16 pm »
What shouldn't be const? I'm sorry, I don't really understand the const all that well (I do know it differs from the final keyword from java, but still I don't know exactly how until I look it up).  I guess I have the habit of const-ing everything.

Pages: 1 ... 6 7 [8] 9