locked
Im new to programming and i need help RRS feed

  • Question

  •  

       Hi im new to programing and i've chosen vb 2005 as my first language. Im reading an rpg development book in vb 2005 express edition, so i reached a part of the book where i get errors, the code is this(the highlighted lines are the errors):

     

    Imports System.Drawing
    Imports Microsoft.DirectX
    Imports Microsoft.DirectX.Direct3D

    Public Class Form1

        ' define some useful constants
        Dim PATH As String = System.Environment.CurrentDirectory()
        Const SCREENW As Integer = 800
        Const SCREENH As Integer = 600
        Dim BLACK As Integer = RGB(0, 0, 0)

        ' Direct3D objects
        Dim device As Direct3D.Device
        Dim backbuffer As Direct3D.Surface
        Dim sprite_handler As Direct3D.Sprite

        ' create image from a Direct3D surface
        Dim ocean As Direct3D.Texture
        Dim pirateship As Direct3D.Texture


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' resize the form
            Me.Size = New Size(SCREENW, SCREENH)
            Me.Text = "Texture Loading Demo"
            Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)

            ' get the desktop display mode
            Dim adapterNumber As Integer = Manager.Adapters.Default.Adapter
            Dim mode As DisplayMode = Manager.Adapters.Default.CurrentDisplayMode

            ' set up the presentation parameters
            Dim params As New PresentParameters
            params.Windowed = True
            params.SwapEffect = SwapEffect.Copy
            params.AutoDepthStencilFormat = DepthFormat.D16
            params.EnableAutoDepthStencil = True
            params.MultiSample = MultiSampleType.None
            params.BackBufferCount = 1
            params.BackBufferWidth = SCREENW
            params.BackBufferHeight = SCREENH

            ' check video card capabilities
            Dim flags As CreateFlags
            flags = CreateFlags.HardwareVertexProcessing
            flags += CreateFlags.PureDevice

            ' create the Direct3D device
            device = New Device(adapterNumber, DeviceType.Hardware, Me, flags, params)

            ' get reference to the back buffer
            backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono)

            ' create the sprite handler
            sprite_handler = New Direct3D.Sprite(device)

            ' load the background as a texture
            ocean = TextureLoader.FromFile(device, "ocean.bmp")

            ' load the pirate ship
            pirateship = TextureLoader.FromFile(device, "pirateship.png")

        End Sub

        Sub draw_ocean()
            'demonstrate Direct3D.Sprite.Draw
            Dim rotation_center As New PointF(0, 0)
            Dim rotation_angle As Single = 0.0
            Dim position As New PointF(0, 0)
           

    sprite_handler.Draw2D(ocean, rotation_center, rotation_angle, position, Color.White)


            sprite_handler.Flush()
        End Sub

        Sub draw_ship()
            'demonstrate Direct3D.Sprite.Draw2D
            Dim rotation_center As New PointF(48, 48)
            Dim rotation_angle As Single = 0.0
            Dim position As New PointF(300, 200)
           

    sprite_handler.Draw2D(pirateship, rotation_center, rotation_angle, position, Color.White)


            sprite_handler.Flush()
        End Sub

        Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
            ' begin rendering
            device.BeginScene()

            ' clear the back buffer
            device.Clear(ClearFlags.Target + ClearFlags.ZBuffer, Color.Green, 1.0, 0)

            ' draw the sprites
            sprite_handler.Begin(SpriteFlags.AlphaBlend)
            draw_ocean()
            draw_ship()
            sprite_handler.End()

            ' stop rendering
            device.EndScene()

            ' copy back buffer to the screen
            device.Present()
        End Sub

        Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            ' check key code for ESC key
            If e.KeyCode = Keys.Escape Then

                ' destroy the Direct3D device
                device.Dispose()

                ' destroy the images
                ocean.Dispose()
                pirateship.Dispose()

                ' end the program
                End
            End If
        End Sub

    End Class

     

     

     

     

     

    so, some guy told me that if i use a microsoft.directx.direct3D reference less than version 1.0.2908.0 then the Draw2D function isnt implamented. My microsoft.directx.direct3D Reference version is  1.0.2902.0 how do i make it 1.0.2908.0?

     

    i yet do not understand the code, as i said im new to this stuff. I'd really appreciate it if you would help me, ill reward you with free copy of game engine code once im finished.

    Wednesday, December 5, 2007 2:30 AM

All replies