Adam's Laboratory - 1 - Experiments in DirectX Sprite Creation, and animation
ADAMS LABORATORY
Experiments in DirectX Sprite Creation, and animation
This first post is an empty post, Watch this space for a progressive tutorial on Experiments in directX.
Read below for more details...
Re: Adam's Laboratory - 1 - Experiments in DirectX Sprite Creation, and animation
Lets start where the program starts shall we. (Okay, not with them main() function but you know what i mean!)
The first library I'm delving into is the collective library of directx 9.0.
The next part defines a rectangle for us to contain a sprite in.
Code:
int main()
{
// Sprite is 64x64 in size
RECT drawRect;
drawRect.left = 0;
drawRect.right = 64; // Width
drawRect.top = 0;
drawRect.bottom = 64; // Height
Not much more can be said at this point about the RECT. So- moving on- we are defining some vectors in a cartesian space. (For those of you not familiar with the term, don't worry too much. it simply means an (x,y) co-ordinate system)
Code:
int main()
{
// Sprite is 64x64 in size
RECT drawRect;
drawRect.left = 0;
drawRect.right = 64; // Width
drawRect.top = 0;
drawRect.bottom = 64; // Height
D3DXVECTOR2 scale( 1.0f/64.0f, 1.0f/64.0f ); // Scale the sprite down to size of 1 local to the screen
D3DXVECTOR2 scale2( 800.0f, 600.0f ); // I want the sprite to cover the whole screen for my background image
D3DXVECTOR2 scale3;
Scaling deals with the magnitude(or size) of what we are manipulating here, which is a vector in our game space (Think of it like the position it will occupy on the screen)
Code:
int main()
{
// Sprite is 64x64 in size
RECT drawRect;
drawRect.left = 0;
drawRect.right = 64; // Width
drawRect.top = 0;
drawRect.bottom = 64; // Height
D3DXVECTOR2 scale( 1.0f/64.0f, 1.0f/64.0f ); // Scale the sprite down to size of 1 local to the screen
D3DXVECTOR2 scale2( 800.0f, 600.0f ); // I want the sprite to cover the whole screen for my background image
D3DXVECTOR2 scale3;
// Multiply the two scale vector objects to scale it to fit the screen
scale3.x = scale.x * scale2.x;
scale3.y = scale.y * scale2.y;
//EDIT - This will be continued tomorrow, as I am heading to bed now (1.30am GMT heh) but feel free to post on what I have so far, which is gleamed from various sources online)