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

Pages: [1]
1
General / Re: Random crashes?
« on: February 21, 2013, 04:26:45 am »
Initial testing shows that worked, thanks.

So when you try to access something like event.key.code when there is no KeyPressed event, event.key.code is undefined and accessing it results in random garbage? 

2
General / Re: Random crashes?
« on: February 21, 2013, 04:00:09 am »
I didn't post any code because this has happened over many projects since I started using SFML, as I said in the original post.  There isn't any line of code that I can post that I suspect to be the problem, because the problem happens all the time. 

This is the code from the current project main loop (the one that crashes for both me and my partner).  The problem occurs with and without the custom mouse cursor code:

        while (gameWindow.isOpen())
        {
                while (gameWindow.pollEvent(gameEvents))
                {
                        if ((gameEvents.key.code == sf::Keyboard::Escape) || (gameEvents.type == sf::Event::Closed))
                                gameWindow.close();
                       
                }

                thing.update(gameTime);
                // Horrible update that sets the cursor to the mouse position
                customCursor.update(sf::Vector2f(sf::Mouse::getPosition(gameWindow)));
               
                Board::GetInstance(gameWindow)->draw();
                thing.draw();
                customCursor.draw();

                gameWindow.display();
                gameWindow.clear(sf::Color::White);

                gameTime = gameClock.restart().asSeconds();
    }

3
General / Random crashes?
« on: February 21, 2013, 02:55:29 am »
I've had this problem and thought it was probably just on my end so I've just sort of been dealing with it.  It seems that randomly, when moving the mouse around, my window simply closes.  This has happened across multiple projects and now with multiple computers, and I'm not sure where the issue lies. 

I recently started coding with a friend (using Git) and he also has the same problem.  We're both using VS12 and got the precompiled packages from exploit's nightly builds.  If you don't move the mouse, there is no problem.  When you do move the mouse, within a few seconds (usually) the window closes on it's own.

I can't seem to find any answers on Google about this particular issue.

4
General / Accessing sf::Keyboard
« on: February 03, 2013, 12:53:36 am »
Apologies for the basic/noob question, but I want to understand what's going on since I really have no idea.

I have a player class that accesses sf::Keyboard, and I'm not really sure how it's able to access it and how it gets populated with any sort of data.

void Paddle::update(const float& t, const sf::RenderWindow& window) {
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
                xVel = -xSpeed * t;
        }

This is an example from Paddle.cpp.  The function is called after window.pollEvent() takes place in Main.  I'm just curious how my class, seemingly unconnected to anything, gets access to it and how it is populated with values (because it works wonderfully).

5
Graphics / Re: Linking a shape and Rect?
« on: January 29, 2013, 11:57:04 pm »
Ahhhh, I gotcha.  I didn't know sf::FloatRect was sf::Rect<float>, so that part had me confused.

Thank you both :)

6
Graphics / Re: Linking a shape and Rect?
« on: January 29, 2013, 11:38:10 pm »
sf::RectangleShape p1Shape;
sf::Rect<int> p1BoundingBox;
p1BoundingBox = p1Shape.getGlobalBounds();

Results in 'no operator "=" matches these operands'.

7
Graphics / Linking a shape and Rect? [SOLVED]
« on: January 29, 2013, 11:01:00 pm »
Apologies in advance because I'm fairly sure this question has a simple answer, I'm just too noob to find it.

I'm using primitives to make a Breakout clone and I'd like to use sf::Rect<int>'s intersect() for all my collision detection, so each object in the game will have an sf::Rect<int> that acts as it's bounding box.  Each object also has an sf::RectangleShape to represent the actual object on screen.

Is there an easy way to keep these two linked?  For example, if I move the object is there an easier way than this?

objectShape.setPosition(x, y);
objectBounding.top = x;
objectBounding.left = y;

8
General / Re: Release/Link issues with VS10 & SFML2.0
« on: January 26, 2013, 11:39:29 am »
Reading that thread and doing some more Googling didn't get me any further, although it was a good lesson.  Doesn't surprise me, because this kind of thing is far out of the scope of what I'm familiar with (I'm still learning lists, inheritance, etc) so I mostly just fumble around until a solution arises.

To anyone reading this thread in the future, I eventually found my way to Solution Properties > C/C++ > Preprocessor > Preprocessor Definitions and added the line SFML_STATIC.  Recompiled, and it works on other PCs. 

Thanks :)

9
General / Release/Link issues with VS10 & SFML2.0 [SOLVED]
« on: January 26, 2013, 08:34:07 am »
So I've made a basic application using SFML 2.0.  I'd like to be able to release it as a single .exe to use on other computers, for example, but when running it on my wife's PC I get 'You don't have sfml-graphics.dll' type errors (as she obviously doesn't have SFML installed).

Until now I have been using -d.lib's and everything has been fine.  The release version runs properly on my PC.  I'm a pretty huge noob, so even getting the release version to run properly without the console window caused some grief.  I had to change the SubSystem and Entry point... or something (this was all done blindly via Google, have no clue what I really did).  I only mention that in case it's causing issues, although it's probably not.

I tried using sfml-graphics-s.lib, but it doesn't even compile.  Not sure if that was for 1.6 only or I've done something wrong somewhere.  I know I have to link the .lib's properly somewhere, but I'm lost on how to do it.  Any help is appreciated.

10
Graphics / Smooth movement in SFML 2.0?
« on: March 15, 2012, 10:01:02 am »
I'm a beginner and I'm having some trouble getting smooth movement in SFML.  I made a Pong game Allegro, and movement was handled as follows.  keyState being an array of bools and keypressed being an enum with an element for each key.  (sorry if this pseudo-code is terrible)

Code: [Select]

Poll for events {
    if key is down, keyState[keypressed] = true;
    if key is released, keyState[keypressed] = false;
   
    if (timer ticks) {  // (timer was set to 1.0 / 60)
        redraw = true;
        handle player movement based on keyState[keypressed] values;
    if (redraw && event queue is empty)
         redraw = false;
         draw everything;
}

clear display;
flip display;


This resulted in the timer ticking 60 times per second, redrawing at 60 FPS and handling the movement smoothly.  With SFML 2.0, I'm having troubles replicating what I did.  I've read about time-based movement (i.e move by x * deltaT), but for some reason the implementation and logic behind it is completely eluding me.  

Right now I have movement handled within the event polling, and it moves fine, but there is a delay if you hold the key down between the first movement and the repeated movement, and it's jumpy.

Can anyone help explain how to handle smooth movement in SFML 2.0?

Pages: [1]
anything