1) Create a square texture - just black, covering the entire scene, but having a slit through which would be seen that part of the scene.
Using Photoshop create image 10241024 pixels
Fill with black
Determine the size 800600 of our app window
I showed it in purple -
In the post purple black square 400400 pixels - this will slit
Everything else fill it with white color
This layer use as an alpha mask
Ie. All that white - it is opaque, black - transparent.
Save this file as tga.
2) Restrict the movement of the scene - because if it will move freely from edge to edge of the screen, the square with a slot does not help.
For this purpose, the module start.cpp in method -
CD3DGameApp::ChangeGameCursorPos
Change code -
LONG cursor_spr_left_limit = 218;//0;
LONG cursor_spr_top_limit = 200;//0;
LONG cursor_spr_right_limit = 587;//(LONG)m_dwScreenWidth;
LONG cursor_spr_bottom_limit = 367;//(LONG)m_dwScreenHeight;
Another course in module game_sprite.h you need to add code to load texture with frame.
To do this, add the following code to -
#define SpriteTexIndex 0 //after a string which must be added
#define FrameTexIndex 1 //is a string that must be added
void Anim(); //after a string which must be added
void DrawFrameTex(); //is a string that must be added
In module game_sprite.cpp add implementation described method DrawFrameTex
At the very end of the module add the following code -
void CGameSprite::DrawFrameTex()
{
if ( m_pSprite == NULL )
return;
In this case, the ball has to be overlap black border if you come beyond it. But we'll leave it until it is. Also, in analogy with scene movement limitation, we can limit the movement of the ball.
Next you will learn how to simulate the fall of the ball in the hole and how to hide the upper part of the hole when the ball is not entirely hit the hole to ensure the correct output of the situation visually.
I decided to slightly elevate the look of our game and replaced on a black background more interesting - the game began to look more attractive.