hey I just started learning win API via an online tutorial. Just so I actually learned what I was reading I figured I would play with the code and try to make a snake game adding different features as I went through each lesson. The tutorial says to put the WM_PAINT definition in the WindowProcedure function as a case. I did this and it draws the picture fine. I noticed the bitblt() function had the x and y parameterss of where the item is drawn so I replaced them with code from my class.
Code:
BitBlt(hdc, MySnake.GetSnakeX(), MySnake.GetSnakeY(), bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
Then I added cases in the WM_KEYDOWN section such as MySnake.SnakeMoveUp() when up is pressed. I did not use any velocities yet as I was just testing moving the image. So if you key up then the snake's Y int is reduced to give a smaller coordinate next time the MySnake.GetSnakeY() function is called. Well the picture never moved.
I used message boxes inside my code to make sure the proper keys were working such as "you pressed up!" When the key is pressed. I tried putting a post message function thinking maybe WM_PAINT did not update unless told. That did not work so I googled WM_PAINT and read that it was called anytime you update the window. So I added UpdateWindow(hwnd). That did not work. I think I am missing something conceptually about the paint feature. Any ideas?
Ps sorry I did not put much code in but I don't have internet where I am coding so I am using a phone to post this.