Results 1 to 10 of 10

Thread: DirectDraw Help [Unresolved]

  1. #1

    Thread Starter
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278

    DirectDraw Help [Unresolved]

    I need some help with DirectDraw. I am trying to make a game where you fly a spaceship around. Is their any function anywhere in DirectDraw/2D DirectX stuff that rotates a bmp?
    Hello

  2. #2
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    No you need to find a function that rotates the image for you
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Normally you have all the angles of the ship in a bitmap and blit that part of the bitmap

  4. #4

    Thread Starter
    Hyperactive Member VBD's Avatar
    Join Date
    Apr 2001
    Location
    The Place Above The Place Below Heavin
    Posts
    278

    ??

    Know any program that can generate all those angles?
    Hello

  5. #5
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    make ur own program
    use it as a tool.
    use getpixel, setpixel and basic trigonometry
    if u want this wrk to be done by some software, god save u

    ppl saw this
    Die, ***** Die !

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In Direct3D/Graphics, you can assign a texture to a quad and user-rotate the quad (if you're in non-Z mode). It's quite simple, I did it when I was first playing around with it. If you decide to switch to 3D, I can give you some code to get you on your way.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Are you using a 2D DirectDraw engine or are you doing that sort of stuff in your code? If your using a 2d engine and it doesn't let you rotate it'll be quite resourse hungry to do it seprate.
    Although if your doing DirectDraw stuff yourself you'll need to create Direct3D surfaces instead of normal directdraw surfaces, for ones that need to be rotated. You can uses Direct3D surfaces practically as if they normal 2D surfaces. Direct3D surfaces can only be in sizes like: 16*16, 32*32, 64*64,ect... Really fast with rotating tho.

    If you were using a 2D engine you could try my one coz it lets you use Direct3D surfaces, My Engine: http://www.electroman.co.uk/Electro2DE7.htm
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK.....look at PLANETSOURCECODE.COM try searching for GTA clone or something....it is an example on how to rotate a sprite in DDraw....I have tested it, but it is only half the speed of using a sprite with the rotation....but it is probably fast enough for small rotations...

  9. #9
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230

    Re: ??

    Originally posted by VBD
    Know any program that can generate all those angles?
    Paint Shop Pro would work just fine.

  10. #10
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    BTW here is the code for the module to rotate the sprite in VB using DDraw....

    VB Code:
    1. Option Explicit
    2.  
    3. Public Const PI As Double = 3.14159265358979
    4. Public carwidth As Integer, carheight As Integer
    5.  
    6. Public Sub RotateSurface(ByRef surfSource As DirectDrawSurface7, surfDestination As DirectDrawSurface7, lngAngle As Long, XDest As Long, Ydest As Long)
    7.  
    8.   Dim ddsdOrigine As DDSURFACEDESC2, ddsdDestination As DDSURFACEDESC2
    9.   Dim iX As Long, iY As Long
    10.   Dim iXDest As Long, iYDest As Long
    11.   Dim rEmpty As RECT, rEmpty2 As RECT
    12.   Dim sngA As Single, SinA As Single, CosA As Single
    13.   Dim dblRMax As Long
    14.   Dim lngXO As Long, lngYO As Long
    15.   Dim lngColor As Long
    16.   Dim lWidth As Long, lHeight As Long
    17.  
    18.     sngA = lngAngle * PI / 180
    19.     SinA = Sin(sngA)
    20.     CosA = Cos(sngA)
    21.  
    22.     surfSource.GetSurfaceDesc ddsdOrigine
    23.     lWidth = ddsdOrigine.lWidth
    24.     lHeight = ddsdOrigine.lHeight
    25.     dblRMax = Sqr(lWidth ^ 2 + lHeight ^ 2)
    26.     surfSource.Lock rEmpty, ddsdOrigine, DDLOCK_WAIT, 0
    27.     surfDestination.GetSurfaceDesc ddsdDestination
    28.     surfDestination.Lock rEmpty2, ddsdDestination, DDLOCK_WAIT, 0
    29.  
    30.     XDest = XDest + lWidth / 2
    31.     Ydest = Ydest + lHeight / 2
    32.     For iX = -dblRMax To dblRMax
    33.         For iY = -dblRMax To dblRMax
    34.             lngXO = lWidth / 2 - (iX * CosA + iY * SinA)
    35.             lngYO = lHeight / 2 - (iX * SinA - iY * CosA)
    36.             If lngXO >= 0 Then
    37.                 If lngYO >= 0 Then
    38.                     If lngXO < lWidth Then
    39.                         If lngYO < lHeight Then
    40.                             lngColor = surfSource.GetLockedPixel(lngXO, lngYO)
    41.                             If lngColor <> 0 Then
    42.                                 surfDestination.SetLockedPixel XDest + iX, Ydest + iY, lngColor
    43.                             End If
    44.                         End If
    45.                     End If
    46.                 End If
    47.             End If
    48.         Next iY
    49.     Next iX
    50.     surfSource.Unlock rEmpty
    51.     surfDestination.Unlock rEmpty2
    52.     carwidth = lWidth / 2 - (iX * CosA + iY * SinA)
    53.     carheight = lHeight / 2 - (iX * SinA - iY * CosA)
    54.  
    55. End Sub


    It's not my code, so don't give the credit to me...

Posting Permissions

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



Click Here to Expand Forum to Full Width