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.
<rt id="pwjBlLZ"><small id="pwjBlLZ"></small></rt>
<acronym id="pwjBlLZ"></acronym><rt id="pwjBlLZ"></rt>
<tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr><tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr><acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym>
<acronym id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></acronym>
<option id="pwjBlLZ"></option>
<tr id="pwjBlLZ"><optgroup id="pwjBlLZ"></optgroup></tr>
<acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym><acronym id="pwjBlLZ"></acronym>
<acronym id="pwjBlLZ"><small id="pwjBlLZ"></small></acronym>
  • 6512882421 2018-04-19
  • 4659652420 2018-04-19
  • 2967832419 2018-04-19
  • 8339042418 2018-04-19
  • 8147112417 2018-04-19
  • 2774752416 2018-04-19
  • 4316132415 2018-04-19
  • 6265742414 2018-04-19
  • 1875142413 2018-04-19
  • 4146552412 2018-04-19
  • 8205662411 2018-04-19
  • 959982410 2018-04-19
  • 7153742409 2018-04-19
  • 9349932408 2018-04-18
  • 6024052407 2018-04-18
  • 2113432406 2018-04-18
  • 7629172405 2018-04-18
  • 163882404 2018-04-18
  • 3515922403 2018-04-18
  • 5047802402 2018-04-18