Hi!
I have a big problem. I have an Isometric Engine. My problem is that I dont know how to make that when I click on a tile, that then the Tile gets an other Texture. Can you help me?? I hope so. Thanks

Elessar


P.S. Here is my code of the Engine:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then arret = 1
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then arret = 1
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Droite = False: Gauche = False: Haut = False: Bas = False
If X > 600 Then Droite = True
If Y > 450 Then Bas = True
If X < 40 Then Gauche = True
If Y < 50 Then Haut = True

End Sub

Public DirectX As New DirectX7
Public DD As DirectDraw7
Public Primary As DirectDrawSurface7
Public Backbuffer As DirectDrawSurface7
Public Display As DirectDrawSurface7
Public Tile(50) As DirectDrawSurface7

Public T(50, 50) As Integer
Public xpos, ypos, arret

Public Gauche As Boolean, Droite As Boolean, Haut As Boolean, Bas As Boolean
Sub AfficheEcran(xa, ya) 'Display tiles (grass and paths)
On Error Resume Next
Backbuffer.BltColorFill DDRect(0, 400, 1024, 768), 0
Display.BltColorFill DDRect(0, 0, 1024, 768), 0
Display.SetFontTransparency True
Display.SetForeColor RGB(256, 256, 0)

For Y = -20 To 80
For X = 0 To 40
xd = (X * 31) - (Y * 31)
yd = (Y * 16) + (X * 16)
Display.BltFast xd, yd, Tile(T(X + xa, Y + ya + 10)), DDRect(0, 0, 63, 63), DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT
' " Display.DrawText xd, yd, CStr(X - 15 + xa) + " " + CStr(Y - 15 + ya), False


Next X
Next Y
'
' On a besoin de faire ça parce que si on blitte quelque chose avec une position x ou y négative
' ça ne marche pas. Donc c'est pour faire joli.
'
' You needs do this, because if you "blit" something with a negativ x or y position, it don't run.
'
Backbuffer.BltFast 0, 0, Display, DDRect(30, 30, 980, 700), DDBLTFAST_WAIT

Backbuffer.SetForeColor RGB(256, 0, 0)


End Sub

Function DDRect(X, Y, x1, y1) As RECT
DDRect.Bottom = y1
DDRect.Top = Y
DDRect.Left = X
DDRect.Right = x1
End Function

Sub Main()
Set DD = DirectX.DirectDrawCreate("")
DD.SetCooperativeLevel FS.hWnd, DDSCL_ALLOWREBOOT Or DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN
DD.SetDisplayMode 1024, 768, 16, 0, DDSDM_DEFAULT

Dim ddsd As DDSURFACEDESC2
ddsd.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddsd.lBackBufferCount = 1
ddsd.ddscaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE Or DDSCAPS_VIDEOMEMORY
Set Primary = DD.CreateSurface(ddsd)

Dim ddscaps As DDSCAPS2
ddscaps.lCaps = DDSCAPS_BACKBUFFER
Set Backbuffer = Primary.GetAttachedSurface(ddscaps)

Backbuffer.BltColorFill DDRect(0, 0, 1024, 768), 0
Dim ddsd2 As DDSURFACEDESC2
ddsd2.ddscaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
ddsd2.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
ddsd2.lWidth = 1024
ddsd2.lHeight = 768
Set Display = DD.CreateSurface(ddsd2)
Display.BltColorFill DDRect(0, 0, 1024, 768), 0
Dim ddr As DDSURFACEDESC2
Dim ddrec As RECT
ddrec.Bottom = 64
ddrec.Left = 0
ddrec.Right = 64
ddrec.Top = 0

Dim ck As DDCOLORKEY
ck.high = RGB(256, 256, 256)
ck.low = RGB(256, 256, 256)
For i = 1 To 6

Set Tile(i) = DD.CreateSurfaceFromFile(App.Path + "\tile" + CStr(i) + ".bmp", ddr)
Tile(i).SetColorKey DDCKEY_SRCBLT, ck

Next i
Randomize
'Fill the area with the filedata.
Open App.Path + "\iso.dat" For Input As 1
For Y = 1 To 50
Line Input #1, li$
For X = 1 To 50
T(X, Y) = Val(Mid(li$, X, 1))
Next X
Next Y

AfficheEcran 0, 0

' Boucle / looping
ok% = 1
Do
DoEvents
AfficheEcran xpos, ypos
If ok% = 0 Then

If Gauche = True Then
ok% = 1: xpos = xpos - 1
End If
If Droite = True Then
ok% = 1: xpos = xpos + 1
End If
If Haut = True Then
ok% = 1: ypos = ypos - 1
End If
If Bas = True Then
ok% = 1: ypos = ypos + 1
End If

End If
If anc + 50 < DirectX.TickCount Then
ok% = 0
anc = DirectX.TickCount
End If

Primary.Flip Nothing, DDFLIP_WAIT
Loop Until arret = 1

Set Primary = Nothing
Set Backbuffer = Nothing
Set DD = Nothing
Set DirectX = Nothing
End
End Sub