Print Page | Close Window

Multi-Tile Select In Mapeditor

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=226
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Multi-Tile Select In Mapeditor
Posted By: Sync
Subject: Multi-Tile Select In Mapeditor
Date Posted: 11 February 2006 at 3:40pm
Difficulty Medium 3/5
This tutorial will allow you to select more tiles then just one in the mapeditor and lay them all down.

In the mapeditor make a shape called shpSelected and make the width/height 32 each and make the bordercolor red and make the top/left 0.
Make sure you make it inside picBackSelect.

In the form code at the very top add:
Dim KeyShift As Boolean

Now add these somewhere in there:
Private Sub picBackSelect_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyShift Then
        KeyShift = True
    End If
End Sub

Private Sub picBackSelect_KeyUp(KeyCode As Integer, Shift As Integer)
    KeyShift = False
End Sub

Now replace all of both Private Sub picBackSelect_MouseDown and Private Sub picBackSelect_MouseMove with:
Private Sub picBackSelect_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        If KeyShift = False Then
             Call EditorChooseTile(Button, Shift, X, Y)
             shpSelected.Width = 32
             shpSelected.Height = 32
        Else
             EditorTileX = Int(X / PIC_X)
             EditorTileY = Int(Y / PIC_Y)
            
             If Int(EditorTileX * PIC_X) >= shpSelected.Left + shpSelected.Width Then
                 EditorTileX = Int(EditorTileX * PIC_X + PIC_X) - (shpSelected.Left + shpSelected.Width)
                 shpSelected.Width = shpSelected.Width + Int(EditorTileX)
             Else
                 If shpSelected.Width > PIC_X Then
                     If Int(EditorTileX * PIC_X) >= shpSelected.Left Then
                           EditorTileX = (EditorTileX * PIC_X + PIC_X) - (shpSelected.Left + shpSelected.Width)
                           shpSelected.Width = shpSelected.Width + Int(EditorTileX)
                     End If
                 End If
             End If
            
             If Int(EditorTileY * PIC_Y) >= shpSelected.Top + shpSelected.Height Then
                 EditorTileY = Int(EditorTileY * PIC_Y + PIC_Y) - (shpSelected.Top + shpSelected.Height)
                 shpSelected.Height = shpSelected.Height + Int(EditorTileY)
             Else
                 If shpSelected.Height > PIC_Y Then
                     If Int(EditorTileY * PIC_Y) >= shpSelected.Top Then
                           EditorTileY = (EditorTileY * PIC_Y + PIC_Y) - (shpSelected.Top + shpSelected.Height)
                           shpSelected.Height = shpSelected.Height + Int(EditorTileY)
                     End If
                 End If
             End If
        End If
    End If
   
    If optAttribs.Value = True Then
        shpSelected.Width = 32
        shpSelected.Height = 32
    End If
   
    EditorTileX = Int((shpSelected.Left + PIC_X) / PIC_X)
    EditorTileY = Int((shpSelected.Top + PIC_Y) / PIC_Y)
End Sub

Private Sub picBackSelect_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        If KeyShift = False Then
             Call EditorChooseTile(Button, Shift, X, Y)
             shpSelected.Width = 32
             shpSelected.Height = 32
        Else
             EditorTileX = Int(X / PIC_X)
             EditorTileY = Int(Y / PIC_Y)
            
             If Int(EditorTileX * PIC_X) >= shpSelected.Left + shpSelected.Width Then
                 EditorTileX = Int(EditorTileX * PIC_X + PIC_X) - (shpSelected.Left + shpSelected.Width)
                 shpSelected.Width = shpSelected.Width + Int(EditorTileX)
             Else
                 If shpSelected.Width > PIC_X Then
                     If Int(EditorTileX * PIC_X) >= shpSelected.Left Then
                           EditorTileX = (EditorTileX * PIC_X + PIC_X) - (shpSelected.Left + shpSelected.Width)
                           shpSelected.Width = shpSelected.Width + Int(EditorTileX)
                     End If
                 End If
             End If
            
             If Int(EditorTileY * PIC_Y) >= shpSelected.Top + shpSelected.Height Then
                 EditorTileY = Int(EditorTileY * PIC_Y + PIC_Y) - (shpSelected.Top + shpSelected.Height)
                 shpSelected.Height = shpSelected.Height + Int(EditorTileY)
             Else
                 If shpSelected.Height > PIC_Y Then
                     If Int(EditorTileY * PIC_Y) >= shpSelected.Top Then
                           EditorTileY = (EditorTileY * PIC_Y + PIC_Y) - (shpSelected.Top + shpSelected.Height)
                           shpSelected.Height = shpSelected.Height + Int(EditorTileY)
                     End If
                 End If
             End If
        End If
    End If
   
    If optAttribs.Value = True Then
        shpSelected.Width = 32
        shpSelected.Height = 32
    End If
   
    EditorTileX = Int(shpSelected.Left / PIC_X)
    EditorTileY = Int(shpSelected.Top / PIC_Y)
End Sub

Find Public Sub EditorMouseDown right under it add:
Dim x2 As Long, y2 As Long

Under
If (Button = 1) And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then

add:
If frmMirage.shpSelected.Height <= 32 And frmMirage.shpSelected.Width <= 32 Then

Find:
If frmMirage.optKeyOpen.Value = True Then
                               .Type = TILE_TYPE_KEYOPEN
                               .Data1 = KeyOpenEditorX
                               .Data2 = KeyOpenEditorY
                               .Data3 = 0
                           End If
                     End With
                 End If

Under the End If (but before the next End If) add:
Else
                 For Y2 = 0 To Int(frmMirage.shpSelected.Height / PIC_Y) - 1
                     For X2 = 0 To Int(frmMirage.shpSelected.Width / PIC_X) - 1
                           If X1 + X2 <= MAX_MAPX Then
                               If Y1 + Y2 <= MAX_MAPY Then
                                   If frmMirage.optLayers.Value = True Then
                                         With Map.Tile(X1 + X2, Y1 + Y2)
                                             If frmMirage.optGround.Value = True Then .Ground = (EditorTileY + Y2) * 7 + (EditorTileX + X2)
                                             If frmMirage.optMask.Value = True Then .Mask = (EditorTileY + Y2) * 7 + (EditorTileX + X2)
                                             If frmMirage.optAnim.Value = True Then .Anim = (EditorTileY + Y2) * 7 + (EditorTileX + X2)
                                             If frmMirage.optFringe.Value = True Then .Fringe = (EditorTileY + Y2) * 7 + (EditorTileX + X2)
                                         End With
                                   End If
                               End If
                           End If
                     Next X2
                 Next Y2
             End If

Finally find Public Sub EditorChooseTile change it all to:
Public Sub EditorChooseTile(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        EditorTileX = Int(X / PIC_X)
        EditorTileY = Int(Y / PIC_Y)
    End If
    frmMirage.shpSelected.Top = Int(EditorTileY * PIC_Y)
    frmMirage.shpSelected.Left = Int(EditorTileX * PIC_Y)
    Call BitBlt(frmMirage.picSelect.hDC, 0, 0, PIC_X, PIC_Y, frmMirage.picBackSelect.hDC, EditorTileX * PIC_X, EditorTileY * PIC_Y, SRCCOPY)
End Sub


Have fun :) Report any bugs here!



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info