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

Pages: [1]
1
General discussions / Re: Views and sprite world positions
« on: October 11, 2024, 04:44:13 pm »
Valid point. I am definitely drawing them as when I change their x position to within the viewport, they draw as expected.

I understand that, in other game dev that I did,  not using views, I would have to position the sprites relative to the offset from the world origin so they would render on screen.

i.e Sprite.x = Sprite.x - xDistanceFromOrigin

If this sprite was then within screen dims, it was rendered/drawn.

But i thought that if I move the view(camera) away from the origin, the sprites would sit where they are until ‘seen’ by the view? i.e a sprite with an xpos of 1300.f would just be outside of the view (width 1280 as per my rendertarget). As the view position moves to the right, without adjusting the sprite, it would eventually come into ‘view’.


But this is not happening?

2
General discussions / Views and sprite world positions
« on: October 11, 2024, 11:15:19 am »
Hi All,

Thanks for any help in advance.

I am getting really confused about views. I am using a view which is full screen (1:1). I am using a view as I have a tilemap based upon a vertex array and I can then move the view left and right to give me a scrolling tiledmap.

I understand the view is positioned by its centre.

Lets say my screen resolution is 1280pixels wide. So the view starts at the far left of my map with its centre at 640.f.

As I increase this position, it scrolls over my map.

But If I place a sprite beyond the screen size to the right, say perhaps world position of 1500.f (xpos), when my view passes this no sprite is drawn?

What am I doing wrong?


3
General discussions / Re: window resize mouse position wrong
« on: October 08, 2024, 12:58:35 pm »
I tried the code as suggested and it still gives wrong values.

I have tried with and without using a view.

Can anyone suggest what I might be doing wrong or what to do that is right?

4
General discussions / window resize mouse position wrong
« on: October 06, 2024, 03:56:39 pm »
Hi all

and thank you for any help in advance.

I create my window and view as follows:
window(sf::VideoMode(l_videoMode.x, l_videoMode.y), l_windowName, sf::Style::Close | sf::Style::Resize)

m_View.setSize(sf::Vector2f(window.getSize().x, window.getSize().y));
m_View.setCenter(window.getSize().x/2, window.getSize().y/2);

 

In the Update method of my window class I get the mouse position as follows:

m_winMousePos = sf::Mouse::getPosition(window);

//I have also tried the following
/*
//sf::Vector2i pixelPos = sf::Mouse::getPosition(window);
//sf::Vector2f worldPos = window.mapPixelToCoords(pixelPos);
/*

//The window resize event as sfml website
if (event.type == sf::Event::Resized)
{
        sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
        window.setView(sf::View(visibleArea));
}

//My draw code:
void Window::Draw(const sf::Drawable& l_drawable)
{
        window.setView(m_View);

        window.draw(l_drawable);
}

When I maximise the window, the mouse coords are not correct and I cannot get what I am doing wrong.

Any pointers [no pun intended] would be a great help!


5
Graphics / scrolling texture thru sprite
« on: June 01, 2024, 06:22:19 pm »
Hi All

I want to have a sprite with a texture. They will be the same size which is the width of the screen. I want to be able to keep the sprite stationary and horizontally move the texture (left and right) so it looks like a repeating scrolling background that wraps around. Movement amount will change on user input.

How would I do this please?


Pages: [1]