Strewya

Members
  • Content count

    194
  • Joined

  • Last visited

Community Reputation

2798 Excellent

About Strewya

  • Rank
    Member

Personal Information

  • Interests
    Design
    Programming
  1. Depicting attack/spell ranges before movement?

    I'm working on a squad based, turn based game that has a similar issue. We solved it by making a look-ahead mode, where by pressing a button, you "project" the selected unit onto the tile you're hovering over, so you can see the attack range of your selected ability in the case you move your unit there. Releasing the button simply "cancels the projection". This way the player can check his ranges before commiting to the action, allowing him to tactically plan ahead.
  2. I'll just pop in to mention that the first approach Finalspace mentioned is the approach that Handmade Hero is doing, and the series is video documenting every step of the way. https://handmadehero.org/ https://hero.handmade.network/episodes
  3. I'd like to throw my pennies in the pile as well, which might echo Satharis a bit.   Your idea of making the systems run concurrently is, in my opinion, not a good idea. You should have a very clear and strictly defined sequence of operations that transform some data into other data. You input system transforms input messages into commands. You command system transforms commands into general actions. Your physics system transforms these actions into a position delta for your entities. As a purely output based system, the rendering system reads the positions, mesh/sprite data, and outputs them to the screen. None of these things can be run in parallel. Even audio might need information about an entity so it can play sounds at the correct 3d world position. And then you have animation systems that might have to be processed two times, once before physics, once after.   Your assumption in the first post that the systems are independent is thus not correct. All of these systems are dependent on another system, even your input system has a dependency (SDL). What you can do is parallelize the transformations within each system, so each object is transformed independently of one another.   So to get back to the question you posed: Send out each message immediately as it's ready, unless you want the message to be received at a later time, in which case you should be explicit about it and probably just process the message in the receiving system at that later time.
  4. Criticism of C++

    Note that i know almost nothing about Jonathans language except for one video i've seen a few years back when he first started working on it.   This only assumes the language itself doesn't provide you with mechanisms for pointer ownership. I recall from when i watched his first video that he wants to have a mechanism where the language and compiler themselves know that a variable is the owner of a pointer. Imagine it as having the unique_ptr as a built-in type, and not a template as well. As far as dot operator overloading, that is a valid question, one which is probably answered in one of his videos, maybe.   How do you easily and cleanly move lambdas that have captures? No idea if his language can do the same, so not sure the question is valid enough.     But anyway, you are using two different terms. Are you talking about preprocessing, which templates don't do, or compile-time computation? It sounds like you are talking about compile-time computation. If so, C++ added that back in 2011, using the 'constexpr' keyword. Initially it was (intentionally) limited in C++11, but they expanded it more in C++14, and intend to keep on expanding it to do exactly what you're talking about: Running arbitrary C++ code at compile-time to compute things, within limitation. Currently it's not fully unleashed, as they are gradually relaxing restrictions with each C++ release, to make sure any problems are ironed out and to give compiler developers a chance to catch up, and so programmers has a consistent featureset until it's fully present.   But the end result is the same, no? You get some automatic code generation done for you. In C, you have only macros to do things templates can do in C++. Granted, they both have their uses in C++, but it would help if you stopped looking at Johns language as an upgrade over C++, rather as an upgrade over C. As was mentioned in this thread, there's a smaller, simpler an easier language in C++ trying to get out, and that language is C. So why not improve C with some of the stuff C++ does better? Also, constexpr is very limited right now, and will probably stay limited to some degree. Johns language has no limitation. Sure, you'd have to control yourself and know that if you invoke an expensive function during compilation, it's gonna slow it down. But then again, you're a programmer, you're supposed to know the tradeoffs of doing so.   Again, the jumping to another file is solved by better tools. I can Ctrl+Click in the IDE I use, to jump between declaration and definition. Whereas there are arguable benefits for separating the two. Many C++ programmers argue the opposite extreme of what you are saying, complaining that a C++ class's private member variables are visible in the header.   Now, headers have other problems (mostly as a result of macroes, which are the reason many seemingly unrelated areas of C++ have taken so long to get fixed), but C++ is migrating towards a module system similar to Python's, which will solve alot of issues. Last I heard, the modules are supposed to get unofficially added to compilers in late 2017 or earlier 2018, and be officially standardized in 2020.   Sure you can jump easily with your IDE, but you'd have to jump less if we'd all just have the .cpp files instead of .h files, no? This might be the thing modules fix after they roll out, but i believe he was referring to having a java/C# model of just having one file type and the compiler figures out all the function names and symbols without you having to write a separate header file to include all over the place just so you can call a function cross files.   C++ is a general purpose language, and has it's flaws when it comes to certain domains, this much we can agree on, and it's been mentioned throughout this thread. As such it will never be perfect for game development. So why shouldn't we strive to have a language specifically suited for game development? Even if it's just C with some extra blows and whistles, some borrowed from C++, some invented to suit the needs of game development. Dismissing attempts to do so because we have something good enough... Well, the wheel got reinvented from time to time, didn't it?  
  5. Is it feasible to make both mechanics, and toggle between them through a menu option?
  6. Member function pointers?

    To be fair, casting a member function to a regular function is possible, but is usually not a smart thing to do because it depends on the compiler and if the function is virtual or not etc. class A { public: void Method(int x) { cout << x << endl; } }; void (Func*)(A* this, int x); int main() { A instanceA; Func f = (Func)(A::Method); //or some such evil cast, not sure if i'm missing and address operator, i.e. &A::Method f(&instanceA, 5); } However, if you're doing this, note that your code is bad and you should feel bad and change it promptly to a good design so you start feeling good because your code is not bad anymore. :)
  7. Member function pointers?

    If you use C++11 onward, you  should use std::function and combine it with std::bind. class AnotherObject { public: std::function<void(void)> callback; }; class TestObject { public: void MyFunction() {}; }; int main() { AnotherObject ao; TestObject to; ao.callback = std::bind(&TestObject::MyFunction, &to); ao.callback(); } Edit: Good catch by CapThunderNutz below.
  8. I recommend you get yourself a copy of Game Engine Architecture by Jason Gregory. It explains a lot of this stuff, overview at first, and dives into specifics later on.
  9. Box2D Problem

    It sounds like it might be the ghost vertices. Your OP is not fully clear to me, but i'll assume your body stops moving suddenly and doesn't move at all in that direction anymore? Does it move in the other direction?   What you could do is generate the static bodies a bit differently. Instead of making them one at a time and having a large amount of small boxes, generate as big of a box as you can in the x direction. Modify the algorithm so when you find a tile that is == 1 (aka ground), find all consecutive tiles on the x axis that are == 1, and if you find there are i.e. 5 of them (looking at your map definition above), you would generate a box that is 5 times the width of a single box, with proper position modification so it gets placed in the right location. You could also modify teh algorithm so you look at both x and y directions, so if you have a block of ground that is 3 high and 5 long, you generate just one box with the proper position and size instead of 3 when just looking at the x axis, and opposed to 15 with your current method.
  10. Help me find tutorial to make this type of game

    Handmade Hero is trying to make a Zelda like game. https://handmadehero.org/ It goes from the very fundemental basics, so if you're trying to learn coding from the ground up, try this.
  11. C++ engine hosting LUA scripts

    There are two ways to do this on Windows. One way is to use Win32 API functions ReadDirectoryChanges coupled with WaitForSingleObject in another thread. I personally found this to be a pain in the ass when trying to implement it myself, so i found a project somewhere on the interwebz and just took it for granted it will do what i need. This will give you notifications about any file that changes in a specific directory of your choosing.   The other way is to use GetFileTime coupled with CompareFileTime function. When you read the file the first time, read it's modification time and store it. Each time through the game loop, for each file you're interested in, read the modification time again, compare it with the stored time and if it's newer, read it again, because you know it's been modified from the last time you used it.
  12. I am sure this isn't allowed to be const or a reference as it has a default value   That is perfectly valid c++ code. It would be better if it wasn't a const reference but a plain float, but both are valid.
  13. DirectX or OpenGL - 2D

    I'm going to quote fastcall22 on this one from the previous topic:   This sounds familiar... Nope nope nope.
  14. Vector cast

    If we're talking about a 2/3/4 dimensional vector class that has a x/y/z/w components, then i'd pass it by value if i'm not modifying it. Works the same as a const reference, and since it's a temporary, you really don't need it to be a reference to anything, const or not.