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

Author Topic: My new Project  (Read 23395 times)

0 Members and 4 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: My new Project
« Reply #30 on: November 26, 2012, 09:37:54 pm »
my brother-in-law has the same problem whit my program, he runs windows 7.
Then you should probably start describing what goes wrong, rather than 'it doesn't work'. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #31 on: November 26, 2012, 09:48:04 pm »
Probably start describing what goes wrong, rather than 'it doesn't work'. ;)

I hope I do not understand you wrong now, I thought the problem would be clear.




The cursor was just a brown quadrangle and no items get shows until i pick it up whit mouse.
« Last Edit: November 26, 2012, 09:50:04 pm by grimmreefer »

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #32 on: November 27, 2012, 01:15:37 pm »
Which graphic card have you?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: My new Project
« Reply #33 on: November 27, 2012, 01:30:29 pm »
Which graphic card have you?
I've an Readeon HD 6470M (ATI).

I quickly skimmed through your code and noticed quite a few things one shouldn't do. One of the things I see that could cause big problems are your global instances... :-\
I strongly advice you to use a class instead of letting everything lie around in the global scope. Just pack all your functions and objects of RunGame into one class, create an instance in main.cpp and use that objects to call functions.

If you want I can also give some more feedback on the code. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #34 on: November 27, 2012, 02:34:00 pm »
Which graphic card have you?
I've an Readeon HD 6470M (ATI).

Ok, its not the graphic.

I quickly skimmed through your code and noticed quite a few things one shouldn't do. One of the things I see that could cause big problems are your global instances... :-\
I strongly advice you to use a class instead of letting everything lie around in the global scope. Just pack all your functions and objects of RunGame into one class, create an instance in main.cpp and use that objects to call functions.

If you want I can also give some more feedback on the code. ;)


So bad? Is my RunGame the worst or is there something worse?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: My new Project
« Reply #35 on: November 27, 2012, 06:26:39 pm »
Ok, its not the graphic.
It still can be, since ATi != ATI. I'm stuck with an older ATI-HP driver (can't update unless HP provides a new driver package :-\).

So bad? Is my RunGame the worst or is there something worse?
Well it's the only one not using a class, so yeah that's quite bad.

Here a few things you could change:
  • Don't use global variables and don't even think about using global instances! (E.g. no global sf::RenderWindow, no global sf::Clock...).
    If you 'need' global objects then your design is most probably flawed.
  • Don't use the C prefix for classes, it's unnecessary and an old Microsoft relic.
  • CLights::AddLigth should be named CLights::AddLight
  • locallConverter.hpp should be called localConverter.hpp
  • Keep the code naming consistent; e.g. localConvert should like the rest of the files get called LocalConverter or all member variables should use the m_ prefix, etc.
  • Try to reduce code repetition as much as possible (e.g. the AddLigth calls in RunGame).
  • To get a nicer draw call derive the object which can be drawn from sf::Drawable (object.draw(window) -> window.draw(object)).
  • Make use of the initialization list to initialize member variables.
  • Inventar and Objekt are German, the English words are Inventory and Object. ;)
  • Maybe use more descriptive and less confusing names for Light and Lights.
  • Don't use using namespace std, it's a little more to write, but after some time you get used to std:: and it makes things clearer where they come from.
  • Don't use backslashes for header inclusions. There's no problem with forward slashes under Windows (e.g. #include <SFML\Graphics.hpp> -> #include <SFML/Graphics.hpp>
  • Only include the class headers of the classes which are actually needed in that file. E.g. #include <SFML/Graphics/RenderTexture.hpp> instead of #include <SFML/Graphics.hpp>.
  • Don't use a vector of vectors, but use one vector and calculate the two dimensions on your own.
  • Maybe you should read again a bit about const correctness, I bet most of your arguments shouldn't get altered.
  • Use consistent indenting.
Quite a long list, as you see there's quite a bit that can be improved and when your done, you'll be glad you did it, because the source will look way better and more dense than the current chaos now. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #36 on: November 27, 2012, 06:47:41 pm »
 :o So many things, omg.

is it still acceptable? Or did i waste my time?


gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: My new Project
« Reply #37 on: November 27, 2012, 07:00:56 pm »
is it still acceptable?
What do you mean ? It's not an exam, there is no minimum performance required to be acceptable. Is it acceptable for a company ? Probably not. But it's not what you're after - for now, at least.

Or did i waste my time?
eXpl0it3r gave you clues for improvements, so you didn't really waste your time. A complete restart might be an idea, but this will probably happens more than once anyway (and not because you suck ; it happens to many people), so don't feel down because of it.

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #38 on: November 27, 2012, 08:41:59 pm »
@eXpl0it3r

i really like the idea with the RunGame Class, it should have been clear to me.
Above all I need no more global variable. And the entire management is simplified.

all beginning is hard, but thanks guys.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: My new Project
« Reply #39 on: November 27, 2012, 09:42:50 pm »
Quote
Don't use backslashes for header inclusions. There's no problem with forward slashes under Windows (e.g. #include <SFML\Graphics.hpp> -> #include <SFML/Graphics.hpp>
Note for vs 2010 users: this seems to be totally supported by microsoft but, in their infinite wisdom, they've hidden the option under 'Tools->Options->Text Editor->C/C++->Advanced->IntelliSense->Use Forward Slash in #include Auto Complete' which is set to false by default.
« Last Edit: November 27, 2012, 09:44:38 pm by FRex »
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: My new Project
« Reply #40 on: November 27, 2012, 10:56:19 pm »
:o So many things, omg.
is it still acceptable? Or did i waste my time?
Well many things are just minor corrections, like spelling and naming conventions, so don't get scared from a list. Also nothing is really mandatory on there, but they'll improve your code quite a bit and as I said, when you're done 'refactoring' you'll feel way more comfortable working with your code.

Nothing is wasted, because with every step you've learned something new. ;)
Keep in mind not that many get as far as you already have.
As gyscos already said, everyone needs some iteration until he gets a final product - nobody is born as a programmer. :D

i really like the idea with the RunGame Class, it should have been clear to me.
Above all I need no more global variable. And the entire management is simplified.
Yes!
I usually go with an Application class and a StateManager with different states (menu state, play state, credit state, etc). Maybe it's another thing you could look into, as an example my SmallGameEngine.

Note for vs 2010 users: this seems to be totally supported by microsoft but, in their infinite wisdom, they've hidden the option under 'Tools->Options->Text Editor->C/C++->Advanced->IntelliSense->Use Forward Slash in #include Auto Complete' which is set to false by default.
Cool didn't know that. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Re: My new Project
« Reply #41 on: November 28, 2012, 02:19:31 am »
No code is perfect code :) At the end of the day, everybody can improve all the time. It's one of the things that appeals to me about programming, there is always more to learn.

As some general advice, the less any section of code depends upon any other section of code the better. Statefulness is something you should look to reduce in your code as much as possible, because a reduced presence of state tends to reduce the complexity of the code without reducing the end result. Which is good because it makes code easier to understand, test, debug, write and maintain. All of those are good things.

This is why global variables are so, for me and many others, considered undesirable: They introduce state into all of your code wherever they go. It can quickly become an unmaintainable nightmare.

Of course some state is needed in video games, but it's still best if that state is contained to only where it's needed.

And, as always: Good luck and happy coding :D
« Last Edit: November 28, 2012, 02:21:03 am by MorleyDev »
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #42 on: December 01, 2012, 06:47:24 am »
How can i get the Global World coordinates  to my local window coordinates?
I give sf :: view :: getCenter () in the function.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Re: My new Project
« Reply #43 on: December 01, 2012, 09:02:44 am »
How can i get the Global World coordinates  to my local window coordinates?
I give sf :: view :: getCenter () in the function.
sf::View::convertCoords()
Btw it's nicely documented in the documentation and for sf::View there's a good tutorial on the wiki. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

grimmreefer

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: My new Project
« Reply #44 on: December 01, 2012, 09:26:38 am »
8) ok thx