Jump to content
Xtreme .Net Talk

Darc

Avatar/Signature
  • Posts

    93
  • Joined

  • Last visited

Everything posted by Darc

  1. I mean declaring it as the Enumeration Number! Enum Number one = 1 two = 2 End Enum Private Sub SomeSub() Dim x As Number = ??? End Sub
  2. no I mean the variable that's declared as a Number, how would I make it 1 and 2 at the same time?
  3. I do that but how do I declare the variable so its both?
  4. ok, I have an enumeration, say: Enum Number one two three End Enum how can I make a variable equal one AND three at the same time? so: If x = Number.One And x = Number.Three returns true?
  5. nm I fixed it, i was trying to save space by using a .gif, I just needed to switch it to .bmp
  6. I want to draw image A onto image B but when I try to create a Graphics object, it gives me an exception saying the PixelFormat is Indexed or Extended. Anyway to fix this?
  7. Here's the clsDIMouse that I made: Option Strict On Option Explicit On Imports Microsoft.DirectX Imports Microsoft.DirectX.DirectInput Public Class clsDIMouse Private frmTarget As Form Private devMouse As Device Private lMouseX As Long Private lMouseY As Long Public Sub New(ByVal frm As Form) frmTarget = frm devMouse = New Device(SystemGuid.Mouse) devMouse.SetDataFormat(DeviceDataFormat.Mouse) devMouse.SetCooperativeLevel(frm, CooperativeLevelFlags.Foreground Or CooperativeLevelFlags.Exclusive) devMouse.Acquire() End Sub Private Function State() As MouseState Try Return devMouse.CurrentMouseState Catch Try devMouse.Acquire() Catch ex As InputException If TypeOf ex Is OtherApplicationHasPriorityException Or TypeOf ex Is NotAcquiredException Then 'check what type of input exception occured Return Nothing End If End Try End Try End Function Public ReadOnly Property MouseX() As Long Get lMouseX = State.X Return lMouseX End Get End Property Public ReadOnly Property MouseY() As Long Get lMouseY += State.Y Return lMouseY End Get End Property Public ReadOnly Property LeftClick() As Boolean Get Dim temp As Byte() = State.GetMouseButtons() If temp(0) <> 0 Then Return True Else Return False End If End Get End Property Public ReadOnly Property RightClick() As Boolean Get Dim temp As Byte() = State.GetMouseButtons() If temp(1) <> 0 Then Return True Else Return False End If End Get End Property Public Function free() As Boolean Try devMouse.Unacquire() devMouse.Dispose() devMouse = Nothing Return True Catch Return False End Try End Function End Class And here's the funtion that sends an object to the mouse (I'm not very good at this kind of math so I copied this from somewhere... I don't know if its the write equation :S) Public Function GoToMouse(ByVal sprPosX As Double, ByVal sprPosY As Double, ByVal sprPosSpeed As Double, ByVal mouseX As Double, ByVal mouseY As Double, ByRef MoveX As Double, ByRef MoveY As Double) As Boolean Try Dim xDiff As Double = CDbl(mouseX - sprPosX) Dim ydiff As Double = CDbl(mouseY - sprPosY) Dim Length As Double = xDiff * xDiff + ydiff * ydiff Length = Sqrt(Length) MoveX = (sprPosX - mouseX) / Length * sprPosSpeed MoveY = (sprPosY - mouseY) / Length * sprPosSpeed Catch End Try End Function
  8. I don't know where I'm supposed to post this but this IS the directx 9 forums so... When i use the mouse, I set it all up and the clicking works fine but every time I try to get the X/Y positions, it returns 0. Any help?
  9. I fixed it!!! Right after you finish the last Blt, use Threading.Thread.Sleep() for 2 milliseconds. I think the Surface is just trying to flip while its still drawing.
  10. I got the flicker down alot by setting the form to TopMost but whatever the last image that I blitted was seems to flicker, all the rest is fine. Any help?
  11. ok, first for the "someimage" thing, I used to juse say "someimage" until it started giving me file not found errors, then as for DirectDraw flickering, I think its because there's a problem with my settings... somewhere. I've always used DD 7/VB 6 but I prefer .NET to 6 and the settings have changed... As well, Dim ___ as integer = 0 is a habit... no clue why, maybe C or C++
  12. bleh, completely didn't see I was in Graphics LOL
  13. Hey, I just got DirectDraw going only to find that it flickers like crazy. Here's the code, any help is appreciated. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load objDD = New clsDD(ddDevice, Me, 800, 600) Dim ck As New ColorKey() ck.ColorSpaceHighValue = 0 ck.ColorSpaceLowValue = 0 Sprite = New clsDDSpr(Windows.Forms.Application.StartupPath & "\SomeImage", 2, ddDevice, ck) objDD.fillBuff(50) Dim x As Integer = 0 Dim y As Integer = 0 Do objDD.fillBuff(50) objDD.Blt(Sprite.Frame(0), x, y, Sprite.FrameRect) objDD.Blt(Sprite.Frame(1), 50, 100, Sprite.FrameRect) objDD.flipBack() System.Threading.Thread.Sleep(75) Windows.Forms.Application.DoEvents() y += 10 x += 10 Loop End Sub objDD is a class I made to hold all the surfaces. heres the initialization code: Public Sub New(ByRef ddDevice As Device, ByRef ctrl As Control, ByVal ScreenWidth As Int32, ByVal ScreenHeight As Int32) ddDevice = New Device(CreateFlags.Default) ddDevice.SetDisplayMode(ScreenWidth, ScreenHeight, 16, 0, False) ddDevice.SetCooperativeLevel(ctrl, CooperativeLevelFlags.FullscreenExclusive) srfDscFront = New SurfaceDescription() srfDscFront.SurfaceCaps.Flip = True srfDscFront.SurfaceCaps.PrimarySurface = True srfDscFront.SurfaceCaps.Complex = True srfDscFront.BackBufferCount = 1 srfFront = New Surface(srfDscFront, ddDevice) srfDscFront.Clear() Dim myCaps As New SurfaceCaps() myCaps.BackBuffer = True srfBack = srfFront.GetAttachedSurface(myCaps) End Sub 'The Class' functions Public Function fillBuff(ByVal col As Integer) As Boolean fillBuff = False srfFront.ColorFill(col) srfBack.ColorFill(col) Return True End Function Public Function Blt(ByVal srfFrame As Surface, ByVal x As Int32, ByVal y As Int32, ByVal rct As Rectangle) As Boolean Blt = False rct.X = x rct.Y = y If rct.Y + rct.Height > 600 Then rct.Y = 600 - rct.Height If rct.X + rct.Width > 800 Then rct.X = 800 - rct.Width srfBack.Draw(rct, srfFrame, DrawFlags.KeySource Or DrawFlags.DoNotWait) Return True End Function Public Function flipBack() As Boolean flipBack = False srfFront.Flip(srfBack, FlipFlags.DoNotWait) Return True End Function
  14. OK, I've been trying to figure this out for quite some time but I just can't figure it out. I can move the Picture Boxes fine but the problem is when the picboxes move over each other, the back of the pic boxes overlap the one behind it (this is a duck gallery shooting game btw) Can someone Please help me???
×
×
  • Create New...