Adam's Laboratory - 1 - Experiments in DirectX Sprite Creation, and animation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Adam's Laboratory - 1 - Experiments in DirectX Sprite Creation, and animation

  1. #1
    Join Date
    Jan 2011
    Posts
    3

    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...

  2. #2
    Join Date
    Jan 2011
    Posts
    3

    Adams lab - Details.

    ADAMS LABORATORY

    Experiments in DirectX Sprite Creation, and animation



    This is the beginning of my personal experiments in directx programming. I hope to take what I learn from these forums and edit this initial post into a Tutorial. The benefits of this will be newcomers will be able to see the processes that have gone into me personally learning directx
    but more importantly the problems/errors that arise during the making of a simple 2D game. My intent for now is sprite creation/animation, but eventually I may move into A* Pathfinding...

    If they prove a hit, I will delve into other aspects related to directx Programming, possibly making a series of 'Adam's laboratory' posts.

    "Software I a Using: " :
    I use an IDE called 'NetBeans' to make my C++ programs out of habit, although I intend to shift to eclipse IDE soon, Oh, and am compiling with Cygwin. My operating system is Windows XP.

  3. #3
    Join Date
    Jan 2011
    Posts
    3

    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.

    Code:
    #include <d3dx9.h>
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center