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

Pages: 1 ... 606 607 [608] 609 610 ... 719
9106
Window / Re: sf::Window in my own class trow Errors
« on: November 28, 2012, 10:38:26 pm »
Welcome to the forum! :)

Quote
I learn a little bit C++ for myself and found this engine.
SFML is 'just' a multimedia library and by far not an engine/framework. ;)
I'm not trying to take away your motivation, but keep in mind that programming a game (specially a 3D game) isn't trivial at all and needs way more than 'a little bit C++' knowledge. At best you get a good book about C++ and read it front to back. :D

Well you've already identified your problem: global instances. (Side note: if you're using VS10 it probably runs 'fine' in release mode.)
The solution to it is, don't use global instances, in fact don't use any globals at all, but wrap things into a class, think about a better approach to accessing your window and pass things around with references. ;)

9107
Graphics / AW: Re: sf::Texture out of scope?
« on: November 28, 2012, 02:36:49 pm »
I'm curious about this.  What aspects of SFML are sensitive to the order of initialization of objects?
It's not directly a SFML problem. The destruction order of global instances (i.e. the objects get initialized globally) are undefined, thus if X would depend on Y, then it might happen that Y gets destroyed before X gets destroyed, which can obviously lead to problems. ;)

9108
Graphics / AW: Re: 3D camera library/code available?
« on: November 28, 2012, 10:58:45 am »
Be aware though that as SFML doesn't support 3D you can't use SFML's renderTexture for it, you'll have to implement your own version of renderTexture using OpenGL or use whatever a 3D engine grants for that so that you can take benefit from 3D transforms.
Don't take my word for it, since I've no idea about OpenGL, but you should easily be able to extract the texture from the render texture and call bind() on it to get it working with OpenGL, but maybe I'm mistaken (or one can't call bind() on the const ref texture...). ;)

9109
Graphics / AW: Re: Shape not placing properly
« on: November 28, 2012, 10:13:42 am »
I believe it would be better for you to set the origin directly in the center of it (width/2,height/2), otherwise it draws from the top left corner, which is just weird.
Well generally speaking it really depends on how you handle things. If you're for instance in a grid, it's way easier to have the origin of all object redering to the top left (or at least the same relative position), rather than having to branch and manually calculate the actual position.

In this case though it might be easier to change the origin and place it in the middle of the screen. ;)

9110
Graphics / AW: Re: Image and OpenGL does not work
« on: November 28, 2012, 10:01:50 am »
I do not have any lighting there
Well there's definitely some very basic lighting goong on, otherwise the top and left surface of a box wouldn't be darker than the front ine. ;)

// EDIT I have just changed the image size from 204x204 to 128x128 and it works good now :D.
Nof sure why that fixed it, but I'm glad it did. ;)

9111
General / AW: Pressing Enter causes two screen switches instead of 1!
« on: November 28, 2012, 09:10:00 am »
What gyscos meant is that you have to check first if the event type is KeyPressed or KeyReleased before you can check the key code. If you don't do that you run into undefined behaviour since key code can hold anything...

9112
Graphics / AW: Help in moving sprite
« on: November 28, 2012, 09:06:37 am »
To move a sprite or a shape you can use move():
sf::CirlceShape ball(10.f);
// ...
ball.move(10.f, 10.f);
If you want some physics you need to implement it or use an existing library. ;)

9113
Graphics / Re: 3D camera library/code available?
« on: November 28, 2012, 12:30:34 am »
SFML is a 2D library, thus you won't find any 3D stuff... ;)
If you want 3D then use your own OpenGL code.

9114
SFML projects / Re: My new Project
« 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. :)

9115
Graphics / Re: GetPosition for shapes and sprites
« on: November 27, 2012, 10:43:39 pm »
Stupid of me. I thought first args of constructor are pos.
Well RTFM! it's so nice and easy understandable. ;)

Also I advise you to use SFML 2, because SFML 1.6 hasn't been touched over 2 years, has many bugs and lacks a lot of new and shiny features. :)

9116
Graphics / Re: Image and OpenGL does not work
« on: November 27, 2012, 10:39:30 pm »
It seems to me like clipping/lighting is set in a way that it turns black at a certain distance, but I've no idea how OpenGL works... ;D

Ehrm don't you want to use a real texture: sf::Texture?
There's a difference between sf::Image and sf::Texture; of course if you really want to use the pixel array you need to use a sf::Image, but sf::Texture has a bind() function, so you can easily use it with your OpenGL code. ;)

9117
SFML projects / Re: My new Project
« 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. ;)

9118
Graphics / Re: sf::Sprite vector reference to sf::Texture vector
« on: November 27, 2012, 04:51:10 pm »
I think a vector of Texture is pretty dangerous in the first place. I'd say a vector of Texture* would be a little easier, since you don't have to worry about such invalidation-on-destructor and so on. Deleting the texture on removal is a small price to pay.
Both are bad ideas! Nowadays there's just no need to manually manage your memory, it's actually even depreciated. :-\

Either use a static number of textures and size the size of the vector in advance or use a recent compiler and std::unique_ptr. ;)

9119
General / Re: Building the SFML aplication on MAC - sfml-system-d not found
« on: November 27, 2012, 03:44:53 pm »
I've no idea about Macs either, but have you been following strictly the official tutorial?
If you do it correctly with Xcode everything should work out fine. ;)

9120
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 03:42:49 pm »
...it's not freedraw. If it's not freedraw...
FreeType I assume... ;)

Although I didn't follow the whole other thread and thus don't have as much insight as Qix, but I agree.
Then again we all know that Laurent has little time on his hands and iirc he has a Nvidia card, so maybe we (as a community) can hunt down the problem and try fixing it and I'm sure he'll try to be as much of a help as possible. ;)

Pages: 1 ... 606 607 [608] 609 610 ... 719
anything