MarcusAseth

Members
  • Content count

    426
  • Joined

  • Last visited

  • Days Won

    3

MarcusAseth last won the day on July 31

MarcusAseth had the most liked content!

Community Reputation

76 Neutral

3 Followers

About MarcusAseth

  • Rank
    Member

Personal Information

  1. Again Inclusion question

    @jpetrie my apologize, sometimes I just reply to the notify message and I completely forgot what a topic was about x_x I'll try harder. But no further OT from me, since your reply above totally clarified how to use that function and it makes perfect sense, so thanks!
  2. October 2017 GameDev Challenge: Arcade Battle Arena!

    Hi guys, I have my texture loading and entity mostly done, here in the image below my tiles entities neatly packed. Now the next step should be to load a level, I guess. I am not yet sure how to handle that, never done. Should Level be a class object that I call with the path on disk of the level data? What is that data? a .txt? How do I parse the data to make it create the appropiate entity type inside the game? Can anyone link some good tutorials (possible C++) about the correct way to do this? I don't think I will proceed until I have it figure it out, I would only end up making a mess I'm sure. Help!
  3. Again Inclusion question

    Because that imply Tile is responsible for freeying up memory, and if that is my pattern, then I have to remember to destroy my textures in every Entity type destructor I create in my game, therefore is the same as using new and deletes because I am bound to forget to destroy a texture, sooner or later. My setup is that App loads a texture upon request into a map<string,SDL_Texture*> in case the texture wasn't already loaded, so each class constructor actually prompt a texture load the first time a type of class is called if the texture wasn't already loaded (and I can also manually prompt a series of texture load at the beggining of a level if I know I will need them), but App destructor is responsible to free all in a single for range loop. SDL_Texture* App::GetTexture(std::string texturePath) { auto Texture = Textures.find(texturePath); if (Texture != Textures.end()) { return Texture->second; } else { LoadTexture(texturePath); return Textures[texturePath]; } } App::~App() { for (auto& T : Textures) { SDL_DestroyTexture(T.second); } if (Window) { SDL_DestroyWindow(Window); } if (Renderer) { SDL_DestroyRenderer(Renderer); } } Clean, compact and not error prone, imo Edit: my bad, seems I am already doing what you're saying @Lactose and I had misunderstood But still, maybe I want to load a bunch of texture upfront, so I might need to have those paths somewhere else too.
  4. Again Inclusion question

    Exactly 1. Hold ALT pressed inside of visual studio, do a rectangle box selection, write the new directory name. And this is why I have them all lined up inside a single file. The way you guy suggest, request go inside of each and every file 1 by 1 and fix it.
  5. Again Inclusion question

    Looks still pretty bad to me...All I am doing right now to load an image is this: //Load Textures LoadTexture(Paths::Images::CHECKER); and to get it from another file, Checker::Checker(float x, float y): Tile(x,y,Paths::Images::CHECKER) { } The fact I write it in 2 different places increase chances for mistakes if I where to manually write it. This way, I simply cannot make a mistake, and if I mispell it inside the Paths.h, then that error get caught by the LoadTexture.
  6. Again Inclusion question

    @Shaarigan if I understand correctly what you're saying, that's seems messy to me because then I have to compose in place the name of the thing I want to load like string(MyGame::Constants::Files()) + "Graphics/Checker.png" and I have to remember the name of stuff all over the place, much easier to just call Paths::Images::CHECKER and let it do the right thing.
  7. Again Inclusion question

    @jpetrie sorry, still not clear ^_^' I guess I am missing the bigger structure here, where everything is placed in comparison to everything else, like in which header is this function compared to who calls it, where are the things result is builted with taken from and how you reach them and so on... SomeThing& getSomeThing() { static SomeThing result(value, of, some, thing); return result; } so this above is the function. So from what I am understanding, in practice would look something like this, and it will live in the Global.h: Global.h #include "App.h" #include "SDL2\SDL.h" struct AppInfo { App* App; GameMode* Game; SDL_Window* Window; SDL_Renderer* Renderer; Uint32 Width, Height; }; AppInfo& GetAppInfo() { static AppInfo result{MyApp.GetApp(), MyApp.GetGame(), MyApp.GetWindow(), MyApp.GetRenderer(), MyApp.GetWinWidth(), MyApp.GetWinHeight()}; return result; } But the problem is, when is that static initialized?! If it is when I run the program, then App wouldn't be initialized yet... is that the case? If so, then I still don't get it how to do it... Furthermore, where is this "App MyApp" global object created and initialized, I mean where is living? :\ The example is still too abstract for my brain, the problem is I can't see the entire structure pattern here... :\
  8. Again Inclusion question

    Not a big fan of that, some object are just too widely used like App for requesting textures to it and Game to allow entity to interact with other entities in the game or the global paths to be used for loading and requesting textures to App (in the code above), I wouldn't want to pass this stuff down constructors and inheritance chains just to end up storing a pointer to each one of them inside of every object or something. And this in case I have understood what you are saying correctly, for me is always hard without a concrete code example to backup an explanation. :\
  9. Again Inclusion question

    @jpetrie can you show me an example of one of this free function? I would like to understand where my global variables should end up living, at which point during executing are they initialized, how this free functions get to them and how all the other files get to this free functions ^_^'
  10. Again Inclusion question

    I've learned about extern today and suddenly it became my favourite C++ keyword I think
  11. Again Inclusion question

    @AxeGuywithanAxe I've beaten you by few seconds But thanks Also, any major differences in the way I did it above and in the way you did it? Or is a style choice?
  12. Again Inclusion question

    Ok I think I've figured it out myself, extern to the rescue Paths.h #pragma once #include <string> namespace Paths { namespace Images { extern std::string CHECKER; } namespace Fonts { extern std::string BUBBLEBATH; } } Paths.cpp #include "Paths.h" std::string Paths::Images::CHECKER = "Graphics/Checker.png"; std::string Paths::Fonts::BUBBLEBATH = "Fonts/BUBBLEBATH.ttf";
  13. Again Inclusion question

    @matt77hias that doesn't solve the problem. Anyone knows how to avoid multiples copies being created for every single variable? :\
  14. Again Inclusion question

    Hi guys, I would like to have the header below: Paths.h #pragma once #include <string> namespace Paths { namespace Images { static std::string CHECKER = "Graphics/Checker.png"; } namespace Fonts { static std::string BUBBLEBATH = "Fonts/BUBBLEBATH.ttf"; } } Included all around the place so that I can do stuff like Paths::Images::CHECKER to easily load the proper file or to request it again by passing that to a map as a key. Though this I believe create a copy of the static string for every compilation unit, am I correct? Meaning I include it in 10 cpp and get 10 copies of each string. How would I do this the proper way?
  15. October 2017 GameDev Challenge: Arcade Battle Arena!

    what is a mesh buffer?! This by the way is where I am right now: Font.cpp Button.cpp MenuState.cpp Next I think I'll jump into the playState. What's the first logic task? Maybe an Entity class and then derive a Tile class from Entity? (because tile have collision too, like other entities) Though, Should I store tiles in a separate vector<Entity*>, since they don't require updates?