ultramailman

Members
  • Content count

    317
  • Joined

  • Last visited

Community Reputation

1720 Excellent

About ultramailman

  • Rank
    Member
  1. How to initialize a reference variable in a Quadtree?

    Hey SteveHatcher,   I have no idea what multiple managers can achieve, and I wasn't suggesting you to have multiple managers. I was just remarking that *if* for some reason you need multiple managers, passing the manager as a parameter would be the way to go as passing parameter provides the most flexibility out of all the other options. This goes for other similar situations as well.   Like BitMaster said, a static variable in a class is just like a global variable outside a class. It may be what you need if you are very sure you will only need one manager.   I don't have much to say about your quadtree, since I don't know much about using quadtrees and ECS together. I remember L.Spiro has an article on efficient quad trees though. Here it is: http://lspiroengine.com/?p=530
  2. How to initialize a reference variable in a Quadtree?

    If you really don't want to keep a member reference variable to the entity manager, you could pass it as a function parameter to the functions that actually need it.   Another way is to make the entity manager a global variable.   Personally I think the member reference variable approach is fine, it's pretty simple. Passing the manager as a function parameter is more flexible, but you probably don't need it unless you are considering the possibility of using the same tree node on different entity managers . On the other side, you have the global entity manager approach. That's a fine approach if you will only ever use one manager.
  3. Java Challange

    Ooo can somebody explain deftware's code? I didn't know .java files can look like that (looks like some kind of assembly?). How does it call checkCubicRoot? Also Mr L, are you accepting trick answers or are you really looking for a specific mathy solution?
  4. If you are having troubles with ordering of indices, you can make yourself a function that accepts indices in whatever order you want.   item = array.atXY(x, y)
  5. I think I don't understand dynamic memory

    Maybe I can try using analogy to explain it.   automatic allocation: Imagine there is a restaurant with many tables and seats. You and your family go in the restaurant. The mute receptionist sees that you have 5 people, and leads you to a table G, with 5 seats. Now table G is occupied by your family. When you are done eating, you leave the restaurant. The receptionist sees that and table G is unoccupied. The next family of 5 that comes are able to use table G. This whole time, you did not speak to the receptionist at all, because he is mute.   dynamic allocation: Now Imagine there is another restaurant with many tables and seats. You and your family go in the restaurant. The blind receptionist asks "how many people"? and you tell him 5. The blind receptionist finds an unoccupied table E with enough seats for 5 people. He's blind so he doesn't want to talk and trip, so he tells you where the table is. Now table E is occupied by your family. When you are done eating, you leave the restaurant. However, you forgot to tell the blind receptionist that you left. He still thinks table E is occupied by you, so table E will not be given to any customers.   tables and seats = memory, since they are space. customers = data, since they are the contents that occupy space. the act of entering/leaving restaurant = entering and leaving a scope. the act of being led to a table by the mute receptionist = automatic allocation. the act of telling the blind receptionist how many seats you need at the minimum, and getting the location of the seats/tables = dynamic allocation.   This analogy omits some details, but I hope that helps.
  6. There's also a way to use 1d array as a logical 2d array while keeping the [][] indexing syntax. Basically you have your Wrapper class that has an operator[]. This operator[] returns a light weight "view" object that defines the operator[] as well. The [] operator of this view object then returns the item you want. Grid g(10, 5); View v = g[2]; Item i = v[3];   // or simply Grid g(10, 5); Item i = Grid[2][3]; Basically indexing the grid by x gives you a closure, and calling the closure with y effectively gives you the item at grid[x][y].   edit: http://www.gamedev.net/topic/665945-easiest-way-to-pass-a-2d-array/#entry5211935 looks like someone else already gave an example of this, in a different thread on a similar topic
  7. What ^ said. If you want pretty code for the indexing logic, it's pretty easy to wrap around in a function.   You can also make a wrapper class that only contains the 1d vector and some methods or operator overloads. That'll allow you to write it like 2dArray.at(x, y) or even 2dArray(x, y).
  8. noncopyable parent class

      Yes sorry if I didn't clarify before, but I'm pretty sure I'm not doing a copy in my own code, because I don't have any code. I'm simply trying to build sfml from source.
  9. noncopyable parent class

      good catch! In the source code, m_mutex is a noncopyable, and is contained by the Lock class. I suspect clang saw that m_mutex is noncopyable, and is trying to tell me that a copyable class can't have noncopyable members. However, the containing class is also a noncopyable. Clang didn't know Lock was noncopyable at that time. This looks like a something to do with the order of semantic analysis.   If this is what happend, then this could be a clang bug, a clang bug but only on windows, or g++ is incorrect.   So I tried changing private constructors to deleted ones, and I get a pretty similar result.   In file included from E:\Programming\SFML-2.2\src\SFML\System\Lock.cpp:28: E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: error: attempt to       use a deleted function class SFML_SYSTEM_API Lock : NonCopyable                       ^ E:/Programming/SFML-2.2/include\SFML/System/NonCopyable.hpp:79:18: note:       'operator=' has been explicitly marked deleted here     NonCopyable& operator =(const NonCopyable&) = delete;                  ^ E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: note: implicit copy       assignment operator for 'sf::Lock' first required here class SFML_SYSTEM_API Lock : NonCopyable                       ^ In file included from E:\Programming\SFML-2.2\src\SFML\System\Lock.cpp:29: E:/Programming/SFML-2.2/include\SFML/System/Mutex.hpp:47:23: error: attempt to       use a deleted function class SFML_SYSTEM_API Mutex : NonCopyable                       ^ E:/Programming/SFML-2.2/include\SFML/System/NonCopyable.hpp:79:18: note:       'operator=' has been explicitly marked deleted here     NonCopyable& operator =(const NonCopyable&) = delete;                  ^ E:/Programming/SFML-2.2/include\SFML/System/Mutex.hpp:47:23: note: implicit copy         assignment operator for 'sf::Mutex' first required here class SFML_SYSTEM_API Mutex : NonCopyable                       ^
  10. Hello Gamedev.   I was trying to build SFML with clang on Windows, but it gave compiler errors about NonCopyable having private copy constructors (isn't that the whole point of NonCopyable?). However, if I try to build SFML with mingw g++, it compiles without any problems. Does anyone know if this is a clang bug, a non-standard idiom supported by only gcc and not clang, or something else?   I can still get it to build under clang if I delete the code that inherits from NonCopyable and add private constructors to those classes by hand.   example:   In file included from E:\Programming\SFML-2.2\src\SFML\System\Lock.cpp:28: E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: error: base class       'sf::NonCopyable' has private copy constructor class SFML_SYSTEM_API Lock : NonCopyable                       ^ E:/Programming/SFML-2.2/include\SFML/System/NonCopyable.hpp:67:5: note:       declared private here     NonCopyable(const NonCopyable&);     ^ E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: note: implicit copy       constructor for 'sf::Lock' first required here class SFML_SYSTEM_API Lock : NonCopyable                       ^ E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: error: 'operator='       is a private member of 'sf::NonCopyable' class SFML_SYSTEM_API Lock : NonCopyable                       ^ E:/Programming/SFML-2.2/include\SFML/System/NonCopyable.hpp:79:18: note:       declared private here     NonCopyable& operator =(const NonCopyable&);                  ^ In file included from E:\Programming\SFML-2.2\src\SFML\System\Lock.cpp:28: E:/Programming/SFML-2.2/include\SFML/System/Lock.hpp:43:23: error: cannot define         the implicit copy assignment operator for 'sf::Lock', because non-static       reference member 'm_mutex' can't use copy assignment operator class SFML_SYSTEM_API Lock : NonCopyable                       ^
  11. Image scaling in SDL c++

    If you are using SDL2, just use a bigger rectangle for dstrect. The texture will stretch to fit the dstrect.   https://wiki.libsdl.org/SDL_RenderCopy
  12. Ok, I figured out from the right panel that the grid is created by xoring the bit string with itself, at different offsets. But I still don't get how the grid is used in the algorithm, on the left panel. Can you explain more in words?   Also, why use the first half to predict the second half? Say my bitstring has 32 bits, so the algo would use the first half (bits 0-15) to predict the second half (bits 16-31). There are 2^16 different bitstrings that can be the second half. That mean the prediction only has the probability of 1/2^16 of being correct. Not good.
  13.   Your question kind of answers your question. Make separate states for "initiating the jump" and "jumping" (I like to call it "falling"). if(spacePressed && (state != ActionState.JUMPING)) { state = ActionState.JUMP; } else if(state == ActionState.JUMP) // .... and then in the next frame { state = ActionState.JUMPING; }
  14. That sounds like a job for an array-like data structure. So I think a vector is suitable for this. When you remove the item, you mark that item's slot as unused.
  15. Whatever you do, you are probably reinventing the wheel. I don't think there's anything wrong with it though. If you have a problem and you come up with a system to solve it, good for you, and you learned something, wheel or not.