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

Pages: [1]
1
Graphics / Shape vs. Window coordinates
« on: October 10, 2009, 03:51:24 pm »
Quote from: "Tank"
You're creating the circle at 300, 400 and are moving it then to 300, 400, which makes an absolute position of 600, 800.

Code: [Select]
sf::Shape circle = sf::Shape::Circle(0, 0, 5, sf::Color(255, 0, 0, 255));

...should do the trick. ;)


So it does, thanks a lot. It seem extremely obvious now.

I guess I expected it to set the position absolutely as opposed to using it as an offset.

2
Graphics / Shape vs. Window coordinates
« on: October 10, 2009, 02:37:57 pm »
Right, that would make sense, here you go.

The issue seems to be with setPosition(). If that gets commented out it works like it should. Maybe I'm misunderstanding how setposition works?

Code: [Select]

#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

using namespace std;

int main()
{
    sf::RenderWindow Win;
    sf::Event m_event;
    bool running = true;
    sf::Shape circle = sf::Shape::Circle(300, 400, 5, sf::Color(255, 0, 0, 255));
    Win.Create(sf::VideoMode(600, 800, 32), "Debug");

    while(running)
    {
        while ( Win.GetEvent(m_event) )
        {
            if ( m_event.Type == sf::Event::Closed )
            {
                running = false;
            }
        }
        circle.SetPosition(300, 400);

        Win.Clear();
        Win.Draw(circle);
        Win.Display();

    }
    return 0;
}

3
Graphics / Shape vs. Window coordinates
« on: October 10, 2009, 04:17:50 am »
Nothing crazy with views, although I did mess with them in an attempt to fix things - didn't seem to work.

This is unfortunate, I'm not really doing anything crazy. Maybe I'll regrab and re-install, see if that does anything.

Thanks for the help.

4
Graphics / Shape vs. Window coordinates
« on: October 10, 2009, 01:22:24 am »
Thanks for the response

Hopefully this is what you're asking for. I shrunk the images down and removed everything except for a red dot which you can see at either location and blacked out the background to make it more visible. The code given is done on creation of the shape object and then I just use shape.SetPosition(posX, posY) in my update loop (posX and posY are currently constant values).

I confirmed that the image is indeed 600x800.

Here's my window initialization stuff:
Code: [Select]

DEBUG_PRINT("Initializing Test...")
    DEBUG_PRINT("Loading Images...")
    m_ImageManager.addImage("background", "../assets/see/scenery/mock_test.png");
    m_ImageManager.addImage("pointer", "../assets/see/scenery/Pointer.png");
    m_testBack.SetImage(*m_ImageManager.getImage("background"));
    m_testPointer.SetImage(*m_ImageManager.getImage("pointer"));
    DEBUG_PRINT("Initing Window...")
    Win.Create(sf::VideoMode(600, 800, 32), "Test");
    Win.ShowMouseCursor(false);


Code: [Select]

posX = 300;
posY = 400;
circle = sf::Shape::Circle(posX, posY, 5, sf::Color(255, 0, 0, 255));



Code: [Select]

posX = 0;
posY = 0;
circle = sf::Shape::Circle(posX, posY, 5, sf::Color(255, 0, 0, 255));


5
Graphics / Shape vs. Window coordinates
« on: October 09, 2009, 10:15:36 pm »
I did some searching and didn't see anything that directly addressed this  - if I missed something obvious, sorry I'm new.

Basically I'm simply drawing a sprite on the screen (moving it around). However I'm noticing it's position looks off (I know I'm definitely missing something).

So I create a window
Code: [Select]
Win.Create(sf::VideoMode(600, 800, 32), "Test");

Then I basically loop and draw my shape:

Code: [Select]

//In the constructor
circle = sf::Shape::Circle(posX, posY, 5, sf::Color(255, 0, 0, 255));

//In my draw function
//...do some position calculations:
circle.SetPosition(posX, posY);


The problem here, is if I set the posX, posY to 0,0 - then it drops the sprite in the top left as expected.

However putting it at 600,800 moves it off the screen.

In fact, drawing it at 300,400 puts it at the bottom right of my window.

Now I wouldn't be so weirded out about this if it didn't display a 600x800 background image entirely. So I'd expect the coordinates to line up.

I was just wondering why? Can this be fixed with a view? If I move the view out so that 600x800 is indeed the bottom right, won't that mess up my background image (since it fits teh window perfectly now)?

Pages: [1]
anything