|
-
Jan 2nd, 2003, 04:54 PM
#1
Thread Starter
Hyperactive Member
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?
-
Jan 3rd, 2003, 04:32 AM
#2
-
Jan 3rd, 2003, 09:47 AM
#3
Addicted Member
Normally you have all the angles of the ship in a bitmap and blit that part of the bitmap
-
Jan 3rd, 2003, 02:57 PM
#4
Thread Starter
Hyperactive Member
??
Know any program that can generate all those angles?
-
Jan 4th, 2003, 03:01 AM
#5
Member
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 !
-
Jan 4th, 2003, 03:19 PM
#6
Good Ol' Platypus
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)
-
Jan 4th, 2003, 03:31 PM
#7
Ex-Super Mod'rater
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.

-
Jan 4th, 2003, 05:56 PM
#8
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...
-
Jan 5th, 2003, 09:03 AM
#9
Addicted Member
Re: ??
Originally posted by VBD
Know any program that can generate all those angles?
Paint Shop Pro would work just fine.
-
Jan 5th, 2003, 09:06 AM
#10
BTW here is the code for the module to rotate the sprite in VB using DDraw....
VB Code:
Option Explicit
Public Const PI As Double = 3.14159265358979
Public carwidth As Integer, carheight As Integer
Public Sub RotateSurface(ByRef surfSource As DirectDrawSurface7, surfDestination As DirectDrawSurface7, lngAngle As Long, XDest As Long, Ydest As Long)
Dim ddsdOrigine As DDSURFACEDESC2, ddsdDestination As DDSURFACEDESC2
Dim iX As Long, iY As Long
Dim iXDest As Long, iYDest As Long
Dim rEmpty As RECT, rEmpty2 As RECT
Dim sngA As Single, SinA As Single, CosA As Single
Dim dblRMax As Long
Dim lngXO As Long, lngYO As Long
Dim lngColor As Long
Dim lWidth As Long, lHeight As Long
sngA = lngAngle * PI / 180
SinA = Sin(sngA)
CosA = Cos(sngA)
surfSource.GetSurfaceDesc ddsdOrigine
lWidth = ddsdOrigine.lWidth
lHeight = ddsdOrigine.lHeight
dblRMax = Sqr(lWidth ^ 2 + lHeight ^ 2)
surfSource.Lock rEmpty, ddsdOrigine, DDLOCK_WAIT, 0
surfDestination.GetSurfaceDesc ddsdDestination
surfDestination.Lock rEmpty2, ddsdDestination, DDLOCK_WAIT, 0
XDest = XDest + lWidth / 2
Ydest = Ydest + lHeight / 2
For iX = -dblRMax To dblRMax
For iY = -dblRMax To dblRMax
lngXO = lWidth / 2 - (iX * CosA + iY * SinA)
lngYO = lHeight / 2 - (iX * SinA - iY * CosA)
If lngXO >= 0 Then
If lngYO >= 0 Then
If lngXO < lWidth Then
If lngYO < lHeight Then
lngColor = surfSource.GetLockedPixel(lngXO, lngYO)
If lngColor <> 0 Then
surfDestination.SetLockedPixel XDest + iX, Ydest + iY, lngColor
End If
End If
End If
End If
End If
Next iY
Next iX
surfSource.Unlock rEmpty
surfDestination.Unlock rEmpty2
carwidth = lWidth / 2 - (iX * CosA + iY * SinA)
carheight = lHeight / 2 - (iX * SinA - iY * CosA)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|