davidwadsworth / OpenGL-RPG-Tutorial

GNU General Public License v3.0
3 stars 0 forks source link

Hey David #2

Open LedLoaf opened 2 years ago

LedLoaf commented 2 years ago

Did you abandon your series or does it still cover everything in here? I'd love to see you implement it all up to this point if so. The reason I ask, is I'm slightly pass the components introduction and I see there has been some changes lately.

davidwadsworth commented 2 years ago

Yes! There is more coming I swear. I kind of screwed myself over with a huge workload that became the initial delay for the project, however that has cleared up and has been clear for a few months now. With regards to the possible reboot, I've decided to go in a slightly different direction. Combining the series with a past project of mine. The current videos on the channel will likely become private and this new series will be uploaded to YouTube either later in March or early July, 2022, likely with a different name, more edits, and a camera. I'm glad to see people enjoying the videos, they are a joy to make, hoping that you can forgive the hiatus and continue to support my future projects.

David

LedLoaf commented 2 years ago

Absolutely man. I just wanted to clarify you didn't leave your channel because it's one of the better ones on there. One thing I would LOVE for you to explain is adding the quad tree and pathfinding JPS/A*/etc as components.

Wish you success and I'm just about at the end of your series in about 4 days. So please keep them coming! Also, just wanted to say you should check out Udemy and upload there and make some side cash!

davidwadsworth commented 2 years ago

Quad Trees are already implemented, and should be explained in the 18th-19th episode or so. As for pathfinding I'll try and think of a way to fit it into this project, but I can't promise anything, lol.

LedLoaf commented 2 years ago

Oh okay! So you do cover it. I was looking at the labels and it looked like you never got around to collision. It must be coming up next! Thanks David, looking forward to new content.

LedLoaf commented 2 years ago

While I have you here, can I ask you a question? Why did you use a SplayTree and where did you learn about using that for an ECS? I've done loads of research on component systems and I have yet to ever hear or see a SplayTree mentioned.

From what I gather, it's good because it takes the last used component and moves it to the top. Was this your own idea or did you come across this somewhere (school, articles, ect.)?

Honestly, it's a pretty cool system. It feels just like traditional component patterns, but slightly different and I'm not sure exactly what it is that gives that impression. haha

davidwadsworth commented 2 years ago

I wanted the EC to both be flexible as a map and an array since those seemed to be the most common uses. I doubt SplayTrees are the fastest most reliable solution for this, but it is pretty light weight and super cool. I also already had some code lying around from college so it was an easy implementation. Collision is implemented here and here. A little extra spice is added later on in the latest release for even smoother collision resolutions.

LedLoaf commented 2 years ago

Had one more question if you don't mind. Feel free to answer ONLY when you get some free time.

void execute() override
        {
                       // Copy constructor was deleted so it had to be done like this
            Component::Dest destination;

            // update render dest by camera and local transforms
            destination.x = m_transform.x - m_camTransform.x;
            destination.y = m_transform.y - m_camTransform.y;
            destination.w = m_transform.w * m_transform.scale;
            destination.h = m_transform.h * m_transform.scale;

            m_renderer.draw(m_src, destination, m_material);
        }

So I was getting weird behavior. If I don't do it like this it shows the texture wrong and acts weird. It acts as if I'm scrolling over a spritesheet and I see the other sprites. Essentially, it's taking it as a reference and changing it. I originally had not referenced on accident from CameraDraw system and thus it was actually working with assigning destination to what you labeled dest_ . But I ran into errors with all the copy constructors deleted in the base component. So instead of just removing the deleted constructors (which worked) I went searching for the root of the problem. Once I added the reference it of course compiled, but not correctly.

Here is a little screen shot of it. So when you get to the top of screen, it starts to scroll the spritesheet. https://ibb.co/JHfxpYF

haha. Any ideas? One thing I'm struggling with is (besides your naming convention 😅) is how the file are laid out. It seems odd to make a update system and a render system. And then a animation update and an animation render ect. Is there a better way to kind of combine them in one? It just seems like it would get bloated when you are adding more and more, especially of basic tasks at times?

What I have done to make it easier for me this far, is for example:

Folder of Components: BaseComponent SystemComponent RenderComponent Ect.

Folder of Systems: AnimationSystem I just added both the Animation Move and Animation classes. CameraSystem MoveSystem RenderSystem etc.

Lastly, I believe you said you plan to private this series. What's a bit tricky right now is your source code is different from your video code. Especially the namespace names. So I catch myself changing back and forth not quite understanding if it's temporary to show off or to keep because it's needed. For example, the array classes that were made for something, but later removed. A few examples like that.

Anyways, apologies, this got longer than I expected for a "quick question" haha Take care and keep up the excellent work.

EDIT: Forgot to add one last thing. For the entity memory leak check, I'm still getting 1 memory leak. My question is how come we use auto tiles = new Entity(); but you can't actually delete it? Something is telling me that's the entity that isn't being removed. I should be able to count the "new" on the main.cpp and delete them, no?

davidwadsworth commented 2 years ago

Yeah... The deleted copy and = operator were kind of a pain to work around for me as well. The only reason they are there is to make reference counting work correctly (you copy over Component::Src to a variable then that copied variable gets deleted it decrements without incrementing the reference counter, this is how I solved it for your code example ).

To be honest your code looks fine, it seems like something might be wrong with the src values if anything. (You might be incrementing the src x and y values by 32 instead of 64). If you want to look at the code directly correlated with the tutorial go to the releases and download episode correlating to whatever tutorial number you are on. It sounds like you are working on animations?

The naming distinction between update and render used to have separate identities (different execute returns and parameters) beyond just being systems, but I removed that identity and don't think its coming back. You can honestly remove the names (I might later as well).

The animations, right now, might be fine together in the same class, however I think I have some plans in the future that will make their separation make more sense.

Lastly memory leak tiles = new Entity() needs to be added as a child of tileset. Like this. I might not have wrote the corresponding method in Entity at that point in the series, so maybe you'll have to put this as well.

Hope this helps.

David

LedLoaf commented 2 years ago

Hey David, I'm going to upload my version and see what you think the problem is. Yes, I'm at the GameState part and finished the animation. At this point this whole "trigger" thing is really getting confusing haha. Perhaps there is a few other words I might be able to identify it with easier?

https://github.com/LedLoaf/OpenGL-RPG

The way I was taught was to always, for example, have a Game class or Application class. Then have a virtual State class and have the Game or Application class add the state in which you would make a new file called IntroState or MenuState, GameState. Some of your methods are completely new to me or at minimum the naming, such as tigger, might be known as something else (if that makes sense).

With that said, I'm trying to get your complete example the GitHub version master to work because I think I rather work backwards instead of changing everything the way I like. That way I at least know all the code will work.

Unfortunately, your solution doesn't compile out of the box. I took some simple notes for some fixes I did

  1. Component_Trigger_Input.h and Component_Trigger.h need to include Entity.h

  2. Game.cpp curr_state defined twice

  3. *void Game::check_new_state(Entity game) needs to have c_next_state** initialized

  4. Game::nextstate is defined as a string in Game.cpp which I believe it's suppose to be GameStateEn

  5. I was getting an overriden error on the base class virtual void execute(Entity gamestate) = 0; because you have another function that is the same name but has an addition parameter Entity parent. So I added a non pure virtual execute(Entity gamestate, Entity parent) to component_trigger.h as well as the original pure virtual.

  6. Lastly, I was getting LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library which I couldn't exactly figure out what it was. I tried change the debug build to /MTd. Instead I just defaulted to my own library files

So it all worked after that, but I get an immediate error in Main.cpp at Game::curr_state->run(); because it is nullptr. I tried to set it to GameStateEn::none, overworld, and house and none of them worked. So I was wondering what is missing to get it to load the basic example?

EDIT: So I got it to run just the black screen. In Game.cpp init function I set auto& ctigs_overworld = game->add_id_ct_input("overworld"); to instead assign Game::curr_state to that all and I at least get a black screen. I'm assuming it's not setup to load a map or anything yet and a blank canvas.

LedLoaf commented 2 years ago

Hey, also added you to a project. I wanted to show you how I was always taught about ECS's. This specific course took it to the next level so I can't make it public, so I just added you to take a look. It's up to you.

davidwadsworth commented 2 years ago

I'm self taught for the most part. Let me see If I can fix the current version and get that compiling again, I was doing some experimental GameState stuff a couple days ago.

The EC design that I'm currently using is part inspired from the standard ECS design that I read about in some books and part what I took away from using the Unity UI and what I learned from previous projects. By abstracting out almost all elements of the game into Entities and Components you get a cleaner looking, easier, more printable/deleteable hierarchy. Game->GameState->GameObjects (all entities). Maybe I'll try and explain it more thoroughly in a recorded video as to why I make the design decisions I do. ECS is also incredibly hard to get right and very easy to misuse, I would need to do some rather large scale testing to see if any of the semi-original ideas I came up here actually provide any useful performance boosts. Something that probably will not come to fruition any time soon.

For the triggers they are for the most part based off the command pattern. They function to fire once and then disappear until they are needed again.

Also this mana sprite engine is crazy impressive. You write that yourself? You should honestly be doing these videos not me, lol.

LedLoaf commented 2 years ago

Hey David,

I never got an email that you responded! Totally forgot we were having a conversation. Yeah, the trigger reminded me of the command pattern and that completely clears that up.

I recently seen that you got back to your videos! Loving them man, they appear so much more professional and seems to be the right choice. Getting exposure is probably the hard part and hope it's going well. But I wanted to run the master of what you got so far, unfortunately got some issues out of the box.

component_trigger_load_box.h(41,97): error C2065: 'box_info': undeclared identifier
component_trigger_load_box.h(45,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(45,27): error C2530: 'c_box_position': references must be initialized
component_trigger_load_box.h(66,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(68,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(70,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(72,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(76,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(78,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(80,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(82,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(86,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(90,30): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(102,21): error C2065: 'entity_': undeclared identifier
component_trigger_load_box.h(102,1): error C3536: 'c_box_position': cannot be used before it is initialized
component_trigger_load_box.h(105,1): error C3536: 'cs_item': cannot be used before it is initialized
component_trigger_load_box.h(105,1): error C2664: 'void Component::Engine::add(Component::ISystem *,float)': cannot convert argument 1 from 'int' to 'Component::ISystem *
component_trigger_load_box.h(109,10): error C2065: 'box_i_': undeclared identifier
component_trigger_load_box.h(115,10): error C2065: 'box_i_': undeclared identifier
component_trigger_load_box.h(130,11): error C2065: 'box_i_': undeclared identifier
component_trigger_load_box.h(139,6): error C2065: 'box_i_': undeclared identifier

component_trigger_load_message.h(221,77): error C2039: 'set_draw_calls': is not a member of 'Component::System::Render::Empty''

So I tried to fix what I could. I believe instead of entity-> you want to use Game::Global? I'm assuming box_info is perhaps boxname? A variable called box_i is missing. I'm assuming it's some type of counter interval? I just defined it.

The error I can't solve is in component_trigger_load_message (what is Render Empty exactly?):

//e_textarea->get_component<Component::System::Render::Empty>("render")->set_draw_calls(non_space_characters);

I tried to comment it out just to see what happens. It built, but immediately I get an exception handle in json.hpp (parse_error) So I'm not sure if that's just an error on the files, or has something to do with what I tried to fix.

Thanks man, looking forward to your videos though! Looks like a LONG way until this point, but I bet it will go faster than I realize.

Thanks,

PS: And no! I didn't write most of that. I think it would be disingenuous to say that haha. Typed it all though! 🤣 But I learned it from a course and expanded upon it. So in a way? haha I wouldn't be comfortable saying "This is my creation" but at the same time I've added so much that I don't know when I could? haha Speaking of which, did you happen to try it and did it work out of the box for you? Something you might consider is a LuaScript component in the future!

davidwadsworth commented 2 years ago

Yeah I was messing around with some stuff, I'm in the process of implementing something from a previous project and was gutting scaffolding that I put in to make textbox work. I'll probably spend some time tonight and see if I can push something that works.

Also for the project I ran into some errors to get it working out the box and was too lazy to fix it. I'll have to look into in depth more, but I'll probably have to steal some of your ideas to put into my project, lol.

LedLoaf commented 2 years ago

Sounds good haha. Keep up the great work man.

LedLoaf commented 2 years ago

Yeah I was messing around with some stuff, I'm in the process of implementing something from a previous project and was gutting scaffolding that I put in to make textbox work. I'll probably spend some time tonight and see if I can push something that works.

Also for the project I ran into some errors to get it working out the box and was too lazy to fix it. I'll have to look into in depth more, but I'll probably have to steal some of your ideas to put into my project, lol.

Hey, where have you been? What happened with your tutorials!? Do you have an email I can get? I wanted to ask you somethings. Hope everything is going well.

EDIT: Also, when was the last working out of box example of the source code?

davidwadsworth commented 2 years ago

I have been interviewing for new jobs this past month. Also been playing a lot of league of legends. Those two combined has put me behind in a lot of my personal projects.

go ahead and email me at dwadsworth@wadapps.net

the last working out of the box example I have should be this (https://github.com/davidwadsworth/OpenGL-RPG-Tutorial/tree/688e10735e6ba65701f68c61712b4c6baafd908d)