Trooper | Okay, heres my code. What I"m trying to do is just get the image to move around the screen with the arrow keys...
I"m using Visual Basic.net 2003 FYI
[code]
Option Explicit On
Imports DaBoodaTurbo2DEngine
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(1016, 752)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Dim Engine As New DBTurbo2DEngine
Dim BLooping As Boolean
Dim Angle As Single
Dim sSize As Single
Dim imgX As Integer = 400
Dim imgY As Integer = 300
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Show()
System.Windows.Forms.Application.DoEvents()
Engine = New DBTurbo2DEngine
Engine.InitializeDisplay(Me.Handle.ToInt32, True, 800, 600, 0, 1)
Engine.SetUpMapView(0, 0, 800, 600, 0)
Engine.DBFPS.SetFrameRate(60)
Engine.SetMaxLevel(1)
'Sets the background colors
With Engine
.SetBackColorBlue(0)
.SetBackColorGreen(0)
.SetBackColorRed(0)
End With
With Engine.DBTexture
.SetFolder("c:\")
.Add(256, "Ball", , 2)
End With
With Engine.DBOverlay
.Add()
.SetTextureReference(1, 1)
.SetVisible(1, True)
.QMSetGetRectangle(1, 0, 0, 256, 256)
.QMSetPutRectangle(1, -123, -123, 256, 256)
.SetXPosition(1, 400)
.SetYPosition(1, 300)
.ULSetColor(1, 255, 0, 0)
.URSetColor(1, 0, 255, 0)
.LLSetColor(1, 255, 255, 255)
.LRSetColor(1, 0, 0, 255)
End With
With Engine.DBText
.CreateFont("timenewroman", 16)
.Add()
.SetVisible(1, True)
.SetText(1, "FPS - ")
.QMSetPutRectangle(1, 0, 0, 100, 30)
End With
With Engine.DBKeyInput
.Initialize(Me.Handle.ToInt32)
.Add(DxVBLibA.CONST_DIKEYFLAGS.DIK_UP)
.Add(DxVBLibA.CONST_DIKEYFLAGS.DIK_DOWN)
.Add(DxVBLibA.CONST_DIKEYFLAGS.DIK_LEFT)
.Add(DxVBLibA.CONST_DIKEYFLAGS.DIK_RIGHT)
.Add(DxVBLibA.CONST_DIKEYFLAGS.DIK_ESCAPE)
.SetAutoFire(1, True)
.SetAutoFire(2, True)
.SetAutoFire(3, True)
.SetAutoFire(4, True)
End With
Angle = 0 : sSize = 128 : BLooping = True
'Main loop
Do While BLooping = True
'Check keys
With Engine
'Poll keyboard
'.DBKeyInput.PollKeyBoard()
'check up
If .DBKeyInput.ReturnKeyDown(1) = True Then
imgX = imgX - 5
Engine.DBMath.SpriteAngleIncrementUp(1, 5)
End If
'check(down)
If .DBKeyInput.ReturnKeyDown(2) = True And sSize <> 2 Then
imgX = imgX - 5
Engine.DBMath.SpriteAngleIncrementDown(1, 5)
End If
'check(Left)
If .DBKeyInput.ReturnKeyDown(3) = True Then
imgY = imgY - 5
Engine.DBMath.SpriteAngleIncrementLeft(1, 5)
End If
'check right
If .DBKeyInput.ReturnKeyDown(4) = True Then
imgY = imgY + 5
Engine.DBMath.SpriteAngleIncrementRight(1, 5)
End If
'Check(escape)
If .DBKeyInput.ReturnKeyDown(5) = True Then
BLooping = False
End If
End With
'This is redundant
'System.Windows.Forms.Application.DoEvents()
'Update the FPS Text
Engine.DBText.SetText(1, "FPS - " & Format(Engine.DBFPS.GetFPS, "000"))
Engine.Render()
Loop
'Destroy DBTurbo2DTurbo object
'UPGRADE_NOTE: Object Engine may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
End Sub
Private Sub Form_Unload(ByVal Cancel As Integer)
'If loop isn't ended
If BLooping = True Then
Cancel = 1 'Cancel the termination of the app
Engine = Nothing
BLooping = False 'End the loop at first given chance
End If
End Sub
End Class
[/code] |