Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions  (Read 18589 times)

0 Members and 1 Guest are viewing this topic.

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #30 on: August 19, 2012, 11:44:25 pm »
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.
« Last Edit: August 19, 2012, 11:57:37 pm by natchos »

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #31 on: August 20, 2012, 12:10:53 am »
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.
« Last Edit: August 20, 2012, 12:31:57 am by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #32 on: August 20, 2012, 12:35:11 am »
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. ;)

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.
« Last Edit: August 20, 2012, 12:36:45 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #33 on: August 20, 2012, 01:01:53 am »
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?
« Last Edit: August 20, 2012, 11:44:28 pm by natchos »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #34 on: August 20, 2012, 08:33:05 pm »
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();
}
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #35 on: August 21, 2012, 12:20:33 am »
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;
                }
        };
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #36 on: August 21, 2012, 12:29:20 am »
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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #37 on: August 21, 2012, 12:42:50 am »
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? ^^

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #38 on: August 21, 2012, 12:47:58 am »
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... ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #39 on: August 21, 2012, 12:53:01 am »
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.
« Last Edit: August 21, 2012, 12:55:37 am by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #40 on: August 21, 2012, 01:04:18 am »
Well most of them are 'just' conversion warnings and there are quite a few other problems like undeclared variables etc...
The "error C2146: syntax error : missing ';' before identifier 'JumpClock'" is often just any syntax error...

Quote
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.
If the file is under 128kb then you could add it to the post, otherwise you'll have to use an external website. (Unfortunatly the creater of sfmluploads.org didn't want to hand over his scripts so someone else could've carried on his work... >:( )
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #41 on: August 21, 2012, 01:09:57 am »
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.
« Last Edit: August 21, 2012, 01:39:48 am by natchos »

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #42 on: August 21, 2012, 10:52:01 am »
I fixed the problem.
« Last Edit: August 21, 2012, 11:23:10 am by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #43 on: August 21, 2012, 11:51:22 am »
I fixed the problem.
Yeah your Watch class is inside a the sf namespace...

Man you should really take a look at other existing source codebases. There's quite a mess in your code. :-\
  • You're including a source file! Never ever do this. If you have declerations put them into a header file and include that.
  • Next you shouldn't place SFML into your source directory, but you should place it somewhere on your disk and add the paths to your project configuration and then you should include the libraries header files with #include <SFML/Graphics.hpp>, i.e. use <> instead of "" and / instead of \.
  • You shouldn't place your own code into the SFML's sf namespace, it's not a good practice and when someone would ever have to take a look at your code it could be quite confusing. If you want it to live in a namespace, create one of your own.
  • Since your developing in C++ it's also good practice to use the .hpp extension instead of the .h one, so it's clear what is C-ish and waht's C++ish.
  • You're using soooo many global variables, this can quickly lead to problems and if you'd use any global SFML resources it often ends in some crashes. Always try to avoid global variables as much as possible.
  • In connection with the point above you could fix a few of the global scope issues by creating an application class that will hold all the variables as members as well as the global functions as member functions.
  • You should not fear new lines and spaces. Clumbing everything together and having a lot of 'inline' definitions makes the source extremly hard to read. Also if you'd make use of identing everything in some way but a constitante way then you'd get so much overview of your source code.
  • You should seperate class decelration and class definition into two files, a header file for the decelaration and a source file for the definition.

I hope those few points help you to get a nicer codebase. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions
« Reply #44 on: August 21, 2012, 03:46:16 pm »
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.


 

anything