Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

196 Neutral

About inanhour&

  • Rank
  1. inanhour&

    Game Structure Advice

    Thanks for the replies.     With the four functions in a game_state: Enter(), Leave(), Update(), Render(). Would you handle input in the update() function which would delegate it out to the objects in that state? Like the player or a button/ menu / piece of interface?   Also, where would you create the game objects? As public members of the game class?   As for scenes, would they only contain data about the game world like the player position, items the player has, world size etc. If there was a pre-made level made of a grid of tiles, would that all be loaded in in the same file?
  2. inanhour&

    Game Structure Advice

    Hello! This isn't a specific question, I just need some general advice on how to structure the code of a game.   Basically, I have been trying to write small games for a while and I eventually give up/start again because the code gets too tangled to keep working on it.   Right now I have written a sort of 'base game' that doesn't have anything game-like in it right now, mainly just the structure I would use to write a game. To me it seems like it could work, but am worried it is going to trip me up later on because I have no idea if what I am doing, if it is right or wrong, or if it resembles how actual games are structured.   So I am just looking for a pointer in the right direction before I do a game, so I know what I am doing is generally the right idea and I don't waste time making a massive mess.   Base game   There is quite a lot of code there but, like I said, I just need general guidance on the structure rather than the specific details, which are probably shit as well but oh well.   Thanks a lot!
  3. Oh my god I am an idiot.
  4. Thanks for your quick response. When I put #include "object.h" in component.cpp i get a linker error: Undefined symbols for architecture x86_64: "object::getSomething()", referenced from: component::accessThis(object&) in component.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  5. Hello. Thanks in advance for reading. In this pattern http://gameprogrammingpatterns.com/component.html   with the example:   Bjørn contains an instance of inputComponent and calls its method like input_.update(this*); this method then accesses members of bjørn, like bjorn.velocity -= WALK_ACCELERATION;   I didn’t understand how this could work, each object accessing each others members/methods  without causing a dependancy loop. So I made a little test program, but I can’t get it to work. I get the error 'member access into incomplete type 'object''.Am I missing something? Or not understanding the pattern?   My basic test:   object.h: #include "component.h"   class object{ private:     component _component; public:     const char* getSomething();     void doSomething(); }; object.cpp: #include "object.h" void object::doSomething(){ _component.accessThis(*this); } const char* getSomething(){ return "something"; } component.h: #include <iostream> class object; class component{ public: void accessThis(object& obj); }; component.cpp: #include "component.h" void component::accessThis(object& obj){ std::cout<< "got" << obj.getSomething() << ".\n"; }
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!