Visual Studio 2017 and Windows Programming

I just ordered a book "Beginning Game Programming" by Michael Morrison. I really like the projects(http://www.pickinpatchfarm.com/store/beginning-game-programming-9780672326592 -> Downloads -> "Examples developed for the book with examples for Borland C++ Compiler, Dev-CPP Compiler, and Visual C++ Compiler").


I would like to create a window but do not know how to do yet after reading Appendix C(http://www.pickinpatchfarm.com/store/beginning-game-programming-9780672326592 -> Downloads -> "Bonus Appendixes A through D in Adobe's Portable Document Format (PDF)")

I am wondering if anyone has any comments about this book or about the projects. I am beginner C/C++.

Thanks
I still got a copy of the book and I think it's a good start learning games under Windows.
I am not sure what you want to do.
Normally the book is about games not about windows.
In the book he will create a Game Engine that will take care of the details of windows creation. Probably best to wait for the book to arrive.
Thanks for feedback. I am excited to read "Beginning Game Programming" by Michael Morrison. I hope it is as good as "C++ Primer Plus" by Stephen Prata.

I got the Skeleton window to show up. I created a console application instead of a desktop application. The window creates using the desktop application.

Last edited on
Thomas1965, were you able to complete the Blizzard Extreme Game Makeover?
1
2
3
Modify the Blizzard.ico and Blizzard_sm.ico to a completely different theme, such as a fireball.
Add a POINT global variable to the program that is used to “remember” the position of the fireball; this position can initially be randomly calculated.
Each time through the GameCycle() function, alter the position of the fireball so that it appears to move in a particular direction over time.
I have an older version of the book so I didn't, but I think it can be done like this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void GameCycle()
{
  static POINT ptFireBall = { 10, 10}; // set any starting point you want
  HWND hWindow = g_pGame->GetWindow();
  HDC   hDC = GetDC(hWindow);
  RECT rcClient;

  GetClientRect(g_pGame->GetWindow(), &rcClient); // Get drawing area
  FillRect(hDC, &rcClient, (HBRUSH)GetBkColor(hDC)); // clear window

  DrawIcon(hDC, ptFireBall.x, ptFireBall.y, (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));
  
  // move position of fireball
  ptFireBall.x += 2;
  ptFireBall.y += 2;

  ReleaseDC(hWindow, hDC);
}
I tried adding a do while loop but it does not seem to have any effect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void GameCycle()
{
	static POINT ptFireBall = { 10, 10 }; // set any starting point you want
	HWND hWindow = g_pGame->GetWindow();
	HDC   hDC = GetDC(hWindow);
	int count = 0;

	do
	{
	        DrawIcon(hDC, ptFireBall.x, ptFireBall.y, (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));
	} while (count > 10 && count < 20);

	// move position of fireball
	ptFireBall.x += 2;
	ptFireBall.y += 2;
	count = count + 1;

	ReleaseDC(hWindow, hDC);
}
Last edited on
You need to update the position inside the loop otherwise you will always draw it at the same position and you wont see an effect.
I'm trying to make the fireball move only for a certain period of time @ 1 frame per second. So frames 10 through 20 should show a fireball moving. Instead, I am getting a blank white screen with no action.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void GameCycle()
{
	static POINT ptFireBall = { 10, 10 }; // set any starting point you want
	HWND hWindow = g_pGame->GetWindow();
	HDC   hDC = GetDC(hWindow);
	int count = 0;

	if (count > 9 && count < 21)
	{
		DrawIcon(hDC, ptFireBall.x, ptFireBall.y, (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));

		// move position of fireball
		ptFireBall.x += 2;
		ptFireBall.y += 2;
	}
        count = count + 1;
	ReleaseDC(hWindow, hDC);
}


Last edited on
You need a frame counter and check if the count is between 10 and 20 like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void GameCycle()
{
  static POINT ptFireBall = { 10, 10}; // set any starting point you want
  static int iFrameCount = 0;
  HWND hWindow = g_pGame->GetWindow();
  HDC   hDC = GetDC(hWindow);
  RECT rcClient;

  iFrameCount++;
  if (iFrameCount >= 10 && iFrameCount <= 20)
  {
    GetClientRect(g_pGame->GetWindow(), &rcClient); // Get drawing area
    FillRect(hDC, &rcClient, (HBRUSH)GetBkColor(hDC)); // clear window

    DrawIcon(hDC, ptFireBall.x, ptFireBall.y, (HICON)(WORD)GetClassLong(hWindow, GCL_HICON));
  
    // move position of fireball
    ptFireBall.x += 2;
    ptFireBall.y += 2;

    ReleaseDC(hWindow, hDC);
  }
}
For a very basic introduction to both Windows and Game programming the book is good, though out-dated.
Registered users can post here. Sign in or register to post.
<acronym id="pwjBlLZ"></acronym>
<object id="pwjBlLZ"><div id="pwjBlLZ"></div></object>
<sup id="pwjBlLZ"></sup>
<acronym id="pwjBlLZ"><center id="pwjBlLZ"></center></acronym>
  • 6809961597 2018-02-24
  • 671871596 2018-02-24
  • 7107821595 2018-02-24
  • 9407391594 2018-02-24
  • 6234261593 2018-02-24
  • 1793521592 2018-02-23
  • 2864591591 2018-02-23
  • 6167231590 2018-02-23
  • 3669201589 2018-02-23
  • 7946381588 2018-02-23
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22