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

Pages: 1 2 [3] 4 5 ... 7
31
Feature requests / sf::Text constructor
« on: September 04, 2012, 09:08:34 am »
I was just wondering whether it was possible to get a sf::Text constructor which does not require a string upon creation, or could you perhaps have the sf::string& string, changed to a default empty parameter(so that it would be the programmers choice if he want's to initialize a sf::text object with a string).

32
General / Re: [SFML 2.0] Acess violation (debugging)
« on: September 03, 2012, 10:00:12 pm »
You still could trace the calls back with the callstack provided in VS, but you'd eventually end up in some SFML resource/context code and wouldn't be able to figure out what goes wrong either.

You need to provide a bit more information so we can say what porbably happens. ;)
What exacte version of SFML 2 are you using?
Do you link dynamic or static?
Do you compile in debug or release mode?
Do you use the default font?

How do you check what version of SFML you are using?
I am using dynamic linking.
Compiling in debug.
Do I use the default font in what? In all my sf::Text objects yes I am using default font.

Also, just in case it matters: I'm using visual c++ 2008 express

33
General / [SFML 2.0] Access violation (debugging)
« on: September 03, 2012, 09:40:00 pm »
So, I recently switched from sfml 1.6 to sfml 2.0.
Now I get this error

Unhandled exception at 0x55520481 in New Game.exe: 0xC0000005: Access violation reading location 0x00000008.

However I only get it upon exiting/shutting down the program. Normally the compiler would attempt to point me in the direction of the transgressive code, but after the first error message I get this:

There is no source code available for the current location.

and an option to show disassembly.

I am very sorry to say that I can make neither head nor tails of disassembly code.
Does anyone have any tips/solutions or a good way to try debugging this?

34
Whelp, I changed from linking to static to linking to dynamic. That fixed it.

35
The problem is although you declare a destructor you don't define it. Your code looks like this:
~Randomizer();
Now either you just delete it, since it isn't needed anyways and the compiler will generate a default destructor or you change to:
~Randomizer() {}

Aye I thought of that first and changed it into
~Randomizer() {}
it still doesn't work.

EDIT: Also tried deleting it. Didn't work either.

36
Fixed :D I'm so close to it compiling ( I think).
One last error (I think).

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Randomizer::~Randomizer(void)" (??1Randomizer@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'theRandom''(void)" (??__FtheRandom@@YAXXZ)

I have no clue what the error message is supposed to tell me.
Randomizer is my own class which I constructed to generate random numbers.
The words "dynamic atexit destructor" had me thinking that the fault was in the destructor function, but it seems fine to me(it's just an empty destructor).

37
I will try to implement your suggestions.

I am pretty sure that I have setup SFML 2.0 incorrectly, because I am getting some 13 linking errors.
Should you or should you not "compile" sfml 2.0 rc with cmake? If so how? When I tried to, I got this error:
CMake Error: The source directory "C:/Users/Admin/Desktop/Small Game/SFML-2.0-rc" does not appear to contain CMakeLists.txt.


38
I fixed the problem.

39
Yah the warnings aren't bad.

However all (and I do mean all) errors are from declaring or using watch/clock objects.

1>c:\users\admin\desktop\small game\new game\main.cpp(134) : error C2146: syntax error : missing ';' before identifier 'JumpClock'

comes from this line

Watch JumpClock;

Watch is the name of class.
I have a hard time of seeing what the hell the error could be except the Watch class implementation. Aaaaaaanyhow, the folder is some 15 mbs.

Do you have a google account with drive on? If so I think that you can directly transfer/share files.

EDIT: Just remembered that you probs don't need the art files (or really, anything except the code)
EDIT2: Welp just the code clocks in at a solid 4000 kb so I might aswell give you the whole thing with art and all.
EDIT3: Going to bed now. I'll share/upload in the morning.

40
Anyhow, should I redownload SFML, reinstall Visual C++ 2008 or just wreck my computer? ^^
Throwing the PC out of the window is always a solution, eventhough not the best one... :D
So maybe you could provide more details on the actual error messages you get and/or maybe zip everything up (the project file etc) and upload it somewhere so one can take a look at it.
Is there a specific reason why you're still using such an old IDE as 2008? I mean there's VS10 express... ;)

I get 23 error messages. Here is the build output.

 1>------ Build started: Project: New Game, Configuration: Debug Win32 ------
1>Compiling...
1>Block.cpp
1>gEntity.cpp
1>main.cpp
1>c:\users\admin\desktop\small game\new game\randomizer.cpp(7) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(87) : warning C4227: anachronism used : qualifiers on reference are ignored
1>c:\users\admin\desktop\small game\new game\main.cpp(120) : warning C4227: anachronism used : qualifiers on reference are ignored
1>c:\users\admin\desktop\small game\new game\main.cpp(134) : error C2146: syntax error : missing ';' before identifier 'JumpClock'
1>c:\users\admin\desktop\small game\new game\main.cpp(134) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\admin\desktop\small game\new game\main.cpp(134) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\admin\desktop\small game\new game\main.cpp(144) : error C2146: syntax error : missing ';' before identifier 'Stopwatch'
1>c:\users\admin\desktop\small game\new game\main.cpp(144) : error C2065: 'Stopwatch' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(145) : error C2065: 'pStopwatch' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(145) : error C2065: 'Stopwatch' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(148) : warning C4244: 'argument' : conversion from 'const int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(148) : warning C4244: 'argument' : conversion from 'const int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(149) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(149) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(225) : error C2065: 'Stopwatch' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(225) : error C2228: left of '.reset' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\admin\desktop\small game\new game\main.cpp(226) : error C2228: left of '.reset' must have class/struct/union
1>        type is 'int'
1>c:\users\admin\desktop\small game\new game\main.cpp(227) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(227) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(232) : error C2146: syntax error : missing ';' before identifier 'FrameClock'
1>c:\users\admin\desktop\small game\new game\main.cpp(232) : error C2065: 'FrameClock' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(233) : error C2065: 'FrameClock' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(233) : error C2228: left of '.restart' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\admin\desktop\small game\new game\main.cpp(233) : error C2228: left of '.asSeconds' must have class/struct/union
1>c:\users\admin\desktop\small game\new game\main.cpp(238) : error C2065: 'Stopwatch' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(238) : error C2228: left of '.getElapsedSecs' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\admin\desktop\small game\new game\main.cpp(288) : warning C4244: 'initializing' : conversion from 'float' to 'int', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(289) : warning C4244: 'initializing' : conversion from 'float' to 'int', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(308) : error C2065: 'FrameClock' : undeclared identifier
1>c:\users\admin\desktop\small game\new game\main.cpp(308) : error C2228: left of '.reset' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\admin\desktop\small game\new game\main.cpp(308) : error C2228: left of '.asSeconds' must have class/struct/union
1>c:\users\admin\desktop\small game\new game\main.cpp(383) : error C2228: left of '.reset' must have class/struct/union
1>        type is 'int'
1>c:\users\admin\desktop\small game\new game\main.cpp(400) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(400) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(405) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(405) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(410) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(410) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(445) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(445) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(454) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(454) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(462) : error C2228: left of '.GetElapsedMillis' must have class/struct/union
1>        type is 'int'
1>c:\users\admin\desktop\small game\new game\main.cpp(462) : error C2228: left of '.asMilliseconds' must have class/struct/union
1>c:\users\admin\desktop\small game\new game\main.cpp(465) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(465) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(475) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(475) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(517) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(517) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(683) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(683) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(691) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(691) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(695) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(695) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(695) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(695) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(700) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(700) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(704) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(704) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(704) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\users\admin\desktop\small game\new game\main.cpp(704) : warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>physics.cpp
1>Watch.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Users\Admin\Desktop\Small Game\New Game\Debug\BuildLog.htm"
1>New Game - 23 error(s), 41 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm mostly using 2008 out of laziness I suppose. Hitherto I have simply not found a compelling reason to upgrade to vs2010.

I've got a zipped project now ^^ can you post files directly here/send through PM or should I go find a uploader/downloader site.

41
Works perfectly on my end... ;)

As a hint for the sleep function, SFML comes with a sf::sleep(sf::Time) function, which is not implemented as busy-waiting loop, thus it doesn't waste CPU time. ;)

Sweet... I wonder what is wrong on my end then :C

anyhow I changed the sleep function to
        void  sleep(int ms)
                {
                        sf::sleep(sf::milliseconds(ms));
                }

Anyhow, should I redownload SFML, reinstall Visual C++ 2008 or just wreck my computer? ^^

42
Quote
But why is there no direct accessor to the m_startTime variable?
And what do you want to do with it? It has no special meaning, it's only purpose is to calculate the elapsed time.

Quote
If they are not, that would be another reason as to why sf::time should include a getCurrentTime function, since being able comparing elapsed time to current time is something that I personally would find to be useful in some timing functions.
As the doc and tutorials explain it, sf::Time is a time span, not an absolute date-time. So there's no such thing as a "current" sf::Time.

Quote
Yes, but if I would need to accurately get the "current time" in a form that at least has a resolution of 5 milliseconds?
What do you want to do with the "current time" ? Usually it's not a useful information, all you need are time spans. Especially if you need it with such a low resolution. It doesn't make sense.

I have the feeling that, for you, "current time" is what timeGetTime() returns. For me, it's more "monday 20 august, 20:34:56 and 568 milliseconds". The time returned by timeGetTime() is just a time span relative to the last boot of the PC.
So in fact what you need is a function that returns time values all relative to the same time point, right? In this case it's not hard to do.
sf::Time now()
{
    static sf::Clock clock;
    return clock.getElapsedTime();
}

Fair enough. I was wrong. I was frustrated because I had to go over 500+ errors from switch from 1.6 to 2.0. Now the change is almost done.
I've only got 23 errors, and all of those are relating to the same thing.

Namely that fact that VC++ 2008 has decided that my clock class is missing a ; somewhere.
AND I JUST CANT FIND THE BUGGERING LINE. I've removed every single call inside of every single function. I've split the class, I've put a ; at the end of every function and double-checked all calls so that they are correct. I've even rewritten the entire innards of the class. So I know that this is a big favour, but could someone please try my clock, and see why it refuses to work?

#pragma once
#include "SFML\System\Clock.hpp"
#include "SFML\System\Time.hpp"
#include "SFML\System\Export.hpp"

namespace sf{

        class SPClock
        {
        private:
                sf::Time stopwatch_start;
                sf::Time sleep_start;
                bool paused;
                sf::Clock my_Clock;
        public:
        SPClock::SPClock(void)
        {
                        stopwatch_start = my_Clock.getElapsedTime();
        }
        SPClock::~SPClock(void)
        {
        }


        sf::Time SPClock::GetElapsedTime()
                {
                        my_Clock.getElapsedTime();
                }

        void SPClock::sleep(int ms)
                {
                        sleep_start = my_Clock.getElapsedTime();
                        Time msperiod = sf::milliseconds(ms);
                        while (sleep_start + msperiod > my_Clock.getElapsedTime());
                }

        void SPClock::reset()
                {
                        my_Clock.restart();
                        stopwatch_start = my_Clock.getElapsedTime();
                        paused = false;
                }

        void SPClock::Pause(void)
                {
                        // If not yet paused...
                        if (!paused)
                        {
                                paused = true;
                                stopwatch_start += my_Clock.getElapsedTime();
                        }
                }
        void SPClock::UnPause(void)
                {
                        if (paused)
                        {
                                paused = false;
                        }
                }

        bool SPClock::stopwatch(int ms)
                {
                        if ( my_Clock.getElapsedTime() > stopwatch_start + sf::milliseconds(ms) )
                        {
                                stopwatch_start = my_Clock.getElapsedTime();
                                if(paused) paused = false;
                                return true;
                        }
                        else
                        {
                                return false;                  
                        }
                }

        bool SPClock::IsPaused()
                {
                        return paused;
                }
        };
}
 

43
But why is there no direct accessor to the m_startTime variable? Having it available through a interface would make it vastly easier for less experienced and skillful programmers (such as myself) to build upon. Just throwing it out there.
Because it would be a bad design decision and just because it could be easier for a few particuallar chases it doesn't justify the spoiling of the variable to derived classes.
It's anyways better as I already said to use a sf::Clock as memeber variable instead of deriving from it. ;)

Yes, but why would having a function like
sf::Time getStartTime()
{
return m_startTime;
}
ruin the class?
No matter if you have it as a member or a parent class m_startTime is completely inaccessible.
Also; expl0it3r, are sf::time and time_t (as returned by time function from time.h) comparable or easily converitble? If they are not, that would be another reason as to why sf::time should include a getCurrentTime function, since being able comparing elapsed time to current time is something that I personally would find to be useful in some timing functions.
sf::Time and sf::Clock do not have anything to do with date/time. ;)
sf::Time is just a class for representing a time interval and provides an interface to return the time either as seconds, milliseconds or microseconds, whereas sf::Clock is just a class that 'enlarges' the time intervall starting from some given point (= up on creation or when calling restart()).
Although the actual type of time_t isn't specified it's mostly a "integral value holding the number of seconds since 00:00, Jan 1 1970 UTC" (source) thus you can use the function sf::seconds(static_cast<float>(time_t)) to get a sf::Time object with the interval from 00:00, Jan 1 1970 UTC.

Yes, but if I would need to accurately get the "current time" in a form that at least has a resolution of 5 milliseconds?

I'll post the old code I used for timing and then if you can give me a better way of doing it, I promise I'll go away and never mentions clocks again(except in praise :D).

class SPClock
        {
        private:
                sf::Time timer_start;
                sf::Time stopwatch_start;
                bool paused;
        public:

                SPClock(void)
                {
                        timer_start = timeGetTime();
                        reset();
                }

                float getTimer()
                {
                        return (float) (timeGetTime());
                }

                void sleep(int ms)
                {
                        Time sleep_start = sf::milliseconds(timeGetTime());
                        Time msperiod = sf::milliseconds(ms);
                        while (sleep_start + msperiod > my_Clock.getElapsedTime());
                }

                void reset()
                {
                        my_Clock.restart();
                        stopwatch_start = sf::milliseconds(timeGetTime());
                        paused = false;
                }

                bool stopwatch(int ms)
                {
                        if ( my_Clock.getElapsedTime() > stopwatch_start + sf::milliseconds(ms) )
                        {
                                stopwatch_start = my_Clock.getElapsedTime();
                                if(paused) paused = false;
                                return true;
                        }
                        else
                        {
                                return false;                  
                        }
                }

}

I know that the code isn't good, and that float isn't really accurate enough, but it's worked decently sofar. Now is there any smoother/easier way to do it with sf::Clock or a class which doesn't access any kind current time variable?

44
snip
Quote
Well yes, but sf::clock is fairly useless on it's own except for very rudimentary timing tasks. That's why I will most likely be constructing my own stopwatch.
sf::Clock is not meant to be the final powerful timing class. But it provides a solid base for timing (best resolution and monotonicity), then it's up to you to add whatever high-level feature that you need on top of it.

But why is there no direct accessor to the m_startTime variable? Having it available through a interface would make it vastly easier for less experienced and skillful programmers (such as myself) to build upon. Just throwing it out there.

Also; expl0it3r, are sf::time and time_t (as returned by time function from time.h) comparable or easily converitble? If they are not, that would be another reason as to why sf::time should include a getCurrentTime function, since being able comparing elapsed time to current time is something that I personally would find to be useful in some timing functions.
EDIT: Nevermind. I found that the time function in ctime returns the time in seconds lol.
Anyhow, after googling around a bit I've found that I'd rather go for timeGetTime and sf::Clock, and forgo accuracy and crossplatforming for reliability and easier programming. Also QPC seems to have it's own fair share of bugs, at least according to the internet.

45
In 1.6 you could directly check for released keys using
sf::Event::KeyReleased
atleast, I would assume that was what it did?
You still can check for KeyRelease that's the event system we've been refering to all the time (and which is already explained in the official SFML 2 tutorial...):
while(window.isOpen())
{
    sf::Event event;
    while(window.pollEvent(event))
    {
        if(event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::A)
            std::cout << "The key A was released!" << std::endl;
    }
}

Now that binary so kindly supplied me with the information that sf::Clock should be more accurate than timeGetTime(), I will be building a clock class with an internal sf::Clock.
Not only that it's also more crossplatform. ;)

Ah you see if you had thrown this solution to me at the start I would never have continued badgering you. :)

I read the tutorial but obviously I must have missed that section. Very truly sorry. You can believe that I am thoroughly embarrassed right now.

Pages: 1 2 [3] 4 5 ... 7
anything