Roland

Members
  • Content count

    2,890
  • Joined

  • Last visited

  • Days Won

    33

Roland last won the day on March 5

Roland had the most liked content!

Community Reputation

473 Excellent

About Roland

  • Rank
    Elder
  • Birthday 12/09/1953

Profile Information

  • Gender
    Male
  • Location
    Sweden
  • Interests
    Game Development
    Home Music Studio
    Art

Recent Profile Visitors

15,151 profile views
  • Josh

  1. In your Main.lua change context:Sync(true) to context:Sync(false)
  2. Thanks for the update and I just say GO GO GO
  3. Looks great and finally a descent code presentation
  4. Lucky you to see such a beautiful face now and then 😀. Anyway I hope this finally means that our code indentions will be treated with respect and dignity
  5. TAB seems to be 8, think 4 would be better
  6. The reason why remove is slow is that all non-removed item are shifted towards the front of the list while the container keeps it's size. After the operation remove returns an iterator past the last non removed item. Removed items are actually not removed​ but just marked as removed. The idea is to bring down the amount of memory allocations and get a continuous vector. You can also use remove to remove all items of a certain value from the vector Here's some notes on iteration on a vector http://fastcpp.blogspot.se/2011/03/fast-iteration-over-stl-vector-elements.html?m=1 There are quite a few types of containers, each one suited for different situations and with their drawbacks in other situations. There is no "the fastest" I'm afraid.
  7. Hard to say without seeing how Link, LinkedList and LinkNode looks like.
  8. Error in C++ - ElseIf int n = 2; if (n == 1) { Print("n equals 1"); } elseif(n == 2) { Print("n equals 2"); } elseif(n == 3) { Print("n equals 3"); } should be int n = 2; if (n == 1) { Print("n equals 1"); } else if(n == 2) { Print("n equals 2"); } else if(n == 3) { Print("n equals 3"); }
  9. Yes using a reference is of course more efficient
  10. Unfortunately I think it's a Microsoft thing, maybe some Linux user can correct me if I'm wrong on that one.
  11. template <typename T> class Link { public: Link(); ~Link(); Link* next; Link* prev; Link* list; T value; }; int main() { Link<int> link1; link1.value = 10; Link<std::string> link2; link2.value = "Hello World"; return 0; }
  12. Well great then If it works it does. So problem solved
  13. Just some free thoughts on this If you are after most efficiency use either std::vector or simple arrays. Using std::list or std::map is not at all suited for games as iterating over them is quite slow compared to vector If possible store the objects and not pointers to them in your array in order to get contiguous memory. Iterating over any data in non-contiguous memory imposes a lot of cache misses in general and removes the ability for the compiler and CPU to do effective cache prefetching. This alone can kill performance When removing from your vector use the 'swap/pop' method. This way you keep your array contiguous std::swap(entitys[index], entitys()); entitys.pop_back(); This of course assumes you know the index of your object. This can be known this way myArray.push_back(object); object.index = myArray.size()-1 then you removes it with std::swap(myArray[object.index],myArray.back()); myArray.pop_back();
  14. Unfortunately I have no idea how the remove work behind the scene.
  15. Node need to have iterators dangling around world->entities.push_front(this); // or world->entities.push_back(this); //... //.. std::remove(world->entities.begin(), world->entities.end(), this);