Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Feature] Dynamic Tile Width
#1
Ok, so this tutorial will make it so that you can putin any size tilesheet with any width and the game will figure out its width and change TILESHEET_WIDTH accordingly. The first thing we have to do for this is make a horizontal scroll bar for our map editor, otherwise we can't use tilesheets bigger then our map editor.

Go to frmMirage,and add a new horizantle scroll bar under where the map editor tiles are. You may want to move some things down to fit this in.

Name the scroll bar hscrlPicture

now in frmMirage add this sub
Code:
Private Sub hscrlPicture_Change()
    Call MapEditorTileHScroll
End Sub

We might as well also add under this line
Code:
scrlPicture.Max = (picBackSelect.Height \ PIC_Y) - (picBack.Height \ PIC_Y)

and under this line
Code:
Call InitTileSurf(scrlTileSet)
Code:
Call CalcTilePositions

These bits should make more sense later.

Now go to modGameEditors and add this sub
Code:
Public Sub MapEditorTileHScroll()
    With frmMirage
        .picBackSelect.Left = (.hscrlPicture.Value * PIC_X) * -1
        .picScreen.Refresh
    End With
End Sub

we put the picscreen.refresh in because when picbackselect goes behind picscreen it makes an ugly grey box, and its better to just refresh the whole screen. You can remove it if you want.

Now lets do the actual dynamic width part

find
Code:
Public Const TILESHEET_WIDTH As Integer = 7 ' * PIC_X pixels
comment it out, or delete it

now in modGlobals add this at the bottom
Code:
'Tilesheet width
Public TILESHEET_WIDTH As Integer


in modDirectDraw7 in the InitTileSurf sub under this code
Code:
Call InitDDSurf("tiles" & TileSet, DDS_Tile)
put
Code:
TILESHEET_WIDTH = modDirectDraw7.DDS_Tile.SurfDescription.lWidth \ PIC_X


I hope this works for you!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)