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.


Topics - Regeta

Pages: [1]
1
Window / Function similar to SDL_SetClipRect ?
« on: April 25, 2013, 01:37:09 pm »
With SDL, it was very simple to make the gameplay window smaller than the actual window itself. The result would be a black border (my cleared/fill color) around the actual rendered window.

It was as simple as typing,

SDL_SetClipRect(_mainWindow, g_ClipRect);

With g_ClipRect being a Rect(x,y,w,h). Sortof like a window within a window.

I was curious as to whether or not SFML has a similar function?

2
I have googled and search these forums for a solution for 30 minutes and can't seem to find anything. It's not a simple google search given the lack of definitions for the problem.

The player moves in 8 directions, using either the NumPad or ArrowKeys/WASD. The NumPad has no problems given its 8 directions are all separate keys. However, arrow keys and WASD require 2 keys down to move diagonally.

if( (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) && (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) )
    {
~walk walk walk~
    }


Everything works fine, until I want to STOP MOVEMENT while facing a diagonal direction. Input is detected so quickly, that 9 times out of 10 you will end up facing N, E, S, W- because even a faster user cannot release both keys at the exact same time. One key is always released after the other.

I've read a little bit about ONE possible solution: Taking out the logic in the keyboard if's, and replace it with a variable.

I am new to SFML, so I am not sure this is the best way to handle this. I would prefer not to slow down detection of input either, or make overcomplicated code if there is an easier way to fix this.


Thank you- I am sure any help to solve this will help me save hours of time trying to solve it or research the deepest depths of google to find the logic behind this instead of diagonal speed (sin / cos).  The engineering is pretty simple if I remember correctly, which is why I ask for a solution. I actually remember long ago kind of how I handled it in a different framework, but I do not remember enough to get it done quickly.

Pages: [1]