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

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 430

  • @Hallowfont
    @Hallowfont 2 ปีที่แล้ว +425

    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 ปีที่แล้ว +9

      Thanks for this 👍

    • @piwwol1405
      @piwwol1405 2 ปีที่แล้ว +2

      Thank you😁

    • @misterkeyboard.
      @misterkeyboard. 2 ปีที่แล้ว +3

      Thank you so much!

    • @calebrowell71
      @calebrowell71 2 ปีที่แล้ว +4

      I'm not religious but you are an angel. Thank you

    • @DidIJustDoThat
      @DidIJustDoThat 2 ปีที่แล้ว +1

      Thank you

  • @michealking6425
    @michealking6425 4 ปีที่แล้ว +241

    It was hard, but I got through. I've never been so happy to see a blank window before

    • @DanZaidan
      @DanZaidan  4 ปีที่แล้ว +42

      That's awesome!!
      Blank windows do have their charm... :)

    • @username-ur6dq
      @username-ur6dq 3 ปีที่แล้ว +10

      just finished it also such a satisfying feeling

    • @stephanieezat-panah7750
      @stephanieezat-panah7750 3 ปีที่แล้ว +4

      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

    • @andrecostafranca
      @andrecostafranca 19 วันที่ผ่านมา

      real

  • @DanZaidan
    @DanZaidan  5 ปีที่แล้ว +15

    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! :)

  • @mateo910
    @mateo910 2 ปีที่แล้ว +95

    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 ปีที่แล้ว +1

      Thanks for this.

    • @The_Snailman
      @The_Snailman 2 ปีที่แล้ว

      tysm

    • @dominicervig
      @dominicervig 2 ปีที่แล้ว +3

      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

  • @arkanesugar
    @arkanesugar 2 ปีที่แล้ว +9

    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 ปีที่แล้ว +16

    I have been searching for this tutorial for a whole day and now I have finally found one that works

    • @DanZaidan
      @DanZaidan  4 ปีที่แล้ว +4

      I hope you love it! :)

  • @GREEENZO
    @GREEENZO 3 ปีที่แล้ว +26

    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!

  • @vanessabyerly3752
    @vanessabyerly3752 2 ปีที่แล้ว +10

    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 8 หลายเดือนก่อน +1

      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 6 หลายเดือนก่อน

      Thank you i was so confused by the error and this comment helped me out a lot!

  • @M3t4lik
    @M3t4lik 2 ปีที่แล้ว +5

    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.

  • @rachelveer7574
    @rachelveer7574 5 ปีที่แล้ว +39

    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.

  • @Akshatparihar007
    @Akshatparihar007 หลายเดือนก่อน +1

    following this in 2024, will keep you updated

    • @Akshatparihar007
      @Akshatparihar007 หลายเดือนก่อน +1

      Just finished this video didn't understand a lot but felt good after seeing the box. Learned a lot

  • @atreyumclewin8282
    @atreyumclewin8282 2 ปีที่แล้ว +6

    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 9 หลายเดือนก่อน

      Exactly what I needed, thank you!

  • @alexjulius69
    @alexjulius69 2 ปีที่แล้ว +24

    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 ปีที่แล้ว +8

      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 :)

  • @liamlluls1588
    @liamlluls1588 2 ปีที่แล้ว +16

    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!

  • @gilernt
    @gilernt 3 หลายเดือนก่อน

    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!

  • @StellarMirage
    @StellarMirage 2 ปีที่แล้ว +1

    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 :)

  • @soneone5525
    @soneone5525 4 ปีที่แล้ว +33

    Who had to watch it in x0.75 because his typing is too fast

    • @utkarshawasthi3368
      @utkarshawasthi3368 3 ปีที่แล้ว +2

      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 .

  • @DH-cg6qx
    @DH-cg6qx 7 หลายเดือนก่อน +3

    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 5 หลายเดือนก่อน +1

      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 5 หลายเดือนก่อน +1

      @@anforawelch marks the literal as a wide literal

    • @anforawelch
      @anforawelch 5 หลายเดือนก่อน

      @@DH-cg6qx thank you😁

  • @suddencucumber5994
    @suddencucumber5994 4 ปีที่แล้ว +13

    this is underrated

  • @M3t4lik
    @M3t4lik 2 ปีที่แล้ว +3

    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.

  • @alyashour7403
    @alyashour7403 3 ปีที่แล้ว +11

    it was a little fast, but definitely was waaaay more informative than every other tutorial i could find

  • @noaxin
    @noaxin 4 ปีที่แล้ว +10

    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  4 ปีที่แล้ว +19

      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 4 ปีที่แล้ว

      @@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 4 ปีที่แล้ว

      @@DanZaidan Hello Dan! Sorry for the late response! Thank you for your helo! I'll let you know if it worked!

    • @daattavyaaggarwal7768
      @daattavyaaggarwal7768 4 ปีที่แล้ว

      @@TeaDessert Did you find a solution? I have the exact same problem.

    • @TeaDessert
      @TeaDessert 4 ปีที่แล้ว

      @@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 ปีที่แล้ว +1

    what a satisfying view that white window was...after struggling all those build errors!!

  • @Eion_real
    @Eion_real 9 หลายเดือนก่อน

    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🤗👍

  • @ChupoCro
    @ChupoCro 3 ปีที่แล้ว +2

    Congratulations! This is how tutorials should be done!

    • @DanZaidan
      @DanZaidan  3 ปีที่แล้ว +2

      Awesome!
      I'm glad you liked it. :)

  • @fcmedic4217
    @fcmedic4217 3 ปีที่แล้ว +4

    bro that was the most hardcore 12 minutes of my life

  • @matviyberezovskiy2372
    @matviyberezovskiy2372 3 ปีที่แล้ว +5

    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

  • @carlo2984
    @carlo2984 4 ปีที่แล้ว +3

    Thank you so much! You will probably be the guy that teaches me coding

    • @DanZaidan
      @DanZaidan  4 ปีที่แล้ว +2

      That would be awesome! :D

  • @Hiyori___
    @Hiyori___ 2 ปีที่แล้ว +5

    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.

    • @amustypigeon
      @amustypigeon 9 หลายเดือนก่อน

      yes probably

  • @danish3605
    @danish3605 3 ปีที่แล้ว +5

    I have no clue what I just did... but I did it...

  • @mathsalmath
    @mathsalmath 4 ปีที่แล้ว +2

    Thank you for sharing your talent, please continue. Excellent video.

  • @user23724
    @user23724 3 ปีที่แล้ว +8

    Thanks, but no need to try to speed run the tutorial, take your time man, lots of people like to 'code along' to tutorials, when you're going so fast, it's hard to follow and code at the same time, it also doesn't leave much time to think about what you're saying, and understand it. It's easy for you because you've done it a million times, but for a beginner, it takes time to understand what the names even mean. I had to keep switching back to this video and pausing it every 5 seconds.

    • @stephanieezat-panah7750
      @stephanieezat-panah7750 3 ปีที่แล้ว

      yes, yes & yes! still, great tutorial. but yes, tranquilo, just a bit

  • @hadiaabq7981
    @hadiaabq7981 หลายเดือนก่อน

    Though surely this is the best. I appreciate your work! The best tutorial out there.

  • @thomaschappell8105
    @thomaschappell8105 2 หลายเดือนก่อน +1

    Lmao. Just spent an hr trying to figure out what was wrong before thinking to check comments

  • @orphixigl1476
    @orphixigl1476 ปีที่แล้ว +2

    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.)

  • @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.

  • @benoldum118
    @benoldum118 2 ปีที่แล้ว +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

  • @ranchbathtub1
    @ranchbathtub1 2 ปีที่แล้ว +4

    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 3 หลายเดือนก่อน

      window_class.lpszClassName = L"Game Window Class"; use this bro

  • @fayefaerii
    @fayefaerii ปีที่แล้ว +2

    2 minutes of video and my brain already fried ill come back tomorrow

  • @soumysahu
    @soumysahu 2 หลายเดือนก่อน +1

    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",......

  • @vanshikagarg647
    @vanshikagarg647 2 ปีที่แล้ว +2

    sir my diagnostic tool part showing No data has been collected yet.....and debug>window>then there is no watch option

    • @ColdBlood14
      @ColdBlood14 2 หลายเดือนก่อน

      You will get the watch option when you are in line by line mode ( press F10)

  • @hungariannerd8445
    @hungariannerd8445 10 หลายเดือนก่อน

    thank you for the series, im learning a lot

  • @niektuytel9519
    @niektuytel9519 4 ปีที่แล้ว +5

    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 ปีที่แล้ว +3

      L"name" xd works just fine

    • @julianavar3836
      @julianavar3836 4 ปีที่แล้ว +1

      @@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

  • @LanNguyen-um6mv
    @LanNguyen-um6mv 4 ปีที่แล้ว +3

    keep doing great things like that bro!

  • @letsgameforever
    @letsgameforever ปีที่แล้ว +3

    i get this error message identifier "window" is undefined

  • @WorldGamer-vq7wv
    @WorldGamer-vq7wv 4 หลายเดือนก่อน

    my mans keyboard is on fire

  • @starplatinum5311
    @starplatinum5311 ปีที่แล้ว +1

    I watch this in 2023 and the code have this new line "[in] WNDPROC lpPrevWndFunc", is it necessary to include this line?

  • @georgem9375
    @georgem9375 10 หลายเดือนก่อน

    pointer explaination on point i must say

  • @meep1l246
    @meep1l246 3 ปีที่แล้ว +1

    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?

  • @Skarjak36
    @Skarjak36 5 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      @@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

  • @suppressinglight1007
    @suppressinglight1007 2 ปีที่แล้ว

    mainly learned about platform development in this did not know how to do that before thx.

  • @johnnyalhat2305
    @johnnyalhat2305 5 ปีที่แล้ว +5

    Hey man.
    Love your video
    Waiting for new tutorial

    • @DanZaidan
      @DanZaidan  5 ปีที่แล้ว

      Thanks so much for your comment! :D

  • @scotty2dadout
    @scotty2dadout 8 หลายเดือนก่อน +1

    Its impossible to follow the video in real time and having to pause for every action because you move on and use shortcuts way too quickly for any beginner to follow along with is a bit frustrating but the video is packed with info which is good. Including the links to the resources would also be very helpful in saving people time.

  • @raphg999
    @raphg999 2 ปีที่แล้ว +2

    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 2 ปีที่แล้ว +1

      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

  • @Glitch900
    @Glitch900 ปีที่แล้ว +2

    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.

  • @widhskxnkan1349pl
    @widhskxnkan1349pl 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      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. :)

  • @albertovitsch453
    @albertovitsch453 3 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      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 2 ปีที่แล้ว

      @@akabami2161 doesnt work anymore with the 2019 version

  • @lyohaboy8662
    @lyohaboy8662 6 หลายเดือนก่อน +1

    Making games on raw C++ seems so hard bro

  • @dontaskmeforusername
    @dontaskmeforusername 4 หลายเดือนก่อน +1

    this is definitely not for beginners 🤯
    in fact it scared me away from programming. very overwhelming

    • @thelionszen3352
      @thelionszen3352 17 วันที่ผ่านมา

      this is OOP which is a couple of lessons into c++. if i were to relate this to college classes this would be like a midterm project in the second c++ class

  • @gamesnroses6595
    @gamesnroses6595 5 ปีที่แล้ว +1

    Tutorials really cool!!! Thanks for work😉

  • @ajthemelon
    @ajthemelon ปีที่แล้ว +1

    if anyone's having any syntax errors for seemingly no reason, make sure all your brackets {} are in the correct places!

  • @jamescut466
    @jamescut466 3 ปีที่แล้ว +2

    At 9:35what did you with the keyboard??

    • @omkarbansode6305
      @omkarbansode6305 2 หลายเดือนก่อน

      Did you find out?
      I also didn't understand it

  • @Felipekimst
    @Felipekimst ปีที่แล้ว +1

    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 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      I'm having the same issue if you figure it out please explain

    • @doctornesneb3955
      @doctornesneb3955 3 ปีที่แล้ว +1

      @@MrFoxUltima Will do. It doesn't seem to be a hinderance though. Just a nuisance

    • @tequinlake1091
      @tequinlake1091 2 ปีที่แล้ว +1

      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.

  • @jakubkozlowski3066
    @jakubkozlowski3066 ปีที่แล้ว +1

    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

  • @vaz5926
    @vaz5926 3 ปีที่แล้ว

    This is amazing! Thank you for sharing this man :]

  • @ninjabirdman551
    @ninjabirdman551 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      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 3 ปีที่แล้ว

      @@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.

  • @pramodbhandari9151
    @pramodbhandari9151 5 ปีที่แล้ว

    Great tutorial man, just a question , There is no minimize, maximize and close buttons in my output window??
    EDIT: Also no black screen on the next tutorial??

    • @DanZaidan
      @DanZaidan  5 ปีที่แล้ว

      Thanks! Make sure you are passing both flags to the CreateWindow function.
      @8:16 WS_OVERLAPPEDWINDOW | WS_VISIBLE
      I'm not sure what you mean by no black screen :P

  • @Kanin_is.Beri_Good
    @Kanin_is.Beri_Good 3 หลายเดือนก่อน

    im stuck at the create window part it just keeps saying theres an error when i followed everything from the video right

  • @delta28-Vods
    @delta28-Vods 3 ปีที่แล้ว +1

    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. :)

  • @stephanieezat-panah7750
    @stephanieezat-panah7750 3 ปีที่แล้ว

    whew! made it! you are amazing, but, wow

  • @jacobrichards720
    @jacobrichards720 11 หลายเดือนก่อน

    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 10 หลายเดือนก่อน +1

      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

  • @theunknown7075
    @theunknown7075 หลายเดือนก่อน

    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

  • @ET-oq1vj
    @ET-oq1vj 2 ปีที่แล้ว

    sorry but i did not watch the first video you mentioned, could you link it?

  • @bbdnuh1028
    @bbdnuh1028 5 ปีที่แล้ว +1

    very good channel, thanks for your time bro subscribed!

    • @DanZaidan
      @DanZaidan  5 ปีที่แล้ว +1

      Thank YOU! :D

  • @foxfirefive
    @foxfirefive 4 ปีที่แล้ว +1

    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.

  • @1211-n4d
    @1211-n4d 9 วันที่ผ่านมา

    at 4:00 I can only see wndclassA structure on the msdn?

  • @ReheThe69
    @ReheThe69 10 หลายเดือนก่อน

    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?

  • @camy3988
    @camy3988 2 ปีที่แล้ว

    i just started this and it says theres something wrong with " window_class.lpszClassName = "Game Window Class"; " and i dont know what to do because this is also exaclty what u have in the video

  • @stevekay6895
    @stevekay6895 6 หลายเดือนก่อน +1

    Damn....You have drawn a blank window and I'm already lost....guess I'm off to watch another 30 to 40 more "Hello World" tutorials....Great video tho, not your fault.

  • @AlexPressure777
    @AlexPressure777 ปีที่แล้ว

    I need a tutorial to do this on my phone while my laptop is in the shop

  • @gamercodes3370
    @gamercodes3370 ปีที่แล้ว +1

    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_ ปีที่แล้ว +1

      CreateWindow(
      win_class.lpszClassName,
      L"Test Game!",
      WS_OVERLAPPEDWINDOW | WS_VISIBLE,
      CW_USEDEFAULT,
      CW_USEDEFAULT,
      1280,
      720,
      0,
      0,
      hInstance,
      0
      );

  • @rares9433
    @rares9433 3 ปีที่แล้ว

    how did you test the Project??

  • @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 3 ปีที่แล้ว

    thanks for this tutorial brother, great stuff

    • @DanZaidan
      @DanZaidan  3 ปีที่แล้ว

      I'm glad you liked it, Frank! :)

  • @noahboccongelle8839
    @noahboccongelle8839 4 ปีที่แล้ว +1

    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 )

  • @Gnarkson
    @Gnarkson 2 ปีที่แล้ว

    Its a wonderful tutorial! Great man, continue with that, please!

  • @kylorojen8066
    @kylorojen8066 3 ปีที่แล้ว

    Is this C++ a diefferent program? Because I downloaded a C++ program but it doesnt have that Infinity logo. I'm just a freshmen in computer engineering and I dont know where to get this C++. I only downloaded the DEV C++ is that different?

    • @hadiaabq7981
      @hadiaabq7981 หลายเดือนก่อน

      Bruh! You're talking about IDE. This is a different one yay. As it had been 2 years I think you know it now!

    • @kylorojen8066
      @kylorojen8066 หลายเดือนก่อน

      @@hadiaabq7981 hahaha true I didnt know what I was talking about then

  • @UsernameaBad
    @UsernameaBad 11 หลายเดือนก่อน

    It Saya hwnd and the other stuff in the callback function thing are unidentified, how to fix

  • @zeeninjapanda8505
    @zeeninjapanda8505 3 ปีที่แล้ว +1

    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);

  • @WahajKamleen
    @WahajKamleen 4 หลายเดือนก่อน

    I got error in creatwindowW
    Tell me how to solve this error

  • @Digitalman271
    @Digitalman271 2 ปีที่แล้ว +1

    Coming here from C#, which I came to after doing this via python.
    This is soooo much harder..

  • @abdulrehman7470
    @abdulrehman7470 ปีที่แล้ว

    If I were to put pointers on the scale 1 to 10. How important are they?

  • @shi64gaming73
    @shi64gaming73 10 หลายเดือนก่อน

    What is name of app?

  • @phantomboy09
    @phantomboy09 3 ปีที่แล้ว

    the buttons for making it full screen does not appear

  • @hadiaabq7981
    @hadiaabq7981 หลายเดือนก่อน

    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?

  • @apex0836
    @apex0836 23 วันที่ผ่านมา

    I just feel like even if i do this and get it working I still won't know what I did or why it works. Will this help me learn/teach me something?

    • @thelionszen3352
      @thelionszen3352 17 วันที่ผ่านมา

      somethings my professor though me is writing the code out on paper and finding out what each piece of code does aka taking notes on the code. you'll also need to be able to recognize classes and pointers to understand the parts in this video. you can also use an AI to break down pieces of the code.
      some of the stuff such as the windows you dont "really" need to know how it works just that it's windows class for windows development. but microsoft does have a documentation you can read through on what each part does.

  • @capitanDeLoFortuito
    @capitanDeLoFortuito 2 ปีที่แล้ว

    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

  • @emilhsimonsen
    @emilhsimonsen 3 ปีที่แล้ว +1

    my window isnt responding

  • @gbm6882
    @gbm6882 4 ปีที่แล้ว +1

    C++ is so much memorization as compared to c#.... you can’t type window size and expect a similar variable to show up