Input Polling | Game Engine series

  Рет қаралды 53,724

The Cherno

The Cherno

Күн бұрын

Пікірлер: 96
@TheCherno
@TheCherno 5 жыл бұрын
Thanks for watching guys, hope you enjoyed the video! Code for this video will be up on GitHub in a couple of days, give it a try yourself in the meantime! Next episode is already available for Patrons at www.patreon.com/posts/24599249 ❤️
@thommybaez5286
@thommybaez5286 5 жыл бұрын
TheChernoProject can you make a new java game tutorial but like that also talking about items and how to add an inventory and also a better collision detection (maybe aabb collision detection)
@thommybaez5286
@thommybaez5286 5 жыл бұрын
Thx
@hannesblack6949
@hannesblack6949 5 жыл бұрын
@TheChernoProject. I forked the repo and cloned it, but the external dependencies are missing. Do i need to download them seperately?
@carlosgarciavigoa7937
@carlosgarciavigoa7937 5 жыл бұрын
@@hannesblack6949 Just-> git clone in the same folder is easy!
@magictrickdev
@magictrickdev 4 жыл бұрын
13:00 For anyone curious: The final keyword can be specified to the compiler that the virtual method you're overriding can't be overwritten in derivative classes. You call also specify it on the class level as well, meaning that the class can no longer be derived from. Useful if you're making a bottom level implementation that you know you won't be changing. This was added in C++11.
@m96fa40
@m96fa40 7 ай бұрын
I love people with valuable information like you, thanks a lot!
@Corgamos
@Corgamos 5 жыл бұрын
This was one of the best episodes of the series, really well explained, not super fast, live coding with some breaks for explaination. Cherno, well done! :)
@theo-dr2dz
@theo-dr2dz Жыл бұрын
The polymorphism is not necessary here (neither in the window class). The platform will not be decided at runtime, it's known at compile time. So no need at all for runtime polymorphism. What he could do (and would be better) is to make an implementation class for every supported platform and include the correct one through the preprocessor. That has zero overhead (virtual functions do have overhead) and the code is simpler.
@thehambone1454
@thehambone1454 5 жыл бұрын
So glad that I am not the only one who is interested in writing custom engines :)
@arcangel964
@arcangel964 3 жыл бұрын
Polling for yr own sanity sounds wonderfully insane. Hehe
@懋张
@懋张 4 жыл бұрын
Thank you Cherno! Your series helps me out!
@davidledger5941
@davidledger5941 5 жыл бұрын
Great video as always. But, what about: enum class MouseButton : int { Left, Right, Middle };
@SkillTrailMalefiahs
@SkillTrailMalefiahs 5 жыл бұрын
need explicit MouseButton::Left // sucess Left // wrong
@davidledger5941
@davidledger5941 5 жыл бұрын
@@SkillTrailMalefiahs Yeah, I like the context, it makes code more readable as you can usually understand enum class function arguments without reading the function signiture, docs or implementation.
@TheFluffyOtter
@TheFluffyOtter 5 жыл бұрын
Such a sad face on the thumbnail 😂 great tutorial though as always
@CBayonaP
@CBayonaP 2 жыл бұрын
Actually, at 22:00, to access values of a pair you can simply do pair.first or pair.second depending on which element you want to access
@123akash121
@123akash121 Жыл бұрын
believe me dude he has 10x more C++/Programming knowledge than you, he knows that you can do that, he doesnt like it from a code style point of view because it litters the code. The man has built a fully functioning, feature packed game engine ALL ON HIS OWN, you dont think he knows that? I'm not saying he is the be all end all authority when it comes to anything related to programming but you can assume a seasoned programmar like him knows trivial things like that
@dylanclarke9497
@dylanclarke9497 11 ай бұрын
@@123akash121 Bit of a weirdly defensive attitude to a comment with a helpful tip; doesn't need to be something Cherno doesn't already know for it to be helpful to others. I used discards in place of the variable that wasn't returned from the pair i.e `auto[_, x] = ...` which is an even cleaner way of writing it imo but it wasn't mentioned in this video. Not really an issue though because like you said yourself these are trivial things and you can't expect someone building a game engine by themselves to be able to address or do every trivial thing right if they're busy working on a fully featured engine. You took a really weird view on this guy sharing some knowledge as if the great Cherno himself was offended that his knowledge of std::pair was questioned (yet he's actively encourages these types of discussions from what I've seen). If you don't find value in a comment that's cool, but this is a series for beginners making their own game engine, so tips like what this guy originally posted will be of help to someone.
@SPL1NTER_SE
@SPL1NTER_SE 7 ай бұрын
@@123akash121 Were you on your period while writing this?
@retroryuu7254
@retroryuu7254 5 жыл бұрын
I hope Senpai updates the Repository! x3
@majedhk5460
@majedhk5460 5 жыл бұрын
I can’t wait ,to see how your game engine will look like ! 🤔😴
@nullbeyondo
@nullbeyondo 3 жыл бұрын
I'm from the future; It looks awesome!
@BlindDemon24
@BlindDemon24 2 жыл бұрын
What is the reason to have public: inline static bool IsKeyPressed(int keycode) { return s_Instance->IsKeyPressedImpl(keycode); } and protected: virtual bool IsKeyPressedImpl(int keycode) = 0; when it could have been only: public: virtual bool IsKeyPressedImpl(int keycode) = 0; ?
@cyqry
@cyqry 2 жыл бұрын
Judging by the other comments, the impl versions (short for "implementation) are meant to be used for specific WIndow types, so for example GLFW or HWINDOW. So you would call the IsKeyPressed function which would then call the appropriate implementation that has more platform specific code.
@pradhivrddhi-research7489
@pradhivrddhi-research7489 Жыл бұрын
Hello Cherno, thanks for this series, I appreciate it. I wanted to ask for your reason as to why you are using the name GetMousePosition instead of just GetCursorPos like GLFW?
@yessicasd9402
@yessicasd9402 3 жыл бұрын
I don't get from where is called the Input* Input::s_Instace = new WindowsInput(); if the only file we are including in the Application.cpp is the Input.h
@universalkey5451
@universalkey5451 5 жыл бұрын
Why do we have to make a separate class for input while we can just use the event system to poll input?
@dawid4450
@dawid4450 3 жыл бұрын
I have a question, at 22:50 why do we need to declare type (Input*) again? and if s_Instance is a private member of an Input class why do we have access to this?
@PradhiVrddhi-Research
@PradhiVrddhi-Research Жыл бұрын
Hello Cherno, Thanks for these videos, I appreciate them quite a lot. I believe that if I started with some other started point I would have given up already. I have a question to ask about this video. I could not help but asking, why you are using the name GetMousePosition instead of GetCursorPos like GLFW?
@dylanclarke9497
@dylanclarke9497 11 ай бұрын
GetCursorPos is an alright name but not as descriptive as GetMousePosition imo, both mean the same though so it just boils down to personal preference :).
@PradhiVrddhi-Research
@PradhiVrddhi-Research 10 ай бұрын
@@dylanclarke9497 Thanks, I guess GetCursorPos might also be more specific to GLFW and the attempt here is to make it more general.
@0ichigan06
@0ichigan06 5 жыл бұрын
So, this whole static - instance thing in input is just a workaround, because it is not possible to override static functions?
@Aluminum0013
@Aluminum0013 4 жыл бұрын
No, you can override static functions. This is called a singleton, and is used to prevent holding information in a static only class.
@yuno3364
@yuno3364 3 жыл бұрын
should WindowsInput be a final?
@armaanc.684
@armaanc.684 Жыл бұрын
For anyone getting an error where the s_Instance conversion from Input* to WindowsInput* is inaccessible, make sure to put public before Input in WindowsInput.h
@Corgamos
@Corgamos 5 жыл бұрын
Ok, can somebody once again explain to me, why Cherno created two versions of all the methodes (normal ones and ones with Impl at the end)?
@beyondhelp
@beyondhelp 4 жыл бұрын
Same
@42mix22
@42mix22 4 жыл бұрын
The methods with Impl at the end are supposed to be overriden and implemented for each platform
@Arteko77
@Arteko77 4 жыл бұрын
How did you do that multi select and remove thing in 17:50 ?
@luizandre12345
@luizandre12345 4 жыл бұрын
Shift + Alt + Down (or Up)
@eddieh7962
@eddieh7962 5 жыл бұрын
ok i can understand the programming but how tf does he type so efficiently
@MicheleTurchiarelli
@MicheleTurchiarelli 5 жыл бұрын
Prior preparation
@amicloud_yt
@amicloud_yt 3 жыл бұрын
@@MicheleTurchiarelli and lots of practice.
@teckleedeyi
@teckleedeyi 3 жыл бұрын
Its called touch typing
@haos4574
@haos4574 4 жыл бұрын
instead of returning a void pointer, maybe we can typedef a PlatformWindow, like #if GLFW typedef PlatformWindow GlfwWindow* #else typedef PlatformWindow void*
@moonding3979
@moonding3979 5 жыл бұрын
This is my earliest comment for your video hihihi
@daniilblagiy8741
@daniilblagiy8741 5 жыл бұрын
Please push the code on github.
@watchcrap1
@watchcrap1 Жыл бұрын
so confused how he could just use "auto [x, y] = Input::GetMousePosition(); " in the Run loop, how is the Input class aware of the functions we implemented on the WindowsInput? I get we overrode the Implementations on WindowInput, but I would have expected to have to use auto [x, y] = WindowsInput::GetMousePosition();
@Brad_Script
@Brad_Script 9 ай бұрын
in WindowsInput.cpp @23:28 he assigns a new WindowsInput object to Input's static s_Instance variable : Input *input::s_Instance = new WindowsInput();
@miloz1950
@miloz1950 4 жыл бұрын
I really think I did everything correct, but suddenly at the end when I'm launching the entire project and hovering mouse over the window it throws an error: Debug Assertion Failed! from the sandbox.exe from file: "minkernel/crts/ucrt/src/appcrt/heap/debug_heap.cpp" Line 996. Expression: __acrt_first_block == header. It doesn't occur when the "PushLayer(new ExampleLayer());" is commented. So after some time i noticed that the error started occuring after changing all buildoptions in premake file to runtime and staticruntime. Somebody maybe knows how to fix it? I can provide more information if it will be necessary.
@miloz1950
@miloz1950 4 жыл бұрын
So it works fine with "buildoptions "/MDd"", but with "runtime "Debug"" it throws an error (in Debug profile).
@神经大
@神经大 3 жыл бұрын
I have the same problem! May I ask you have fixed it?
@miloz1950
@miloz1950 3 жыл бұрын
I'm sorry but I don't remember what I've done to fix it.
@berrymix3282
@berrymix3282 3 жыл бұрын
Uhm, idk if you're still have this problem, but solution is the following: make shure you've removed staticruntime line in every other section but "project" (and it has to be toggled "off") in premake file.
@cyqry
@cyqry 2 жыл бұрын
@@miloz1950 Hazel itself is a library (dll file) while Sandbox is an application (exe file). /MD and /MDd are the library build options while /MT and MTd are the multi-threaded application build options. Cherno did a video in the playlist already discussing this, I believe its in the Github video. Not much code going on in it, its a talking video so I think a lot of people may have skipped over it. I would need to check again to be certain but there are TWO lines needed to properly set it. One sets the debug/release state (that lowercase d after the MD/MT) while the other determines if its a library or executable.
@foureverfour4
@foureverfour4 4 жыл бұрын
do you ever explain how to change screen coordinates to world coordinates for the cursor position?
@greenb1ade
@greenb1ade 5 жыл бұрын
How and where did you learn how to code?
@k1ng121
@k1ng121 5 жыл бұрын
I learned it all from watching yt videos and google. :D
@lewisnorth1188
@lewisnorth1188 5 жыл бұрын
He went to university and did a lot of research and practice there I think
@stephen9849
@stephen9849 4 жыл бұрын
From DanisTutorials
@yousafe0
@yousafe0 5 жыл бұрын
you never called delete on s_Instance
@TheCherno
@TheCherno 5 жыл бұрын
Why would we need to? There's one instance of it across the entire process, and it exists for the lifetime of the application.
@gideonunger7284
@gideonunger7284 5 жыл бұрын
@@TheCherno Sure but that relies on the os to reclaim the process memory. I dont think that then ever calls the destructor of input instance. that might not cause issues now but a poblem could only be one refactor away. If it was a smart pointer it would be properly cleaned up on shutdown
@davidste60
@davidste60 5 жыл бұрын
@@gideonunger7284 - What kind of problem?
@gideonunger7284
@gideonunger7284 5 жыл бұрын
@@davidste60 Depends on the destructor.
@davidste60
@davidste60 5 жыл бұрын
@@gideonunger7284 - How can it if the destructor is not called?
@PflanzenChirurg
@PflanzenChirurg 5 жыл бұрын
Still here!
@gideonunger7284
@gideonunger7284 5 жыл бұрын
12:36 then make it final? thats what its for
@gideonunger7284
@gideonunger7284 5 жыл бұрын
@@marklinton4567 final is pretty basic tho right? if you are already learning about virtual and override final should be included
@gideonunger7284
@gideonunger7284 5 жыл бұрын
@@marklinton4567 ind thats pretty much exactly what final is for. it doesnt make sense to inherit from windows input
@jamesmnguyen
@jamesmnguyen 5 жыл бұрын
I use final override anywhere applicable.
@thomasknapp7807
@thomasknapp7807 5 жыл бұрын
I stated this series a couple of months late. I am current at video 9, "Event System", and am having trouble getting the code for that episode, along with spdlog, from the GitHub repository using git. git keeps complaining with fairly terse statements. Might anyone suggest a source for learning how to use GitHub, especially for cloning or downloading older versions of the code? Thanks.
@voxelrifts
@voxelrifts 4 жыл бұрын
Check the older commits. Sry for Late reply. :)
@simonkgothatso7236
@simonkgothatso7236 5 жыл бұрын
Hello am new to the channel and i just feel like The compiler that you are using is too complicated for my liking. I find CodeBlocks easy and to the point. Nonetheless, i love what you are doing hands down. Keep on sharing @TheChernoProject👍🏻👍🏻👍🏻
@rikseth9606
@rikseth9606 5 жыл бұрын
Why don't you use Directx?
@nikoszervo
@nikoszervo 5 жыл бұрын
Because people who watch these series and use Linux would not be able to follow along.
@bies_moron4404
@bies_moron4404 5 жыл бұрын
1. Windows only 2. Harder than OpenGL
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 214 М.
BLENDING | Game Engine series
19:21
The Cherno
Рет қаралды 23 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 202 МЛН
Haunted House 😰😨 LeoNata family #shorts
00:37
LeoNata Family
Рет қаралды 16 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Window Events | Game Engine series
23:37
The Cherno
Рет қаралды 76 М.
Moving to Sandbox | Game Engine series
22:16
The Cherno
Рет қаралды 31 М.
Event System | Game Engine series
35:40
The Cherno
Рет қаралды 165 М.
Rendering Architecture | Game Engine series
27:53
The Cherno
Рет қаралды 66 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 292 М.
CAMERAS and How They Work | Game Engine series
38:54
The Cherno
Рет қаралды 41 М.
Rendering Context | Game Engine series
27:03
The Cherno
Рет қаралды 49 М.
Layers | Game Engine series
22:59
The Cherno
Рет қаралды 77 М.
Refs, Scopes and Smart Pointers | Game Engine series
24:55
The Cherno
Рет қаралды 36 М.
Creating an Orthographic Camera | Game Engine series
38:28
The Cherno
Рет қаралды 47 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 202 МЛН