• Content count

  • Joined

  • Last visited

Community Reputation

8084 Excellent

About phil_t

  • Rank
    1st Place Winner - The Week of Awesome 2014

Personal Information

  1. how many there are types of sprites?

    sounds like a homework question
  2. A linked list is the wrong data structure to use here (a linked list is rarely the right data structure to use these days). And making Transform the holder of the linked list makes even less sense. Also, having list management functions like clear, remove, push_back on the nodes itself doesn't really make sense. Also, C++ already has a double linked list in the standard library (std::list), anyway. You don't need to implement your own.   But again, it's the wrong data structure to use. You're mainly concerned with adding/retrieving components by type id, right?. So an unordered_map seems to be the obvious choice. If you need to support multiple components of the same type on a game object, then use unordered_multimap.   Your storage can just be: std::unordered_map<std::type_index, std::unique_ptr<Component>> components; You Get/Add/Remove on game object can then be something like: template<typename _T> _T &GetComponent() { const std::type_info& r2 = typeid(_T); auto result = components.find(std::type_index(r2)); if (result != components.end()) { return static_cast<_T&>(*(result->second)); } throw std::exception("No component of this type exists"); } template<typename _T> void AddComponent(std::unique_ptr<_T> pComponent) { std::unique_ptr<Component> pTemp(pComponent.release()); const std::type_info& r2 = typeid(_T); components[std::type_index(r2)] = std::move(pTemp); } template<typename _T> void RemoveComponent() { const std::type_info& r2 = typeid(_T); auto it = components.find(std::type_index(r2)); if (it != components.end()) { components.erase(it); } } If you need "multiple types of the same component" support, then use a unordered_multimap, and change the above functions accordingly to support returning all of a certain type, etc...
  3. Cascade Quest

    In case anyone's interested on what goes into making a retro adventure game,  I've started a blog to chronicle some of the behind-the-scenes of Cascade Quest:
  4. Deleting an object by pointer

    I would still use std::vector<std::unique_ptr>> for m_sprites -- and start adopting this pattern for other containers which "own" the objects whose pointers they contain. Learn what the various C++ smart pointers do, and start thinking about object ownership and lifetime to decide which to use.
  5. ECS and saving/loading

    In the ECS system I built, each component type knows how to say if its equal to another of the same type. So when serializing an entity, I compare it to its original entity template (each entity stores its template id, so I can look this up. The template id is just a hash of the template name). For any components that are the same, I don't need to serialize anything. Then for any components which are different, I serialize that whole component (the component itself participates in this, so it might compress its data too). And of course I also have to take into account deleted/added components that weren't in the entity template.
  6. Use a tool that can view DDS textures, like DDSView:   Your pixel shader looks like it supports an alpha channel in the Diffuse color property of your material. What are you passing for that value?
  7. Quicker Algorithm

    What techniques did you use to make it faster?
  8. How do you deal with the case when a system requires more than one component to do its job?
  9. Sorry to ask the obvious, but what does the alpha channel of your wave texture look like? What does the pixel shader used for the waves output in the alpha channel?
  10. Unity I want to try Unity

            You're falling into a trap of "I want to do A, and the way I already know how to do A is by doing B. Therefore I need to do B". You can definitely do what you want in Unity (or Unreal). You'll have to work within different confines compared to writing it from scratch. But it will probably be a lot less work in the end.
  11. I don't see any SQL error messages, but several warnings in my browser's console. And the page keeps spinning until it fails to load index.php (e.g. on this page, )
  12. Love those flesh tones.
  13.   I mean, you already gave yourself the answer (use a profiler). Profile your game with a profiler and see in which functions the greatest percentage of time is spent. Analyzing the results of a profiler takes some practice, but there should be lots of good information online. There's no point in switching to a different ogg player until you know that's the issue.
  14.     Just have one component: MotionComponent, that specifies the entity's velocity. Why would you separate horizontal and vertical? Then maybe have some PlayerController component that is responsible for knowing when the player is jumping or running, and poking the Motion and Animation components so that the correct motion and animations are applied.
  15. Profile it and see.  I've seen significant improvements by reducing vertex size before.