Input Polling | Game Engine series

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

The Cherno

The Cherno

Күн бұрын

Пікірлер
@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! :)
@thehambone1454
@thehambone1454 5 жыл бұрын
So glad that I am not the only one who is interested in writing custom engines :)
@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.
@懋张
@懋张 4 жыл бұрын
Thank you Cherno! Your series helps me out!
@arcangel964
@arcangel964 3 жыл бұрын
Polling for yr own sanity sounds wonderfully insane. Hehe
@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.
@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 11 ай бұрын
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 10 ай бұрын
@@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?
@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?
@Arteko77
@Arteko77 4 жыл бұрын
How did you do that multi select and remove thing in 17:50 ?
@luizandre12345
@luizandre12345 4 жыл бұрын
Shift + Alt + Down (or Up)
@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?
@TheFluffyOtter
@TheFluffyOtter 5 жыл бұрын
Such a sad face on the thumbnail 😂 great tutorial though as always
@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?
@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!
@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
@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.
@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
@retroryuu7254
@retroryuu7254 5 жыл бұрын
I hope Senpai updates the Repository! x3
@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
@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
@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?
@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*
@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 10 ай бұрын
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.
@daniilblagiy8741
@daniilblagiy8741 5 жыл бұрын
Please push the code on github.
@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.
@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();
@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
@foureverfour4
@foureverfour4 4 жыл бұрын
do you ever explain how to change screen coordinates to world coordinates for the cursor position?
@moonding3979
@moonding3979 5 жыл бұрын
This is my earliest comment for your video hihihi
@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?
@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. :)
@PflanzenChirurg
@PflanzenChirurg 5 жыл бұрын
Still here!
@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
CAMERAS and How They Work | Game Engine series
38:54
The Cherno
Рет қаралды 41 М.
Event System | Game Engine series
35:40
The Cherno
Рет қаралды 164 М.
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 42 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 126 МЛН
Kohi #009: Input Part 1 (Vulkan Game Engine Series)
27:00
Travis Vroman
Рет қаралды 10 М.
C#'s Best features you might not be using
31:20
dotnet
Рет қаралды 11 М.
TEXTURES | Game Engine series
51:48
The Cherno
Рет қаралды 43 М.
Our First Triangle! | Game Engine series
28:33
The Cherno
Рет қаралды 53 М.
I Created a Game Engine Just to Optimise This
4:50
Vercidium
Рет қаралды 1,1 МЛН
Refs, Scopes and Smart Pointers | Game Engine series
24:55
The Cherno
Рет қаралды 36 М.
Object-Oriented Programming is Bad
44:35
Brian Will
Рет қаралды 2,3 МЛН
Vertex Buffer Layouts | Game Engine series
49:16
The Cherno
Рет қаралды 42 М.
Adding Event Listeners with GLFW | Coding a 2D Game Engine in Java #2
26:46