Im following a YouTube video that explains how to create a simple game with C++, here is the link: https://www.youtube.com/watch?v=yD0WzbKJcOg&list=PL7Ej6SUky135IAAR3PFCFyiVwanauRqj3&index=2&ab_channel=DanZaidan He is using Visual Studio 2019, im using 2022 but i dont think that's a problem. I literally copied and pasted in my project the same code he published under the video after many attempts, but it still doesn't work even if it's the same. If i leave the code in his project, it works, if i copy and paste it inside my project, it doesn't. Here are the two differences i noticed: 1- The external dependencies folder of my project has different files than his. 2- In my project, the IDE tells me that there are two mistakes. Sorry if its a noob question, im really new in programming.
#include <windows.h>
bool running = true;
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;
}
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
// Create Window Class
WNDCLASS window_class = {};
window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.lpszClassName = "Game Window Class"; \\GIVES ME ERROR***********
window_class.lpfnWndProc = window_callback;
// Register Class
RegisterClass(&window_class);
// Create Window (GIVES ME ERROR)*****************************
HWND window = CreateWindow(window_class.lpszClassName, "My First Game!", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0);
while (running) {
// Input
MSG message;
while (PeekMessage(&message, window, 0, 0, PM_REMOVE)) {
TranslateMessage(&message);
DispatchMessage(&message);
}
// Simulate
// Render
}
}