Welcome, Guest. Please login or register. Did you miss your activation email?

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 - Haze

Pages: 1 ... 5 6 [7] 8 9
91
Graphics / Partially drawing/hiding a sf::Shape::Line
« on: December 03, 2011, 03:22:54 pm »
You could use glScissor: it will only draw objects which are within a rectangle area.
It's really easy to use:

Code: [Select]
glEnable(GL_SCISSOR_TEST);
glScissor(right_x, bottom_y, width, height);

// draw your stuff

glDisable(GL_SCISSOR_TEST);


documentation: http://www.opengl.org/sdk/docs/man/xhtml/glScissor.xml

92
General / Problem with moving/turning a sprite in cursor direction
« on: December 02, 2011, 02:24:36 am »
Hi,

Here my custom angle function, with a demonstration code for what you want.
This should solve your problem.

Code: [Select]
#include <cmath>
#include <SFML/Graphics.hpp>

#define PI 3.14159265f

// return angle between 2 points (radians)
float angle(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
float x = p1.x - p2.x;
if (x == 0.f)
{
return 0.f;
}
float y = p1.y - p2.y;
float radians = std::atan(-y / x);
if (p2.x > p1.x)
{
radians += PI;
}
return radians;
}

// convert radians to degrees
float rad_to_deg(float radians)
{
return radians / PI * 180;
}


int main()
{
sf::RenderWindow app(sf::VideoMode(640, 480, 32), "SFML Window");
sf::Event event;
bool running = true;

sf::Image img;
img.LoadFromFile("images/arrow.png");

// create arrow, centered on screen
sf::Sprite arrow(img);
arrow.SetCenter(img.GetWidth() / 2, img.GetHeight() / 2);
arrow.SetPosition(320, 240);

while (running)
{
while (app.GetEvent(event))
{
if (event.Type == sf::Event::Closed)
{
running = false;
}
else if (event.Type == sf::Event::MouseMoved)
{
sf::Vector2f mouse(event.MouseMove.X, event.MouseMove.Y);
float mouse_angle = rad_to_deg(angle(arrow.GetPosition(), mouse));
arrow.SetRotation(mouse_angle);
}
}

app.Clear();
app.Draw(arrow);
app.Display();
}
app.Close();

return 0;
}

93
SFML projects / Linavalanche
« on: November 27, 2011, 10:02:10 pm »
That's a really nice and original little game! The concept is very challenging.

The program runs fine under Linux with wine.

Minor bug: it seems like sf::Event::Closed is not handled in the Online High-Scores menu.

PS: Eh? No Ninja? :x

94
Feature requests / Extended operations for sf::String
« on: November 18, 2011, 12:40:55 am »
I get your point; I guess it's all about finding the right balance.

Thanks for your time by the way, I always enjoy reading those brainstorming discussions.

95
Feature requests / Extended operations for sf::String
« on: November 17, 2011, 01:54:55 am »
Quote from: "Laurent"
First, I have to say that I hate sf::String, and I don't think that I'll make it a super powerful string class.

Sure, I bet you won't turn it into something like QString.
But std::string objects are so limited...

Quote from: "Laurent"
What can be considered a whitespace? In the Unicode world, there are probably more than the usual {tab, space, line feed} set.

I understand your concern when dealing with Unicode, that's why I suggest to keep it fast & simple (:wink:) and just use the good old standard isspace function:
int isspace ( int c );

Let's face it, that would cover most of the cases people care about.

Quote from: "Laurent"
You can search the task that already exists in the issue tracker, and add your suggestions to it (only Replace please, so that I won't have to duplicate my answer there :D).

Done. Sorry for not notifying the github issue first!

96
Feature requests / Extended operations for sf::String
« on: November 16, 2011, 01:58:04 am »
SFML 2.0 introduces sf::String, which is really convenient for handling strings.
Since this class already has string manipulation methods (Erase, Insert, Find and iterators), that would be very useful if sf::String provides more of these.

I am thinking about basic operations such as:

- Removing leading and trailing whitespaces:
sf::String Trim() const;
And why not LTrim (leading only) and RTrim (trailing only)

- Extracting a sub-string:
sf::String Substr(size_t Index, size_t Length) const;

- Replacing occurences:
sf::String Replace(const sf::String& LookFor, const sf::String& ReplaceBy) const;

- Converting to lowercase:
sf::String ToLowerCase() const;

- Converting to uppercase:
sf::String ToUpperCase() const;

97
Graphics / How does the Draw() work?
« on: November 11, 2011, 12:40:15 am »
Quote from: "P@u1"
Why sfml then doesen't do it?
You just need to test for intersection with the view rect for every sprite before making the actual draw calls.

I guess this would be an unnecessary (and time-consuming) operation if your application doesn't draw objects outside the screen.

98
Graphics / sf::String width
« on: November 11, 2011, 12:35:33 am »
Well, there is really nothing to explain, use the GetRect method to retrieve the bounding rectangle of the text.
SFML 1.6:
Code: [Select]
sf::String string("hello");
float width = string.GetRect().GetWidth();


SFML 2.0:
Code: [Select]
sf::Text text("hello");
float width = text.GetRect().Width;

99
SFML projects / CosmoScroll - space shooter game
« on: November 08, 2011, 12:26:59 am »
Thanks all!

Quote from: "eXpl0it3r"
I downloaded the windows version from the Google Code Project site and when I start the game, a new proces gets created (I can see it in the taskmanager) but it won't show any window or error or anything...  :(

So the process doesn't even crash?
Did you experience similar issues with other SFML projects?

Quote from: "eXpl0it3r"
Or do could I miss some dependencies (installed a new  Windows 7 last week).

I don't think so:
1) I provided all the required DLL's
2) If something was missing, the process wouldn't even get created.
Sorry, but I am clueless as well :(

Quote from: "eXpl0it3r"
Btw quickly translated the .lang file to german. It's not perfect and maybe it won't fit everywhere into the predefined space, but I wasn't able to look which label sits where, since the game won't start.


That's very kind of you!
Since I'm currently working on the next release (with new features such as spaceship upgrading :) ), the language files have been updated with new contents. A friend of mine, who is involved in this project, also started a german translation, so I've merged both files, (assuming your translation is the better one, my friend is not a native german speaker).
You can check the result here, that's the current (= devel) version.


100
General / Re: Standalone program in Ubuntu
« on: November 03, 2011, 05:52:24 pm »
So you want to launch your program without launching a desktop environment first?
Your problem is not related to SFML, you should look into X11 (Linux graphical server).

101
SFML projects / CosmoScroll - space shooter game
« on: October 16, 2011, 05:37:49 am »
Quote from: "frostwork"
current rv doesn't seem to build with current sfml2

I'm still using SFML 1.6 for this project, I will probably migrate to 2.0 version when it will be officially released.
Don't hesitate to contact me if you need more information.

102
Graphics / Checking if a sprite flipped?
« on: October 15, 2011, 09:15:18 pm »
I just discovered there is currently no way to tell is a sprite is flipped, and found this old topic.

Laurent, do you still plan to add those two little getters IsFlippedX / IsFlippedY ?
I concur with Nexus, overriding FlipX/FlipY methods is just an hacky workaround.

103
SFML projects / CosmoScroll - space shooter game
« on: October 15, 2011, 07:48:19 pm »
Quote from: "frostwork"
maybe just disable the feature until there's a better fix? :)

I'm ok with this.
Points 1 and 2 (data paths and settings management) will be fixed by the next version, but there is also other big features currently on the track, so do not expect a new release before a couple of months !

104
General / Re: Thinking about making a GUI library
« on: October 14, 2011, 12:42:40 am »
Quote from: "Nexus"
Quote from: "N1ghtly"
- And should I derive from sf::Drawable or make a
Code: [Select]
void draw(sf::RenderWindow* window) function?
Write a Draw() function. This offers more flexibility and you don't inherit all properties of sf::Drawable (like the blend mode). You should never use inheritance if it doesn't come with relevant advantages.

On the other hand, deriving from sf::Drawable provides many benefits:

- Within your widget, every graphic component’s position is relative to the widget position. So if you want to move your widget, you just need to update the Drawable position, and graphic components drawn in the Render method will be moved automatically.
- sf::Drawable properties are very useful: beside obvious ones such as Position and Size, I do believe that features such as blend mode, rotation and scale (zoom) could be used in a GUI system, especially in a game GUI, where "eye-candies" are always welcomed.

105
SFML projects / CosmoScroll - space shooter game
« on: October 12, 2011, 11:30:47 pm »
Quote from: "frostwork"
I could create a gentoo ebuild for it and commit it to the gamerlay

Sure! But I think I need to improve a couple of things to allow a proper installation, I've just sent you an PM about that.

Quote from: "Nexus"
If I resize or maximize the window, the GUI doesn't react correctly anymore. Maybe you should adapt it or disallow resizing...

Indeed, I've already noticed that bug a few weeks ago...
I chose the easy way and just disabled window resizing, which wasn't useful anyway ;)

Thanks for your feedbacks.

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