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

Pages: [1]
1
General / Debug: Program received signal SIGSEGV, Segmentation fault
« on: July 28, 2008, 04:32:30 am »
If possible you might try downloading and installing SFML from scratch. There's no reason that I know of that code should be segfaulting. I'm using the exact same code on the exact same platform (Windows/MingW/Code::Blocks) without any problems, so my best guess is a corrupt library. :?

2
Window / sf::RenderWindow fullscreen switch problem
« on: July 20, 2008, 10:35:35 pm »
Ah, good to hear! I assume the change applies to the SVN version of SFML? I'll give it a try. Thanks again! :D

3
Graphics / Trouble with views
« on: July 18, 2008, 05:02:17 pm »
Ah, thanks. Apparently I did misunderstand the purpose of views (ie, they were for things like "split-screen"). I'll just use some kind of "fake" scrolling instead. Thanks! :)

4
Graphics / Trouble with views
« on: July 18, 2008, 04:50:28 pm »
This isn't necessarily a problem with SFML, but more a request for help. what I'm trying to do is create a 352x352 pixel view inside of a 640x480 window in the top left corner that can scroll separately from the main window.

The obvious solution to me would be to use an sf::View, but I don't understand views at all. What exactly are the "Center" and "Half Width" parameters? I assumed they were the position of the "window" into whatever I'm drawing after the view is set, so I did something like this:

Code: [Select]
View LevelView(Vector2f(176,176), Vector2f(176, 176));

while (SFMLApp.IsOpened()) {
//Process events
while (SFMLApp.GetEvent(input)) {
//(...)
}

SFMLApp.SetView(LevelView);
SFMLApp.Draw(testlevel);
SFMLApp.Draw(Player);
SFMLApp.SetView(SFMLApp.GetDefaultView());
}


Instead what I get is this:



As you can see, the content of the view is stretched in strange ways. I read the View tutorial a few times, read the source for it a few times, and as far as I can tell there's no way to make a view that only takes up part of the screen. Is that true? Are views incomplete or am I misunderstanding their purpose? :?

5
Graphics / [Solved] Problems with collision detection
« on: July 16, 2008, 09:22:56 am »
Quote from: "Hiura"
Your Sprite::GetRectangle is not good for one thing : if you rotate your sprite, the FloatRect (no Int*) can be false.


Ah, good point. I guessed there must be a reason why the ability wasn't already included, but I couldn't figure out what it was. :)

Still though, the ability to get the (axis aligned) bounding box of a (possibly rotated) Sprite could be a useful feature to add at some point..

6
Graphics / [Solved] Problems with collision detection
« on: July 15, 2008, 11:46:17 pm »
The easiest way to do this would probably be to use SFML directly:

Code: [Select]
IntRect PaddleRect(Paddle.GetPosition().x, Paddle.GetPosition().y, Paddle.GetPosition().x + Paddle.GetSize().x, Paddle.GetPosition().y + Paddle.GetSize().y);
IntRect BallRect(Ball.GetPosition().x, Ball.GetPosition().y, Ball.GetPosition().x + Ball.GetSize().x, Ball.GetPosition().y + Ball.GetSize().y);
IntRect Intersection;
//Find out if the ball is touching the paddle, and get a rectangle representing the overlap if so
if (BallRect.Intersects(PaddleRect, &Intersection)) {
//Move the ball so it's no longer overlapping the paddle, otherwise it would change directions forever (get "stuck")
Ball.Move((Ball.xSpeed > 0 ? -Intersection.GetWidth() : Intersection.GetWidth())); //If the ball is moving right, slide it left, otherwise slide it right
//Reverse the ball's direction
Ball.xSpeed = -Ball.xSpeed;
}


That code assumes a lot about the structure of your "Ball" and "Paddle" classes, but hopefully you get the idea. :)

As a side note, it would be nice if sf::Sprite had a function like this:

Code: [Select]
const IntRect Sprite::GetRectangle() {
return IntRect(myPosition.x, myPosition.y, myPosition.x + GetSize().x, myPosition.y + GetSize().y);
}


Since it would greatly simplify this kind of collision code. :)

7
Window / sf::RenderWindow fullscreen switch problem
« on: July 15, 2008, 11:49:52 am »
Thanks, I appreciate it! I know you must be busy maintaining the library, but I can't seem to figure this one out even after looking at the library source. :?


Update: Closing the window with RenderWindow::Close just before the call to RenderWindow::Create solves the issue. I'm still not sure of the cause though, perhaps something is preserved that shouldn't be when Create is called on and existing window?

8
Window / sf::RenderWindow fullscreen switch problem
« on: July 15, 2008, 05:33:46 am »
Hi! I'm just starting with SFML and I just want to say great job! I really like the concept and implementation of SFML, and the pre-built mingw libraries are a godsend for me. Usually I have to build my own from .dlls and .libs. :|

Anyway, after reading the tutorials I decided to try a simple test to really get comfortable with the library, but I've run into a small problem:

I'm using the RenderWindow::Create function to toggle between fullscreen and windowed modes, and it works beautifully going from the initial windowed mode to fullscreen, but when switching back the window remains the same size as my desktop, and as far as I can tell from reading the documentation and searching these forums there's no way to resize the window.

I'm using Code::Blocks and MinGW. Can anyone tell me what I'm doing wrong? Is this a quirk with the Windows/MinGW implementation or a bug/limitation in SFML? And if so is there a workaround or should I go ahead and dive into SFML's source? Any help is appreciated! :)

My source:
Code: [Select]
#include <SFML/Graphics.hpp>
using namespace sf;

int main() {
Event input;
bool fullscreen;
RenderWindow App(VideoMode(640, 480, 16), "SFML Test");

while (App.IsOpened()) {
        //Process events
        while (App.GetEvent(input)) {
            //Exit
            if (input.Type == Event::Closed) App.Close();
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::Escape)) App.Close();
            //Fullscreen toggle
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::F)) {
fullscreen = !fullscreen;
App.Create(VideoMode(640, 480, 16), "SFML Test", (fullscreen ? Style::Fullscreen : Style::Resize|Style::Close));
}
        }

        App.Display();
}

return EXIT_SUCCESS;
}


P.S. It seems that it's not just the window size that's off, but the video mode. Displaying a 640x480 image in the window results in a large black space around it after switching to fullscreen and back.

Edit: I knew I was forgetting something. I'm using the latest stable version of SFML: 1.3.

Pages: [1]