Results 1 to 12 of 12
  1. #1
    CAFlames's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Where ever my imagination takes me
    Posts
    3,006
    Reputation
    202
    Thanks
    2,944
    My Mood
    Twisted

    CAFlames Simple Crosshairs

    Hey, so this is basically a code for much simpler crosshairs...

    In Globals:

    Code:
    ID3DXLine *pLine;

    My Crosshair Function:

    Code:
    void CrossHair   ( DWORD Size, D3DCOLOR Color )
    {   
        D3DXVECTOR2 vLine[ 5 ]; //# of points
        pLine->SetAntialias( 0 );
     
        pLine->SetWidth( 1 ); // 1 Pixel width for XHair
        pLine->Begin();
     
            vLine[ 0 ][ 0 ] = GetSystemMetrics( 0 ) / 2 - Size;
            vLine[ 0 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
            vLine[ 1 ][ 0 ] = GetSystemMetrics( 0 ) / 2 + Size;
            vLine[ 1 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
    		vLine[ 2 ][ 0 ] = GetSystemMetrics( 0 ) / 2;
            vLine[ 2 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
    		vLine[ 3 ][ 0 ] = GetSystemMetrics( 0 ) / 2; 
            vLine[ 3 ][ 1 ] = GetSystemMetrics( 1 ) / 2 + Size;
    		vLine[ 4 ][ 0 ] = GetSystemMetrics( 0 ) / 2; 
            vLine[ 4 ][ 1 ] = GetSystemMetrics( 1 ) / 2 - Size; //Drawing Crosshair
    
        pLine->Draw( vLine, 5, Color ); // Draw Line, # of points {(left to right, right to center, center to down, down to up) = 5}, Color
        pLine->End(); // finish
    }

    Then Create the line like a font (Creditz to kotentopf):
    Code:
    void SetLine(LPDIRECT3DDEVICE9 pDevice)
    {
    	if(pLine == NULL ){
    		D3DXCreateLine(pDevice,&pLine);
    	}else{
    
    	if (g_pDevice2 != pDevice)
    	{
    		g_pDevice2 = pDevice;
    		try
    		{
    			if (pLine != 0)
    				pLine->Release();
    
        } catch (...) {}
    	pLine = 0;
    	D3DXCreateLine(pDevice,&pLine);	}}
    }

    Then to Actually make the crosshairs:

    Code:
    CrossHair   ( Size, Color );
    The Size is how big the crosshairs are... i.e. how wide and tall it is.
    The color is just a D3DColor.

    Ex of my crosshairs:

    Code:
    CrossHair   ( 15, Red );
    Thanks guys.
    Last edited by CAFlames; 03-08-2011 at 06:46 PM.

    Current Works:
    ---Horror Game





    [IMG]https://i645.photobucke*****m/albums/uu180/drgnforce9/Siggys/signature3.jpg[/IMG]
    Special thanks to drgnforce9 for my sig picture

    Quote Originally Posted by m_t_h View Post

    CAflames is one epic coder.

    Rep and thanks him.. or you're perma banned.

  2. The Following User Says Thank You to CAFlames For This Useful Post:

    Strikex (03-09-2011)

  3. #2
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Quote Originally Posted by CAFlames View Post
    Hey, so this is basically a code for much simpler crosshairs...

    In Globals:

    Code:
    ID3DXLine *pLine;

    My Crosshair Function:

    Code:
    void CrossHair   ( DWORD Size, D3DCOLOR Color )
    {   
        D3DXVECTOR2 vLine[ 5 ]; //# of points
        pLine->SetAntialias( 0 );
     
        pLine->SetWidth( 1 ); // 1 Pixel width for XHair
        pLine->Begin();
     
            vLine[ 0 ][ 0 ] = GetSystemMetrics( 0 ) / 2 - Size;
            vLine[ 0 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
            vLine[ 1 ][ 0 ] = GetSystemMetrics( 0 ) / 2 + Size;
            vLine[ 1 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
    		vLine[ 2 ][ 0 ] = GetSystemMetrics( 0 ) / 2;
            vLine[ 2 ][ 1 ] = GetSystemMetrics( 1 ) / 2;
    		vLine[ 3 ][ 0 ] = GetSystemMetrics( 0 ) / 2; 
            vLine[ 3 ][ 1 ] = GetSystemMetrics( 1 ) / 2 + Size;
    		vLine[ 4 ][ 0 ] = GetSystemMetrics( 0 ) / 2; 
            vLine[ 4 ][ 1 ] = GetSystemMetrics( 1 ) / 2 - Size; //Drawing Crosshair
    
        pLine->Draw( vLine, 5, Color ); // Draw Line, # of points {(left to right, right to center, center to down, down to up) = 5}, Color
        pLine->End(); // finish
    }

    Then Create the line with your font (After if(Directx.pFont == NULL)) :
    Code:
    D3DXCreateLine(pDevice,&pLine);

    Then to Actually make the crosshairs:

    Code:
    CrossHair   ( Size, Color );
    The Size is how big the crosshairs are... i.e. how wide and tall it is.
    The color is just a D3DColor.

    Ex of my crosshairs:

    Code:
    CrossHair   ( 15, Red );
    Thanks guys.
    when u call everytime at the present/endscene loop D3DXCreateLine, u create a "RAM-killer", create it like the font
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  4. #3
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,423
    Reputation
    112
    Thanks
    693
    Good release. Common D3D knowledge though :/

  5. #4
    Threadstarter
    We are the CONTRIBUFORCE
    MPGH Member
    CAFlames's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Where ever my imagination takes me
    Posts
    3,006
    Reputation
    202
    Thanks
    2,944
    My Mood
    Twisted
    Quote Originally Posted by kotentopf View Post
    when u call everytime at the present/endscene loop D3DXCreateLine, u create a "RAM-killer", create it like the font
    @kotentopf
    And what would be the best way of doing that?

    @Zane Slayman
    This is for those that dont want to figure out hieghts, widths, placements and stuff... so all you have t put is size and color
    Last edited by CAFlames; 03-08-2011 at 02:22 PM.

    Current Works:
    ---Horror Game





    [IMG]https://i645.photobucke*****m/albums/uu180/drgnforce9/Siggys/signature3.jpg[/IMG]
    Special thanks to drgnforce9 for my sig picture

    Quote Originally Posted by m_t_h View Post

    CAflames is one epic coder.

    Rep and thanks him.. or you're perma banned.

  6. #5
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Quote Originally Posted by CAFlames View Post

    @kotentopf
    And what would be the best way of doing that?

    [Highlight=c++]
    bool bCreateLine;

    if ( !bCreateLine)
    {
    //Create yo line nigga
    bCreateLine = true;
    }
    [/Highlight]

  7. #6
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Quote Originally Posted by whit View Post



    [Highlight=c++]
    bool bCreateLine;

    if ( !bCreateLine)
    {
    //Create yo line nigga
    bCreateLine = true;
    }
    [/Highlight]
    Code:
    void c3DMisc::SetLine(LPDIRECT3DDEVICE9 pDevice)
    {
    	if( D3D.Settings.pLine == NULL ){
    		D3DXCreateLine(pDevice,&D3D.Settings.pLine);
    	}else{
    
    	if (g_pDevice2 != pDevice)
    	{
    		g_pDevice2 = pDevice;
    		try
    		{
    			if (D3D.Settings.pLine != 0)
    				D3D.Settings.pLine->Release();
    
        } catch (...) {}
    	D3D.Settings.pLine = 0;
    	D3DXCreateLine(pDevice,&D3D.Settings.pLine);	}}
    }
    how i said it, create it like font
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  8. #7
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Quote Originally Posted by kotentopf View Post
    how i said it, create it like font
    / ...........

  9. #8
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Quote Originally Posted by whit View Post


    / ...........
    i also create my Textures and sprites on this way
    u can do it with all what needs to be created with a Direct3DDevice
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  10. #9
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Quote Originally Posted by kotentopf View Post
    i also create my Textures and sprites on this way
    u can do it with all what needs to be created with a Direct3DDevice
    Thats how i recreate my font
    I think its mmbob's method

  11. #10
    Stephen's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Engine.exe
    Posts
    4,689
    Reputation
    184
    Thanks
    1,149
    My Mood
    Aggressive
    Quote Originally Posted by whit View Post


    Thats how i recreate my font
    I think its mmbob's method
    mmbob4life.

  12. #11
    Strikex's Avatar
    Join Date
    Dec 2010
    Gender
    male
    Posts
    1,311
    Reputation
    9
    Thanks
    355
    My Mood
    Relaxed
    nice release,
    I will test to see if it will work on CABR

  13. #12
    Threadstarter
    We are the CONTRIBUFORCE
    MPGH Member
    CAFlames's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Where ever my imagination takes me
    Posts
    3,006
    Reputation
    202
    Thanks
    2,944
    My Mood
    Twisted
    Quote Originally Posted by Xpeeh View Post
    nice release,
    I will test to see if it will work on CABR
    It does. Press thanks when you test.

    Current Works:
    ---Horror Game





    [IMG]https://i645.photobucke*****m/albums/uu180/drgnforce9/Siggys/signature3.jpg[/IMG]
    Special thanks to drgnforce9 for my sig picture

    Quote Originally Posted by m_t_h View Post

    CAflames is one epic coder.

    Rep and thanks him.. or you're perma banned.