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

Pages: 1 [2] 3 4 ... 7
16
General / Re: SF::Rotation returning a value above 360 or below 0
« on: November 13, 2012, 03:48:55 pm »
Might this be related to this commit?
There's probably no problem in the latest code @ git repository...

I would indeed believe that it is, if such a code snippet is also in the rotate function (and since I think that rotate just calls setRotation inside I would think so). Sorry to have disturbed you.

17
General / Re: SF::Rotation returning a value above 360 or below 0
« on: November 13, 2012, 03:40:13 pm »
The documentation is correct, the rotation should never be out of the range [0 .. 360].

That's why we need to see your code.

Quote
The problem itself is easily replicable, just create a sprite, rotate it and print its rotation(using the getRotation function).
So please provide the code. Even if it's short and simple, it's better if written once by you and simply copied by everyone else. And this way we are also sure that your code and our code is exactly the same. No stupid mistake.

Ok, here is a functioning example.
void main()
{
        sf::RenderWindow App(sf::VideoMode::VideoMode(320,480),"Test!",sf::Style::Default);
sf::Text VelocityText;
std::ostringstream ss;
sf::Sprite extraeye;
sf::Texture Eye;
Eye.loadFromFile("Graphics/eye.png");
extraeye.setTexture(Eye);
while(App.isOpen())
{
extraeye.setOrigin(extraeye.getLocalBounds().width/2,extraeye.getLocalBounds().height/2);
extraeye.rotate(10.f);
ss.str("");
ss << extraeye.getRotation();
VelocityText.setString(sf::String(ss.str()));
App.clear();
App.draw(extraeye);
App.draw(VelocityText);
App.display();
}
}

(You will have to use your own texture tho :P)

18
General / Re: SF::Rotation returning a value above 360 or below 0
« on: November 13, 2012, 03:00:06 pm »
It would be nice if you could describe your actual problem. All I see in your first post is "is the documentation correct?", but you don't describe what you do, and what results you get. A complete and minimal code that reproduces the problem would be perfect. And yes, first make sure that your version is not too old.

I am using the SFML 2.0 rc. I'm not quite sure how to check what exact version I have.
It isn't exactly a big problem it merely complicates my calculation during rotation of objects. What I merely meant it that a sprite which is rotated above 360 degrees or below 0 degrees will, when you call its getRotation function, return precisely that, a value above 360 or below 0.

Since the documentation explicitly states that the value returned by getRotation would be between 0 and 360, I merely wondered whether you should change that statement in the documentation as it is not (to my experience)correct.
(or include this code in the rotate/getRotation function)
       
if(this->getRotation() >= 360)
{
        this->rotate(-360);
}
else if(this->getRotation() < 0)
{
        this->rotate(360);
}

The problem itself is easily replicable, just create a sprite, rotate it and print its rotation(using the getRotation function).

EDIT: I just looked over the first post/thread name and saw how sloppy it looked. Very sorry for that.

19
General / Re: SF::Rotation returning a value above 360 or below 0
« on: November 10, 2012, 01:05:37 am »
It's true. But it shouldn't be an issue.
So:

-1 == 360
-2 == 359

361 == 0
362 == 1

It's not really an issue that can't be compensated for, still it would be nice if documentation corresponded with what the actual code does.

20
General / SF::Rotation returning a value above 360 or below 0
« on: November 10, 2012, 12:41:18 am »
So, the title says it all. Despite the description text of sf::transformables function sf::getrotation says:

get the orientation of the object

The rotation is always in the range [0, 360].
Returns:
Current rotation, in degrees

So is this untrue or not? To see the rotation I'm using
                                       
std::ostringstream ss;
ss.str("");
ss << player.getRotation();
VelocityText.setString(sf::String(ss.str()));
and then drawing VelocityText to the screen.

21
General / Re: Mouse input
« on: October 24, 2012, 05:06:59 pm »
Well, as I said, the structure actually works fine for keyboard input. It hasn't given missed a single stroke so far. The reason for the crazy indentation was that since the actual structure is some hundred or so lines long, I didn't feel like burdening you with all the unneccesary code, and instead just copy pasted. I however discovered that attempting to use tab to create indentations in the webpage didn't work so I instead attempted to use spaces. It obviously didn't work.

Edit: Fixed the original post.

22
General / Mouse input
« on: October 23, 2012, 09:15:07 am »
Hey I was wondering whether there is something wrong with the SFML mouse input class.
When I get input from the keyboard I use a pollEvent and a switch type structure

while(App.pollEvent(Event))
{
        switch(Event.type)
        {
                case sf::Event::Closed:
                        App.close();
                        break;
                case sf::Event::KeyPressed:
                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                        {
                                //Do stuff
                        }
                        break;
        }
}

And it works fine.

However attempting to put in a
case sf::Event::MouseButtonPressed: doesn't work.
In my application I did it like this

while(App.pollEvent(Event))
{
        switch(Event.type)
        {
                case sf::Event::Closed:
                        App.close();
                        break;
                case sf::Event::KeyPressed:
                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                        {
                                //Do stuff
                        }
                        break;
                case sf::Event::MouseButtonPressed:
                        if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
                        {
                                //Do stuff
                        }
        }
}

But it never triggered/worked. Instead I had to do this:

while(App.pollEvent(Event))
{
        switch(Event.type)
        {
                //Process events
        }
}
if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
        //React to the mouse button
}
Am I doing an incorrect implementation or is it something else?

23
Graphics / Using an untextured or filled shape
« on: October 15, 2012, 11:33:01 am »
Is there any way to, instead of using sf::texture object to create and use a sf::shape, to simply fill the shape with a specified colour and then drawing it to the screen.

Alternatively can you fill a texture object with a single colour instead of loading an image?

24
This can be achieved in two ways:
  • Spawn a thread that runs your logic. Be aware that it can be more difficult to work with than it looks.
  • Use one loop, but only perform tasks at the wanted intervals.

I found this article helpful, although it is focused around game loops, which may not be what you are looking for:
http://www.koonsolo.com/news/dewitters-gameloop/

Sorry for not responding. Thank you.

In the end I went for this approach

if(DisplayClock.GetElapsedTime().asMilliseconds() >= 2.85714)
{
draw stuff...
}
 

(2.85714 millis means about 35 frames per second)

25
General / Having one calculation loop and one graphic loop in SFML 2.0
« on: October 10, 2012, 03:02:06 pm »
To explain my topic a bit better: Is there anyway to have a section of code which goes much faster than the rest of SFML?
I would like to change my project to have two loops: one drawing loop which is "only" called 40 times per second, so that the visual portion of the game has 40 fps, and a update/calculation loop which runs at a higher speed (say 70-80 times per second).

Is there any easy way to do this, is it impossible with sfml or is it possible but I just have to code it myself?

26
SFML projects / Re: "Project 2"
« on: September 22, 2012, 07:44:03 pm »
Looks nice :) Hope you'll post updates when something happens! :D

27
General / Re: SFML 2.0 switching from debug to release setting
« on: September 22, 2012, 05:54:36 pm »
Ty. I had actually placed the file that it requested before in the folder, but only now noticed that the error message had changed to requesting another dll.

28
General / SFML 2.0 switching from debug to release setting
« on: September 22, 2012, 12:03:44 am »
So, I've made the rough beginnings of the seed of a small demo of a game that I'm working on and now I would like to send it to one of my friend.

However, when I try to compile it in release setting an error message pops up saying that I'm missing sfml-system-2.dll.

Is this a known problem or is it something trivial that I have done wrong? I don't think that there is anything wrong in the code itself since it compiles and runs just fine in debug setting. Also I checked in the sfml 2.0-rc folder and found that there was a file called sfml-system-2.dll lying in /bin. So the file is there my comp/compiler just wont find it.

Any tips?

FYI I'm using visual c++ express 2008

29
General / Re: [SFML 2.0] Access violation (debugging)
« on: September 07, 2012, 07:32:17 am »
Aye, knowing myself I presumably linked an invalid file or fileformat or something. ^^

30
General / Re: [SFML 2.0] Access violation (debugging)
« on: September 06, 2012, 10:56:08 am »
Yup, that fixed it ^^ However, now no text prints on screen at all :P

Pages: 1 [2] 3 4 ... 7
anything