How to program a game in C++: #1 - Window and Pointers

  Рет қаралды 226,433

Dan Zaidan

Dan Zaidan

Күн бұрын

Пікірлер: 432
@Hallowfont
@Hallowfont 2 жыл бұрын
Just a heads up to anyone who has an error with window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). In the properties of the project, go to general > advanced > character set > "Use Multi-Byte Character Set". This is how I fixed this error on Visual Studio 2019.
@nomadic626
@nomadic626 2 жыл бұрын
Thanks for this 👍
@piwwol1405
@piwwol1405 2 жыл бұрын
Thank you😁
@misterkeyboard.
@misterkeyboard. 2 жыл бұрын
Thank you so much!
@calebrowell71
@calebrowell71 2 жыл бұрын
I'm not religious but you are an angel. Thank you
@DidIJustDoThat
@DidIJustDoThat 2 жыл бұрын
Thank you
@KynesisCoding
@KynesisCoding 4 жыл бұрын
It was hard, but I got through. I've never been so happy to see a blank window before
@DanZaidan
@DanZaidan 4 жыл бұрын
That's awesome!! Blank windows do have their charm... :)
@username-ur6dq
@username-ur6dq 4 жыл бұрын
just finished it also such a satisfying feeling
@stephanieezat-panah7750
@stephanieezat-panah7750 3 жыл бұрын
I am with you, Michael. A blank window never looked so good ; 0
@vanshikagarg647
@vanshikagarg647 2 жыл бұрын
can u pls help me out i found difficulties in debug process
@superexplosion12
@superexplosion12 2 ай бұрын
real
@mateo910
@mateo910 2 жыл бұрын
If you are having trouble creating the window in 2022, the LPCTSTR type for lpszClassName and for lpWindowName now need to be written as L"Game window Class" and L"My First Game!" with the L before the " "
@SeveredSoul77
@SeveredSoul77 2 жыл бұрын
Thanks for this.
@The_Snailman
@The_Snailman 2 жыл бұрын
tysm
@dominicervig
@dominicervig 2 жыл бұрын
Thanks a lot, I was trying to figure out why I was getting this kind of error message after typing exactly what he had there.
@spaidory874
@spaidory874 Жыл бұрын
thanks
@f-2619
@f-2619 Жыл бұрын
Thank you
@DanZaidan
@DanZaidan 5 жыл бұрын
DOWNLOAD the GAME and the SOURCE CODE: danzaidan.itch.io/pong-learn-programming It's also on GITHUB: github.com/DanZaidan/pong_learn_programming Let me know what you think about the way I'm doing these tutorials! :)
@arkanesugar
@arkanesugar 2 жыл бұрын
You saved me from the PAIN that is going through this without a proper guide. This is amazing, thank you from the bottom of my kidney.
@foics
@foics 4 жыл бұрын
I have been searching for this tutorial for a whole day and now I have finally found one that works
@DanZaidan
@DanZaidan 4 жыл бұрын
I hope you love it! :)
@jtcuth95
@jtcuth95 3 жыл бұрын
I'm pretty familiar with C++, and I'm going through this series just to brush up on engine development a bit. But I want to say, that locker analogy you gave for pointers is the single best one I've EVER heard, and I can't believe I haven't heard it elsewhere. Props!
@liamlluls1588
@liamlluls1588 2 жыл бұрын
Great video, two issues i had was, i need to put L in front of strings so L"my first game" and i didnt have a close button top right of window so i had to put in WS_SYSMENU on the create window line for window style "WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU"
@denilopereira234
@denilopereira234 2 жыл бұрын
Thx, that L tip just save me (I'm not sure why i had to do this, but I gonna search about it later to understand)
@majesticsprhunt3388
@majesticsprhunt3388 2 жыл бұрын
@@denilopereira234 I know this comment was helpful right?
@blakesutherland798
@blakesutherland798 Жыл бұрын
Thanks for this comment. I was trying to figure out how to generate an exit button on the window. This helped!
@M3t4lik
@M3t4lik 2 жыл бұрын
How cool is this? The last time I looked at windows coding, it was like staring into the abyss. This is excellent. Thx so much.
@atreyumclewin8282
@atreyumclewin8282 2 жыл бұрын
Recently decided to try making my own little games from scratch and found your series. I don't understand half of what's happening in this video, but I am so excited to learn! In only a half hour, I've already made my own window pop up, something I didn't think i'd be able to do until after college! Just graduated high school a little less than a year ago and have been dealing with doubts about my own coding abilities. But seeing what I can do here in such little time gives me hope, so thank you for that! Your videos are inspiring and you have created something good into the world, feel proud!
@MassHypnosis805
@MassHypnosis805 11 ай бұрын
Exactly what I needed, thank you!
@rachelveer7574
@rachelveer7574 5 жыл бұрын
This is SO exciting. Even though I knew bits of this a refresher is nice, I like knowing all the nitty gritty details instead of - let's say - Unreal/Unity holding my hand.
@StellarMirage
@StellarMirage 2 жыл бұрын
Oh, that's great, I did it with you. Last time I did it on my own I failed and almost gave up and then got this. Great way of approaching the problem. Thanks dude!!! I could create that silly blank window to hype my confidence up again :)
@M3t4lik
@M3t4lik 2 жыл бұрын
I couldn't close the window so I changed the case inside the switch(uMsg) to the following: case WM_CLOSE | WM_DESTROY: { running = false; }break; and it it now works as intended! I'm using MSVS 2022.
@vanessabyerly3752
@vanessabyerly3752 2 жыл бұрын
So I followed along... and I got frustrated because a lot of the stuff was not working like it did for you. This was the second time watching the video, so I am glad I came back. I did make sure the windows.h library was on my computer this time, a simple google search for this helped out! I had issues with the lpszClassName giving errors. So I google searched that and came up with that I had to put TEXT in front of Game Window Class, so it looked like window_class.lpszClassname = TEXT("Game Window Class"). It may be because I have VS 2022, it could be a lot of things. But I hope that might help someone else down the road. Do not get frustrated with the code guys. If it doesn't work the first time, google is your friend. You can find just about anything out there when it comes to the error codes you get with the compilers. I hope this helps!
@gamedudepc5684
@gamedudepc5684 10 ай бұрын
Your reply saved me from a half hour headache. I'm a beginner, this is my first lesson, and even googling didn't get me far as I understood nothing of the answers. You legend!
@carolinambos541
@carolinambos541 8 ай бұрын
Thank you i was so confused by the error and this comment helped me out a lot!
@alexjulius69
@alexjulius69 2 жыл бұрын
Thanks a million dude, C++ is my arch nemesis, it pounds me into a confusion pulp, but with your tutorial I finally created a freaking window! Also, seems you can't define a string variable with quotes anymore, you have to use: string_variable = L"test" I don't know why, but you have to put that L in front of your quotes to not get an error xd
@mkhadka123
@mkhadka123 2 жыл бұрын
LPCWSTR expects a multi-byte char and a string variable is just a normal single-byte char, appending just an L (I too have no idea why the heck they made it like that) converts normal string variable to multi-byte char...alternatively you could set character set to "Use Multi-Byte Character Set" in Config Properties of the main project -> that saves a lot of manual conversion effort actually :)
@gilernt
@gilernt 5 ай бұрын
wow, your pointers explanation would've been really helpful last semester when i was struggling through learning C lol; yours is definitely the best explanation i've found so far, thanks!
@alyashour7403
@alyashour7403 3 жыл бұрын
it was a little fast, but definitely was waaaay more informative than every other tutorial i could find
@suddencucumber5994
@suddencucumber5994 4 жыл бұрын
this is underrated
@noaxin
@noaxin 5 жыл бұрын
Hey Dan! I followed your tutorial step by step but no window appears when I run the program like you did @ 8:54. Task Manager shows a process for the window but the window doesn't show up (not even on the taskbar). Also, when defining window_class.lpszClassName it's giving me an error saying "a value of type const char* cannot be assigned to an entity of type LPCWSTR". Could you help me?
@DanZaidan
@DanZaidan 5 жыл бұрын
Apparently, your compiler is expecting a Unicode string (LPCWSTR). You can define one by putting an L before the string like: windows_class.lpszClassName = L"My Class Name"; Alternatively, you can make the Window Class be of type WNDCLASSA to make use it will use Ansi (the default) strings. Like this: WNDCLASSA window_class = {0}; window_class.style = CS_HREDRAW|CS_VREDRAW; window_class.lpfnWndProc = win32_window_callback; window_class.lpszClassName = "Window Class"; Let me know if it helps you! :)
@TeaDessert
@TeaDessert 5 жыл бұрын
@@DanZaidan Hi Dan. I have a problem when I used WNDCLASSA window_class = {}; RegisterClass change to RegisterClassA. The result coming out the title no same like my settings and looks like don't have UTF-8 words
@noaxin
@noaxin 5 жыл бұрын
@@DanZaidan Hello Dan! Sorry for the late response! Thank you for your helo! I'll let you know if it worked!
@daattavyaaggarwal7768
@daattavyaaggarwal7768 5 жыл бұрын
@@TeaDessert Did you find a solution? I have the exact same problem.
@TeaDessert
@TeaDessert 5 жыл бұрын
@@daattavyaaggarwal7768 Yes, I found it. You just use the same with video WNDCLASS window_class and RegisterClass. In lpszClassName just added "L" in your game title windows_class.lpszClassName = L"My Class Name";
@mkhadka123
@mkhadka123 2 жыл бұрын
what a satisfying view that white window was...after struggling all those build errors!!
@Glitch900
@Glitch900 Жыл бұрын
Why at 3:59 there is a video edit that doesn't allow the viewer to see how you got to that documentation page, I downloaded the whole pdf and searched for WINDCLASS, and it doesn't show up. This is always a kill joy on these tutorials when the person giving instructions just randomly jumps to another page without showing how they got there.
@Glitch900
@Glitch900 Жыл бұрын
I realize this video was made 3 years ago so a heads up to anyone just barely jumping in like me, there is no WNDCLASS information, you can pull up WNDCLASSA, documentation under winsuer.h, I found the latest information is from 2022 so be aware you might need to dig like I did to follow along with this video. Hope this helps.
@Glitch900
@Glitch900 Жыл бұрын
Also, like user @andrewcampbell4960 pointed out do the following to clear the error with the .lpszClassName "In properties of the project, go to advanced > character set > "Use Multi-Byte Character Set". and that will fix your problem.
@ChupoCro
@ChupoCro 3 жыл бұрын
Congratulations! This is how tutorials should be done!
@DanZaidan
@DanZaidan 3 жыл бұрын
Awesome! I'm glad you liked it. :)
@fcmedic4217
@fcmedic4217 3 жыл бұрын
bro that was the most hardcore 12 minutes of my life
@DH-cg6qx
@DH-cg6qx 9 ай бұрын
If anyone is having issues with this line ~ window_class.lpszClassName = "Game Window Class"; ~ add L before the string like this ~ window_class.lpszClassName = L"Game Window Class"; ~. I also noticed that you have to do that at least for the createWindow section as well like ~ L"My First Game!" ~.
@anforawelch
@anforawelch 7 ай бұрын
hi this worked for me but why do we have to put an L in, like what does it do in there?
@DH-cg6qx
@DH-cg6qx 7 ай бұрын
@@anforawelch marks the literal as a wide literal
@anforawelch
@anforawelch 7 ай бұрын
@@DH-cg6qx thank you😁
@carlo2984
@carlo2984 4 жыл бұрын
Thank you so much! You will probably be the guy that teaches me coding
@DanZaidan
@DanZaidan 4 жыл бұрын
That would be awesome! :D
@albertovitsch453
@albertovitsch453 3 жыл бұрын
at 05:45 mine doesn't compile... the error list flags line 11 with a value of the type ""const char*"" can't be assigned to an entity of the type ""LPCWSTR"" and "=": "const char [18]" can't be converted into "LPCWSTR" My code is exactly like yours, please help
@akabami2161
@akabami2161 3 жыл бұрын
I have the same problem. Found a comment that said to just put an L in front of it. window_class.lpszClassName = L"Game Window Class" dunno why tho...
@ladyunknown101
@ladyunknown101 3 жыл бұрын
@@akabami2161 doesnt work anymore with the 2019 version
@soneone5525
@soneone5525 4 жыл бұрын
Who had to watch it in x0.75 because his typing is too fast
@utkarshawasthi3368
@utkarshawasthi3368 3 жыл бұрын
Me bro 😂😂
@kevz3351
@kevz3351 2 жыл бұрын
I dont see any problem with that. We are supposed to UNDERSTAND the code, not just rewriting/copypasting everything that he wrote .
@Akshatparihar007
@Akshatparihar007 3 ай бұрын
following this in 2024, will keep you updated
@Akshatparihar007
@Akshatparihar007 3 ай бұрын
Just finished this video didn't understand a lot but felt good after seeing the box. Learned a lot
@mathsalmath
@mathsalmath 4 жыл бұрын
Thank you for sharing your talent, please continue. Excellent video.
@Hiyori___
@Hiyori___ 3 жыл бұрын
This is a great series. I love C++, even if I normally use JS or Python for uni projects. Your tutorial are super fast and condensed but we can take our time to study each single concept even in more detail. Am I screwed? Programming has become my new hobby.
@smg_bednqci
@smg_bednqci 11 ай бұрын
yes probably
@niektuytel9519
@niektuytel9519 4 жыл бұрын
if you get issue around 4 min ``` std::string word = "Game Window Class"; LPCTSTR lp = (LPCTSTR) word.c_str(); window_class.lpszClassName = lp; ``` will work instead
@ovdiaries
@ovdiaries 4 жыл бұрын
L"name" xd works just fine
@julianavar3836
@julianavar3836 4 жыл бұрын
@@ovdiaries it got rid of the error, but the compiler still complained, @niek's answer worked best :) If you want to put it all in one line the you can do `(LPCTSTR)std::string("Game Window Class").c_str()`, remember to `#include ` :)
@ahmedthegreat3973
@ahmedthegreat3973 3 жыл бұрын
@@julianavar3836 THANKS
@soumysahu
@soumysahu 4 ай бұрын
5:45 if your class name doesn't work: add L as a prefix window_class.lpszClassName = L"Game_Window_Class"; 9:42 again CreateWindow(window_class.lpszClassName, L"My First Game",......
@Vanessa-im6tb
@Vanessa-im6tb 2 ай бұрын
thank you!
@ninjabirdman551
@ninjabirdman551 4 жыл бұрын
I'm stuck at 9:35, to me it doesn't appear you change anything so I'm not sure what's causing it to work, because mine isn't. Any help would be appreciated.
@DanZaidan
@DanZaidan 4 жыл бұрын
At this point, the window should be created and destroyed very quickly (just flash on the screen). I used the debugger to set through each line of code (by pressing F10) to see the window before the program exists (and the window closes). A little bit layer in this video I add the input loop so that the window stays open. Try to plow forward a bit, and if the problem persists, paste some code and I'll try to help you further. ;)
@ninjabirdman551
@ninjabirdman551 4 жыл бұрын
@@DanZaidan Ok thanks I was able to get the window to stay up but now I'm unable to move it, close, or full screen it and I can't minimize it I just click on another tab to move it to the background.
@ranchbathtub1
@ranchbathtub1 3 жыл бұрын
in the line where i wrote "window_class.lpszClassName = "Game Window Class" I got the error "a value type of 'const char*' cannot be assigned to an entity of type 'LPCWSTR'" and the error "'=': cannot convert from 'const char[18]' to 'LPCWSTR'. Does anybody know what to do with this or how to fix it? Thanks.
@christianypil6929
@christianypil6929 5 ай бұрын
window_class.lpszClassName = L"Game Window Class"; use this bro
@hadiaabq7981
@hadiaabq7981 3 ай бұрын
Though surely this is the best. I appreciate your work! The best tutorial out there.
@matviyberezovskiy2372
@matviyberezovskiy2372 3 жыл бұрын
I wrote the same code as you did with L before "Game Window Class" and "My First Game". And there's still something wrong with CreateWindow. How to solve that?
@mrturretpl7532
@mrturretpl7532 2 жыл бұрын
I also have this issue, someone pls help
@danish3605
@danish3605 3 жыл бұрын
I have no clue what I just did... but I did it...
@oneilmw
@oneilmw 3 жыл бұрын
12:30 Lines 9 and 10 both start with "case"... does this mean that running=false; should be ran in the line 9 case OR the line 10 case, as in: if(uMsg == WM_CLOSE|WM_DESTROY){...} Also, why is running = false; inside the curly brace for the case but break is outside? It's still in the switch, but why the distinction? Which case(s) apply to running=false; and which case(s) apply to break?
@Skarjak36
@Skarjak36 5 жыл бұрын
Hey! Thanks for the guide. Quick question: at 4:51 we can see that when you hover over lpfnWndProc you are getting a little tooltip that links to some documentation. How are you getting that? Hovering or selecting that text just shows me a tag.
@DanZaidan
@DanZaidan 5 жыл бұрын
I'm glad you are liking it! Actually I have CS_VREDRAW under the cursor at this point (lpfnWndProc is only selected via Shift+Arrow Keys), so it shows the tooltip for the macro (pink text). If you don't see, I'm not really sure, I have installed VS2019 specifically for this series. You can watch me installing it on episode #0 (with the Windows SDK, so maybe it has something to do with it?) and I haven't added anything to it. :P Visual Studio is kind of a mystery... hahaha Sorry I couldn't be more useful.
@Skarjak36
@Skarjak36 5 жыл бұрын
@@DanZaidan So it turns out that the version of visual studios that comes with unity3d is 2017 and the features that were lacking from my intellisense quickinfo panel were added in 2019. -_- Well, I guess I just spent a couple hours learning all about intellisense. Visual studio is not longer a mystery to me. :p
@tesseraction3462
@tesseraction3462 2 жыл бұрын
This is the best tutorial for creating Windows in C++ I have ever seen. Thank you for putting in the effort to explain things so well. You explained enough that I can fill in any of the other information by doing my own research. Other tutorials are so vague that I don't even have enough information to efficiently and effectively do my own research to fill in all of the holes. Once again, thank you.
@Eion_real
@Eion_real 11 ай бұрын
I hope you are doing well sir as you have not posted anything on the channel for 3 years i feel bad as i was not able watch this legacy in its prime . I will absorb every bit of information for game development and make something. Thank you from the bottom of my heart as game development is my dream and i hope you read my comment if you are out there🤗👍
@LanNguyen-um6mv
@LanNguyen-um6mv 4 жыл бұрын
keep doing great things like that bro!
@1211-n4d
@1211-n4d 2 ай бұрын
at 4:00 I can only see wndclassA structure on the msdn?
@orphixigl1476
@orphixigl1476 Жыл бұрын
Thanks for the tutorial! I did the code as in the video but i have a problem: when i execute the file, it also opens the console. i´m doing this in vscode. What can i do to solve this? (Sorry if my english is bad, it´s not my firss language.)
@YungRagz
@YungRagz 3 жыл бұрын
Hi, I have a few problems with my game. So first of all the 1Param wouldn't go grey, then when I got to the CreateWindow part the "CreateWindow" error wouldn't go away. And then I couldn't debug because of the errors and when I went to debug> Windows There was no watch window there. I'm using Visual studio 2022. Please help me
@ReyitosXD
@ReyitosXD 3 жыл бұрын
it's "lParam" not "1Param" his font made the lowercase L look like a 1 for some reason, as for a window just put a L before the title in quotes
@benoldum118
@benoldum118 2 жыл бұрын
I'm getting "LPCSTR kind entity cannot assignt to "const wchar_t*" no value assignment of type" and " Unable to convert ''=' const wchar_t - LPCSTR" errors in this line //Create a window class WNDCLASS window_class = {}; window_class.style = CS_HREDRAW | CS_VREDRAW; window_class.lpszClassName = "Wnd"; //This is line with the problem window_class.lpfnWndProc = window_callback; Please help
@fayefaerii
@fayefaerii Жыл бұрын
2 minutes of video and my brain already fried ill come back tomorrow
@hungariannerd8445
@hungariannerd8445 Жыл бұрын
thank you for the series, im learning a lot
@tomneumann8653
@tomneumann8653 3 жыл бұрын
Can someone help me? I have the same code as in 5:42 in the video but I get error from line: window_class.lpszClassName = "Game Window Class"; the error is '=' cannot convent from 'const char[2] to 'LPCWSTR'
@forestguy1106
@forestguy1106 3 жыл бұрын
put an L before the quotes: window_class.lpszClassName = L"Game Window Class"; Idk why exactly it fixes the problem, but it does, so here you go
@ladyunknown101
@ladyunknown101 3 жыл бұрын
@@forestguy1106 sadly, that does not seem to work
@vanshikagarg647
@vanshikagarg647 2 жыл бұрын
sir my diagnostic tool part showing No data has been collected yet.....and debug>window>then there is no watch option
@ColdBlood14
@ColdBlood14 4 ай бұрын
You will get the watch option when you are in line by line mode ( press F10)
@jakubkozlowski3066
@jakubkozlowski3066 2 жыл бұрын
One guy commented with a solution to an error: window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). One can solve it by imply writing it with "L" before the string like: window_class.lpszClassName = L"Game Window Class". Im not sure of it but L there works as an literal defined by msc, and what it does is basically make your single char take twice as much space (or sth like that) as it is in LPCWSTR
@EgeÇınar-m7f
@EgeÇınar-m7f Жыл бұрын
are you boy or girl
@jakubkozlowski3066
@jakubkozlowski3066 Жыл бұрын
@@EgeÇınar-m7f male, why
@MegaManlego
@MegaManlego 5 жыл бұрын
What command you use to debug line by line at 9:08 ?
@DanZaidan
@DanZaidan 5 жыл бұрын
It's F10. The same shortcut I introduced in the end of last lesson. ;)
@eatpant4ever
@eatpant4ever 2 жыл бұрын
Seeing someone with a Layton profile pic on a C++ video was really unexpected.
@jamescut466
@jamescut466 3 жыл бұрын
At 9:35what did you with the keyboard??
@omkarbansode6305
@omkarbansode6305 4 ай бұрын
Did you find out? I also didn't understand it
@ajthemelon
@ajthemelon Жыл бұрын
if anyone's having any syntax errors for seemingly no reason, make sure all your brackets {} are in the correct places!
@suppressinglight1007
@suppressinglight1007 3 жыл бұрын
mainly learned about platform development in this did not know how to do that before thx.
@johnnyalhat2305
@johnnyalhat2305 5 жыл бұрын
Hey man. Love your video Waiting for new tutorial
@DanZaidan
@DanZaidan 5 жыл бұрын
Thanks so much for your comment! :D
@thedustypilot1473
@thedustypilot1473 3 жыл бұрын
My visual studio says that I have the error c2440 on line 9. Timestamp is 4:39.
@cuicuiismybaby
@cuicuiismybaby Ай бұрын
hi, the first window function should I spend time to study or just check in the microsoft web?
@gamercodes3370
@gamercodes3370 Жыл бұрын
in my CreateWindow(); it's giving me error because it's saying:argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR". PLEAAAAAAAAAAAAAAAAAAAAAAAAAAAASSSSSSSSSSEEE Someone help!!!!!! 🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺
@ielliena_
@ielliena_ Жыл бұрын
CreateWindow( win_class.lpszClassName, L"Test Game!", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0 );
@thomaschappell8105
@thomaschappell8105 4 ай бұрын
Lmao. Just spent an hr trying to figure out what was wrong before thinking to check comments
@gamesnroses6595
@gamesnroses6595 5 жыл бұрын
Tutorials really cool!!! Thanks for work😉
@Felipekimst
@Felipekimst Жыл бұрын
can someone help me? it errors C4716 'winMain': must return a value if I return 0 or 1 it says cant find main();
@doctornesneb3955
@doctornesneb3955 3 жыл бұрын
For my code I had to type an L just before every mention of "Game Window Class" to avoid getting the following build error: Severity Code Description Project File Line Suppression State Error (active) E0513 a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR" My_First_Cpp_Game Any idea why?
@MrFoxUltima
@MrFoxUltima 3 жыл бұрын
I'm having the same issue if you figure it out please explain
@doctornesneb3955
@doctornesneb3955 3 жыл бұрын
@@MrFoxUltima Will do. It doesn't seem to be a hinderance though. Just a nuisance
@tequinlake1091
@tequinlake1091 3 жыл бұрын
Thanks my code took the L now it works
@dr.velious5411
@dr.velious5411 2 жыл бұрын
Typing L changes it to wide character type, no idea why that fixes it though.
@tofazzolakash5515
@tofazzolakash5515 Ай бұрын
Is there any way to code this game(or whatever simulation)on my tablet(in any extent)?cause I am really interested
@georgem9375
@georgem9375 Жыл бұрын
pointer explaination on point i must say
@meep1l246
@meep1l246 3 жыл бұрын
hey so i got to the point where the blank window should pop up, however it reads that an access violation was thrown. the code is 0xC000041D. do you know how to fix this?
@vaz5926
@vaz5926 3 жыл бұрын
This is amazing! Thank you for sharing this man :]
@starplatinum5311
@starplatinum5311 Жыл бұрын
I watch this in 2023 and the code have this new line "[in] WNDPROC lpPrevWndFunc", is it necessary to include this line?
@rezac4042
@rezac4042 3 жыл бұрын
I have a few errors... I was following along to your code until 5:46 until i tried to compile and got these errors. Can someone please help me with this? Also great quality vid i am liking it so far a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR", '=': cannot convert from 'const char [18]' to 'LPCWSTR' The intermediate directory (Debug\) contains files shared from another project (Project1.vcxproj). This can lead to incorrect clean and rebuild behavior.
@DanZaidan
@DanZaidan 3 жыл бұрын
Hi! This means that "CreateWindow" is expecting "wide characters" for the window name (characters that support the whole Unicode format). You can easily fix this by calling CreateWindowA instead (also make sure that RegisterClass has the A sufix). Alternatively, you could pass "wide characters" instead of normal strings to it, by prefixing the string with L, like so: CreateWindow(L"Window Title", ...); Let me know if it helps. :)
@thituyetanhle1895
@thituyetanhle1895 4 жыл бұрын
what is "CreateWindowExW: function does not take 11 arguments"? help me please :) at 8:54
@DanZaidan
@DanZaidan 4 жыл бұрын
Hi! I think the problem is that you are creating an extended window (CreateWindowExW) and not a "normal" window (CreateWindowA). The former requires more arguments: (See: docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw) Try calling the "normal" window creation function directly (CreateWindowA instead of CreateWindow or CreateWindowExW) and see if it helps. :)
@thituyetanhle1895
@thituyetanhle1895 4 жыл бұрын
@@DanZaidan Thanks :)
@letsgameforever
@letsgameforever Жыл бұрын
i get this error message identifier "window" is undefined
@bastienrobin9334
@bastienrobin9334 5 ай бұрын
Thanks a lot for the video ! I had an error at 5:47 for the compilation (error LNK2019) : I had to add just after the call of the library windows.h the line : #pragma comment(lib, "user32.lib")
@delta28-Vods
@delta28-Vods 4 жыл бұрын
I’m haveing troubles with the LPSTR part of the int winmain code it’s saying cannot concert const char to [18] to LPCWSTR could I get some help?
@ahmedthegreat3973
@ahmedthegreat3973 3 жыл бұрын
Have you found a fix Mine is also not working
@DanZaidan
@DanZaidan 3 жыл бұрын
@@ahmedthegreat3973 Hi! This means that "CreateWindow" is expecting "wide characters" for the window name (characters that support the whole Unicode format). You can easily fix this by calling CreateWindowA instead (also make sure that RegisterClass has the A sufix). Alternatively, you could pass "wide characters" instead of normal strings to it, by prefixing the string with L, like so: CreateWindow(L"Window Title", ...); Let me know if it helps. :)
@theunknown7075
@theunknown7075 3 ай бұрын
i have two build erros link2019 and link1120 1 .how to resolve the issue and i just dont know where was the problem it says unable to run the porgram at specified direction
@palashahirwar1187
@palashahirwar1187 3 жыл бұрын
plz help me with this part ' 2:02 - 3:03 ' i am using Code::Blocks IDE
@palashahirwar1187
@palashahirwar1187 3 жыл бұрын
plz i am in dire need of help!!
@DanZaidan
@DanZaidan 3 жыл бұрын
@@palashahirwar1187 What is the problem you are having, Palash?
@palashahirwar1187
@palashahirwar1187 3 жыл бұрын
@@DanZaidan don't worry now i have switched to visual studio IDE thnx..
@neonclouds9295
@neonclouds9295 Жыл бұрын
1:19 why doesnt this code work on clion?
@nicoledenty-uu9ul
@nicoledenty-uu9ul 10 ай бұрын
I literally copy step for step what you're doing and it don't work same with hello world watched until 3:16 exe doesnt exist and failed to start because it cannot find the file
@andresbarragan7212
@andresbarragan7212 6 ай бұрын
did you click on "Build Solution" ? It happend to me the same but clicking on "Local Windows Debugger" made it work
@foxfirefive
@foxfirefive 4 жыл бұрын
it says that it cant find windows.h. also all this line of code: (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) it wont work and i want to do this.
@DanZaidan
@DanZaidan 4 жыл бұрын
This probably mean you don't have the Windows SDK installed. It is installed automatically when you install Visual Studio. Maybe the best thing for you to do would be to reinstall it and make sure you select the "C++ Development" option. :)
@foxfirefive
@foxfirefive 4 жыл бұрын
@@DanZaidan thanks! i will try it.
@widhskxnkan1349pl
@widhskxnkan1349pl 4 жыл бұрын
Hey, I'm really enjoying the tutorial, but I've encountered an issue. See, I'm using blocks instead of visual studio and somehow can't compile the code. When I click the "build" button nothing happens, but when I click the "run" button, the window about the code not being built appears. This would be normal but the window keeps reappearing whenever I click the "yes" option and the code still isn't compiled. Is it a compiler issue, or something else? Also, I don't know how to change the x64 bit os into x32 bit os. It's much clearer in visual studio but not in codeblocks.
@DanZaidan
@DanZaidan 4 жыл бұрын
Hi Marcel. This seems to be an IDE issue. Unfortunately, I don't know CodeBlocks so I can't help you specifically. However, I would suggest trying to create a simple "Hello World" program before tacking the game to make sure everything is working properly. :)
@ReheThe69
@ReheThe69 Жыл бұрын
How can I fix the CreateWindow error? When I type it, it's wrong spelling and my only option is to take it out. So can you fix it for me please?
@noahboccongelle8839
@noahboccongelle8839 4 жыл бұрын
what version on visuel studio do I download (community, professional, enterprise )
@DanZaidan
@DanZaidan 4 жыл бұрын
The community edition is perfect for individuals! (And it's free! :D )
@nourtech705
@nourtech705 Жыл бұрын
I’m new to coding and i would like to know if i Can do that using vs on a mac???
@bbdnuh1028
@bbdnuh1028 5 жыл бұрын
very good channel, thanks for your time bro subscribed!
@DanZaidan
@DanZaidan 5 жыл бұрын
Thank YOU! :D
@Kanin_is.Beri_Good
@Kanin_is.Beri_Good 5 ай бұрын
im stuck at the create window part it just keeps saying theres an error when i followed everything from the video right
@gorangorkoza6666
@gorangorkoza6666 4 жыл бұрын
Creating a Window in plain C++ is a bit painful at start. Charles Petzold explains a lot of window creation and its properties in his "Programming Windows" book...
@UsernameaBad
@UsernameaBad Жыл бұрын
It Saya hwnd and the other stuff in the callback function thing are unidentified, how to fix
@Paul1miller1
@Paul1miller1 Жыл бұрын
I dont know if this is beginner friendly. I'm trying to follow and I dont understand any of these concepts yet. I think I have to go do some reading on C++.
@haroldmcbroom7807
@haroldmcbroom7807 2 жыл бұрын
First off, thanks for the video :) Everything works fine, until 12:00 in the video, towards the end. "warning: no return statement in function returning non-void [-Wreturn-type]" The problem for me started when you changed... return DefWindowProc(hwnd, uMsg, wParam, lParam); to... return result; Here's my code: LRESULT CALLBACK window_callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ LRESULT result = 0; switch(uMsg){ case WM_CLOSE: case WM_DESTROY: { running = false; } break; default: { result = DefWindowProc(hwnd, uMsg, wParam, lParam); } } return result; } I got it working by putting "return 0" within the WinMain{} block, as the last statement, figuring that if an error occurs, then the return value will not be 0. I'm using Mingw64, with Notepad++ Maybe it's a compiler issue that won't allow me to run the program while WinMain expects a return value, even though the "return" value has already been provided within the LRESULT CALLBACK window_callback() function. Perhaps?
@Fr4nkVG
@Fr4nkVG 4 жыл бұрын
thanks for this tutorial brother, great stuff
@DanZaidan
@DanZaidan 4 жыл бұрын
I'm glad you liked it, Frank! :)
@jacobrichards720
@jacobrichards720 Жыл бұрын
I get the error below at '=' in the line window_class.lpszClassName = "Game Window Class"; a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR"C/C++(513) I also get another error shown below in the line CreateWindowA(window_class.lpszClassName, "My First Game!", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0); argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR"C/C++(167) I followed along exactly and should get the blank window but for some reason the types don't agree and I am not sure why and don't know enough to fix it. I have tried several things like using a wide string by putting 'L' in front of "Game Window Class", but that doesn't fix the other error. I've tried CreateWindow without the 'A' and tried other versions of CreateWindow but always end up with errors.
@bts.army.ot7.2013
@bts.army.ot7.2013 Жыл бұрын
for the first problem i guess u can go to properties in the project > advanced > character set > "Use Multi-Byte Character Set". it's fixed my error
@WorldGamer-vq7wv
@WorldGamer-vq7wv 6 ай бұрын
my mans keyboard is on fire
@mjmares
@mjmares Жыл бұрын
I had a problem with the wide strings but then i put L infront, bc the wind api likes wide strings? idk can someone example why that works?
@hadiaabq7981
@hadiaabq7981 3 ай бұрын
How do i make the window stop?? I struggled but succeeded to find the watch option now what did you press i don't get it?
@hadiaabq7981
@hadiaabq7981 3 ай бұрын
Solved
@Gnarkson
@Gnarkson 2 жыл бұрын
Its a wonderful tutorial! Great man, continue with that, please!
@prankbyte6125
@prankbyte6125 3 жыл бұрын
There is an error in the statement "window_class.lpszClassName = "Game Window Class";". It underlines "=" saying that it cannot be a const char value for LPCWSTR. How do I fix this?
@zenitsu950
@zenitsu950 2 жыл бұрын
im so mad no one replied to this with a fix lmao
@Digitalman271
@Digitalman271 3 жыл бұрын
Coming here from C#, which I came to after doing this via python. This is soooo much harder..
@capitanDeLoFortuito
@capitanDeLoFortuito 3 жыл бұрын
I really want to do this tutorial, but my Visual Studio seems to be different than yours, I don´t have the Properties option, for example
@stephanieezat-panah7750
@stephanieezat-panah7750 3 жыл бұрын
whew! made it! you are amazing, but, wow
@zeeninjapanda8505
@zeeninjapanda8505 3 жыл бұрын
on create window it is underlined in red and i cant get rid of it... How do i do that?
@DanZaidan
@DanZaidan 3 жыл бұрын
Try posting your code here and I'll try to help out. :)
@hadiyahalkauthar
@hadiyahalkauthar 3 жыл бұрын
*MAKE SURE TO COPY IT EXACTLY!!!* I had the same problem and it was because I only had one "CW_USEDEFAULT" when there should be two. Here's what you should copy: CreateWindow(window_class.lpszClassName, "Your name", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0);
@sidkisoleh
@sidkisoleh Жыл бұрын
how can i fix "" when debug window watch?
How to program a game in C++: #2 - Drawing Graphics
22:08
Dan Zaidan
Рет қаралды 121 М.
CHESS! // Code Review
51:05
The Cherno
Рет қаралды 245 М.
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
Web10190h - Can You Trust (Web Handling) Equations
14:03
David Roisum
Рет қаралды 4
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
you will never ask about pointers again after watching this video
8:03
How to make games in C++ from 0 experience!
5:23
Low Level Game Dev
Рет қаралды 17 М.
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 836 М.
Making a C++ Game with No Experience!
5:51
Barji
Рет қаралды 784 М.
Cross Platform Graphical User Interfaces in C++
44:49
javidx9
Рет қаралды 875 М.
Making a Game With C++ and SDL2
5:34
Goodgis
Рет қаралды 670 М.
BEST WAY to make Desktop Applications in C++
26:00
The Cherno
Рет қаралды 950 М.
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН