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

Pages: 1 2 [3] 4 5
31
General / Re: Major lag when a C++ statement is removed
« on: March 04, 2014, 10:50:47 am »
Console output is always slow and laggy, compared to the rest  ;)
Why do you need it?

32
Graphics / Re: texture problem
« on: March 03, 2014, 04:19:15 pm »
Hi there.
Unfortunately, the code you showed is to short to answer your question.
Please reduce your project to a minimal and complete example (i.e. an example that shows the problem). Minimal is crucial, nobody has the time to read through several pages of code.

During the preparation of a minimal example, one often has the chance to solve the problem  ;)


By the way, your use of the namespace operator :: is way over the top. It is sufficient to use it in the method signature, but not in its body. Whats that with Npc::location? That is an attribute, not the parameter location you are referring to.

33
Window / Re: Native Menus
« on: March 03, 2014, 01:38:27 pm »
Well, enabling it (for Win32 anyways) is only 10 lines of code, so it's hardly clutter.
As Laurent pointed out: API clutter, not code clutter  ;)

Still I don't think that native GUI integration needs to be a basal feature. Look at other, similar frameworks like SDL or Cinder: They also don't have any native GUI integration.

If you are unsure: Start a poll to gather the opinions of the community.
The main advantage of SFML imho is that only needed features are implemented. However, if the majority wants that integration Laurent shouldn't be hesitant either  ;)

34
Window / Re: Native Menus
« on: March 03, 2014, 11:54:08 am »
SFML is a libray for multimedia/game development. For these cases it is unusual to use the native GUI API delivered by the OS. Since almost every game uses its own GUI -- often for aesthetical purposes -- it is outside the scope of SFML to use native APIs.

I don't want SFML to be cluttered with those additions that would be necessary to use native GUIs. I wouldn't use it either.

And in those cases where you need such an integration (e.g. maps editors or the like), the current state of integration between Qt and SFML is more than sufficient.

35
General / Re: Need help with a problem in my game
« on: February 27, 2014, 10:36:46 am »
Ok, I know that book, it is ok, although a little bit outdated.
If you want some suggestions: C++ Primer, written by Lippman/Lajoie/Moo. Buy the last english(!) edition, since it covers the new C++2011 standard.

36
General / Re: Need help with a problem in my game
« on: February 26, 2014, 10:14:26 pm »
May I ask for the title of the book?

37
General / Re: Rendering without RenderWindow
« on: February 26, 2014, 10:09:25 pm »
No, that's not possible..... unless you create a device context and a rendering context for the HWND and setup the correct pixeldescriptor for Windows and OpenGL and use the wgl-functions and all the other platform-dependent stuff.

Which would make SFML useless/obsolete.

Why do you want to mess around with WinAPI internals while using SFML? What kind of problem are you trying to solve?

38
General / Re: What's the best method to give an entity a "search" range?
« on: February 26, 2014, 09:15:03 pm »
Just do the brute force check "every turret <-> every enemy". If you have few turrets and enemies (like 100 or so) the check shouldn't be that bad on today's computers.

But if you really happen to experience any lags, use a spatial data structure like a quadtree to organize your objects and to reduce the number of tests that are needed.

39
General / Re: Help Compiling SFML
« on: February 26, 2014, 06:01:34 pm »
But that's not exactly a deep arcane secret.
Never said anything like that  ;)

40
General / Re: Help Compiling SFML
« on: February 26, 2014, 05:19:58 pm »
The compiler options of CMake are somewhat different to MSVC's versioning. Visual Studio 12 is Visual Studio 2013 and Visual Studio 11 is Visual Studio 2012, because MSVC2013 is Microsoft-internally referred to as version 12.

41
General / Re: Implementing gamle loop with alpha state blending
« on: February 26, 2014, 04:49:40 pm »
You mean state as the state of physics as Glenn wrote? If so, I think it wouldn't be that hard to implement. Just make sure that the elements you use to describe actual data (vectors for position, quaternions for orientation) would implement lerp/slerp (e.g. sf::Vector2 c = lerp(a,b, alpha); for vectors a and b). You certainly would have to preserve the previous state in your game objects. So if there is an object which sprite's being moved, you would save two positions inside the object's instance.

A quick and dirty try on this (can certainly be improved  ;) ):
sf::Vector2 lerp(const sf::Vector2& a, const sf::Vector2& b, float alpha)
{
        return sf::Vector2(a * alpha + b * (1.0f - alpha));
}

class GameObjectInstance
{
public:
        void UpdateLogicPos(sf::Vector2& offset)
        {
                oldPos = actualPos;
                actualPos += offset;
        };

        void UpdateRenderPos(float alpha)
        {
                mySprite.setPosition(lerp(oldPos, actualPos, alpha));
        };

        sf::Sprite& Sprite()
        {
                return mySprite;
        };

private:
        sf::Sprite mySprite;
        sf::Vector2 oldPos;
        sf::Vector2 actualPos;
};



// main drawing loop
// ..

        for (auto goi : myObjects)
        {
                goi.UpdateRenderPos(currentFrameAlpha);
                window.draw(goi.Sprite());
        }

// ..

42
For someone's own learning purposes (learning by doing) it could be a good idea to write such a framework. But from a possible user's point of view I only can say that this project grows more and more into YAGNI.
I'm sorry, Lolilolight, but with your current development philosophy I guess there won't be many persons interested in your framework.

Asides, I wish you good luck and motivation to continue  ;)

43
General / Re: Need help with a problem in my game
« on: February 26, 2014, 04:22:54 pm »
So what's the problem now? In your last post you stated that you "just tested it out". This looks like everything is fine.
If it isn't, you need to describe your current problem  ;)


If it's just the same as above (only one coin drawn): Your function draw_coins() is only called once per loop and only draws a single coin. So if you want to draw all coins you just have to loop over your vector and draw all spawned coins.


By the way: There are several things you could improve.
At first and foremost: EDIT: I've just seen that the formatting is wrecked by pastebin. The "RAW paste data" is ok. Pretty formatting! Your code is a mess. Just use consistent(!!!!!) and simple indendation (2 spaces, 4 spaces, 1 tab per block, just as you like, but be consistent).
And please get rid of those #pragma region things. Although they should make the code more readable, they clutter it more than necessary.

And then, the content: Why do you have a std::vector of somehow "constant" size? Why don't you use it the way it is supposed and push_back every new object? You could for example add newly spawned coins to the vector and remove any coins that would be collected or somehow moved offscreen. This would simplify drawing a lot! Just loop through the vector (google for C++11 for-range-loops) and draw each object. Bang, there you are.

You are making your code more complicated than necessary. KISS: Keep it simple and stupid :)
It seems you have a programming background somehow based on a mashup of C and C++. Where did you learn to program? Did you read a book? There is much potential for improvement, young padawan  ;D

44
General / Re: Optimizing CPU usuage
« on: February 25, 2014, 11:43:01 am »
but my while loop doesn't always call window.display() only when there is user input.
Why do you do this? Look at the big red box on this page: http://sfml-dev.org/tutorials/2.1/graphics-draw.php
It is absolutely correct to to a clear->draw->display every frame. Don't mess with this concepts if you are using SFML (and OpenGL and DirectX aka. all modern acclerated graphics APIs/Libs).


Why do you want to reduce CPU usage? Is your program designed to run as a background process? Then I wonder why you use SFML.
If you program is the "main" running program, like it is normal for a (fullscreen) game, you shouldn't limit your CPU usage without any reason!

45
Graphics / Re: RenderWindow doesn't clear
« on: February 06, 2014, 09:23:45 pm »
Yeah, that's right. To update the screen, i.e. swap the buffers, you need to call display().

Aside from that I wrote completely nonsense. I confused your usage of showLogo() somehow.
Your loop was nearly correct, apart from that last clear(). Sorry.

Pages: 1 2 [3] 4 5