dcsimg
Results 1 to 27 of 27

Thread: tileset help...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Question tileset help...

    Hi, it's been awhile since i have used vb 6.0 so please be patient with me. ty


    basically i am trying to make a tileset helper kinda thing...

    so on the left i want to have the png tileset loaded with vertical scrollbar - each tile has to be clickable
    on the right i want a result a result in say a textbox...

    IE:

    IMG xxxoxxxo

    to better get an example:
    Name:  untitled.PNG
Views: 169
Size:  81.7 KB

    i use RPG MAKER XP, and the project i am trying to accomplish is making tilesets mapable (right side as mentioned above) so other people can map out their tilesets. because people create tilesets but do not give mapouts - (the X's and O's and such).

    the project must have a way to find a PNG image, the image must be vertically scrollable - the image is 8x32=256 wide

    i really don't know how to explain the project any better/clearer - but if you have any questions feel free to ask.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    really? 95 views and NOBODY can tell me or show me how to do what i'm looking for? hard to believe!!!

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    Is it VB6 question or RPG MAKER XP question?



  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    basically i am trying to make a tileset helper kinda thing...
    so it's a vb thing...

    i wanna make a tileset helper thing with vb.. i need to know how to have a vertical scrolling image thing as shown.. and the image be clickable to be able to put a O or X or back to blank.. as you click each tile it will also put out to the right in a listbox or text the same info.. O, X, BLANK...

    i showed the rpg maker pic so people would get the exact idea of what i'm trying to make..

  5. #5
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,060

    Re: tileset help...

    you should post some code showing what you've tried, and explaining your exact problems.
    so far all you've done is outline a generic app, without any specifics except what format the input file is, and that it needs a vertical scroll bar.

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,612

    Re: tileset help...

    Part of the solution depends on how a user would provide "mapouts".
    Is there some standard structure being used to define "mapouts" for a tile set?
    As for scrolling the tileset, you would just load the image in a picturebox. The scrollbar would move the location of the picturebox up and down.
    You would use the position of where the mouse was clicked in the picturebox and a bit of math to determine which tile was clicked on.
    Is the tile set coordinates specified as two dimensions, or a linear index? Likewise, the mapout structure being two dimension or linear.
    Assuming you have a "mapout" structure, what enumeration is used for "clear", "0" and "X"?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    across is 8 (32x32) = 256
    vertically it's unlimited - but you need a scrollbar obviously..

    picturebox does not have vscroll or hscroll for that matter.. i just want the same exact thing as shown above.. minus those buttons for now..

    as far as coding, i haven't done any cause first i need the image to be scrollable which picturebox does not have.

    as for "standard" structure.. again, each 32x32 tile is to be clickable and that would place a "O" or "X" or back to nothing over each tile = and to the right there would be a listbox or whatever everytime you click it would put that indicator in there..

    IE:
    PICTURE AS SHOWN IN POST 1 LISTBOX OR WHATEVER
    o, blank, o, x, x, blank, blank, x o, blank, o, x, x, blank, blank, x
    o, blank, o, x, x, blank, blank, x o, blank, o, x, x, blank, blank, x
    o, blank, o, x, x, blank, blank, x o, blank, o, x, x, blank, blank, x

    and so on.. if you make a change on a tile, then it will also reflect in the listbox

    so i dunno how to any of this, i would appreciate it if somebody would help me out to accomplish this project.

  8. #8
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    Try the attached project.

    I used one dimension array to store clicks data, if you want two dimensions then try to adapt the code to meet your needs.
    Attached Files Attached Files



  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    that's exactly what i'm looking for.. however, there won't be a pic already there.. end user will have to find/open their own image.. but the image will have O's on every tile by default... and i was wrong about X,O, BLANK it's X, O and a SQUARE..

    Name:  aaa.PNG
Views: 82
Size:  9.8 KB

    can you be able to make the x's,o's and squares also appear over the image tiles too?

    but yeah you nailed the right side for sure! is the left side always going to match the length of the image regardless what image they open?

    Code:
    Private Const TileWidth As Long = 40 ' According to the map picture used in this project
    Private Const TileHeight As Long = 40
    Private Const ColumnsCount As Long = 8
    apparently not.. can that be self-calculating based on image opened?
    Last edited by elRuffsta; Dec 8th, 2017 at 08:13 PM.

  10. #10
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    After loading the image calculate TileWidth according to the image width, also you can draw in the picture, try the new attached code
    Attached Files Attached Files



  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    Name:  giphy.gif
Views: 76
Size:  36.2 KB


    too bad it doesn't make a square in the textbox - it's either x, o, .

    that's all i can say - i just wanna change the way end user gets the image.. so i'll try to do dir1, filelist, drive - in a separate form so when i click file in the menu but place the picture in this form in picMap.. although i was trying that earlier and it wasn't working for me.. i must be doing something silly wrong too..

    it won't let me rate yer post so i gave a big bow gif lol and ty for your help.. much appreciated!
    Last edited by elRuffsta; Dec 9th, 2017 at 12:44 AM.

  12. #12
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    I tried t = t & ChrW(&H25A1) but the Text box show question mark insted of square character because text box cannot display Unicode characters

    You can add Common Dialog Control to your form to easily browse for files



  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    would it show in anything else than a textbox that could be copied by the end user?

  14. #14
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    You can use a Unicode TextBox from Microsoft Forms 2.0 Object Library http://www.freevbcode.com/ShowCode.asp?ID=3278



  15. #15

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    hmmm
    Last edited by elRuffsta; Dec 10th, 2017 at 08:19 PM.

  16. #16
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    Quote Originally Posted by elRuffsta View Post
    hmmm
    What is that mean?



  17. #17

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    sorry.. wrote something but then changed my mind.. can't delete post so.. lol

    anyways.. i'm having an issue:
    Code:
    Private Sub mnuOpen_Click()
    CommonDialog1.Filter = "Png Files (*.png)|*.png"
     CommonDialog1.ShowOpen
     Form1.picMap.Picture = LoadPicture(CommonDialog1.FileName) ' error, line gets highlighted yellow after i select a picture..
    End Sub
    i even tried this:
    Code:
    Private Sub mnuOpen_Click()
    With picMap
    CommonDialog1.Filter = "Png Files (*.png)|*.png"
     CommonDialog1.ShowOpen
     Form1.picMap.Picture = LoadPicture(CommonDialog1.FileName) 'same error
     End With
    End Sub

    and this:
    Code:
    Private Sub mnuOpen_Click()
    With picMap
    CommonDialog1.Filter = "Png Files (*.png)|*.png"
     CommonDialog1.ShowOpen
    .Picture = LoadPicture(CommonDialog1.FileName) 'same error
     End With
    End Sub
    Run-time error '481:'
    Invalid picture
    Last edited by elRuffsta; Dec 10th, 2017 at 08:47 PM.

  18. #18
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    There are hundreds of errors, what is the error you are talking about? I can guess it is "Invalid picture" because PNG format is not supported by VB6 Picture control, try JPG or GIF instead.



  19. #19

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    :/ all the tilesets ARE png tho.. there are no other formats for them..

    how is it not possible? they did it some how this is their built-in map editor.. they loading PNG's

    Name:  cvc.jpg
Views: 119
Size:  37.6 KB
    Last edited by elRuffsta; Dec 10th, 2017 at 09:20 PM.

  20. #20
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    See this http://www.vbforums.com/showthread.p...n-Visual-Basic the Attached Files in post #2 is simple and enough for you.



  21. #21

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    yeah, i got picMap to load png.. ty

    but you may wanna look at this: since you coded it...

    and download this pic to use.. but use the app to find and open it to see..
    png

    it loads the png, however.. things just don't line up correctly (x,o, square)... and umm.. yeah the scrolling works backwards lol - i didn't touch yer code at all.. so best you look at it to see exactly what i'm talking about..
    Attached Files Attached Files
    Last edited by elRuffsta; Dec 10th, 2017 at 09:50 PM.

  22. #22
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    Of course you must update TileWidth, TileHeight and aMap each time you load new picture, all you need is:

    1- Replace mnuOpen_Click sub with
    Code:
    Private Sub mnuOpen_Click()
        Dim token As Long
        token = InitGDIPlus
        CommonDialog1.Filter = "Graphic Files (*.png)|*.png"
        CommonDialog1.ShowOpen
        Form1.picMap.Picture = LoadPictureGDIPlus(CommonDialog1.FileName)
        FreeGDIPlus token
        
        ' Update TileWidth, TileHeight and aMap array size
        TileWidth = picMap.Width \ ColumnsCount
        TileHeight = TileWidth
        Erase aMap
        ReDim aMap(ColumnsCount * (picMap.Height \ TileHeight))
        DrawData
        ShowData
    End Sub
    2- Replace ScrollPicture sub with

    Code:
    Private Sub ScrollPicture()
        If picMap.Height > picClient.Height Then
            picMap.top = -((picMap.Height - picClient.Height) * VScroll1.Value) / VScroll1.Max
        Else
            picMap.top = ((picMap.Height - picClient.Height) * VScroll1.Value) / VScroll1.Max
        End If
    End Sub
    Last edited by 4x2y; Dec 10th, 2017 at 10:15 PM.



  23. #23

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    right side doesn't match..

    i have the image scrolled all the way down and marked the very last tile and the right side scrolled down.. does not match the.. the scrollbar also goes goes back to the top - i guess after refreshing? should really only change when i click on another tile - matching at all times

    like there's more dots on the right than the image?? or the image isn't being scrolled all the way down, but the scrollbar stops..

    and you have to max the form to see all the image with scroll and i still don't think it's scrolling all the way down.. scroll only goes so far down, then you have to max the form to finish scrolling lol

    NOTE:
    yeah, i believe it's the scrollbar itself is not scrolling all the way down.. form maxed, scrollbar all the way down.. but not scrolling the full image.
    Last edited by elRuffsta; Dec 10th, 2017 at 10:51 PM.

  24. #24
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,531

    Re: tileset help...

    You also have to update picClient width and scroll position after opening new image, add this to the end of mnuOpen_Click

    Code:
    picClient.Width = picMap.Width
    VScroll1.Move picClient.Left + picClient.Width, picClient.Top, 17, picClient.Height
    Text1.Move VScroll1.Left + VScroll1.Width, picClient.Top, picClient.Width, picClient.Height
    Also in form resize event adjust the controls' height according to the form height.



  25. #25

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    still can't scroll the whole picture..

  26. #26
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,612

    Re: tileset help...

    Apparently there is a bug trying to move the picturebox with really tall pictures in them.
    Your image is 17152 pixels in height.
    When you change the .Top property of the picturebox to move its location, the picturebox's height is truncated to 16383 pixels (looking suspiciously like a size related to 16384, which is 2^14).
    This seems to happen regardless of whether AutoSize is set to True or False, and regardless of whether the picture is a .png file or a .bmp file.

    You may have to resort to loading the picture in a bitmap (could be in a hidden picturebox) and using PaintPicture or bitblt to implement scrolling rather than moving a picturebox.

    As an example, I've modified your existing code a little bit to use PaintPicture to implement the scrolling.
    The code is changed to set picMap.Visible to False since we no longer need to see it. We will still load the picture into it and draw on it using the existing code.
    We'll use picClient to show a portion of the image from picMap, so we set picClient.AutoRedraw to True.

    The ScrollPicture sub is changed to paint a portion of picMap into picClient rather than move the picturebox.
    Code:
    Private Sub ScrollPicture()
        picTop = ((17152 - picClient.Height) * VScroll1.Value) / VScroll1.Max
        picClient.Cls
        picClient.PaintPicture picMap.Image, 0, 0, picClient.Width, picClient.Height, 0, picTop, picClient.Width, picClient.Height
        picClient.Refresh
    End Sub
    I went ahead and set Scroll1.Max to 10000 to give us smoother scrolling.
    I changed the DrawData sub to call ScrollChange at the end of the sub to refresh the drawing when you make a change.
    I changed the MouseUp sub to be for picClient since picMap is no longer visible, just adding the Y offset to the Y click position so the position is relative to the portion of picMap being shown.
    I think that's about it for the important changes. Here's the full form code so you can just paste it in to replace your existing form code to try it out.
    You will see that you can scroll down to the bottom of the full tall image now. Probably something you would want to change is to set the scroll max based on the size of the image, and have no scrolling if the map was smaller than your client window.
    Code:
    Option Explicit
    
    Private TileWidth As Long
    Private TileHeight As Long
    Private Const ColumnsCount As Long = 8 'try with different values e.g. 6, 10, 11 or according to column in your image
    Private picTop As Integer
    
    Private aMap() As Integer
    
    Private Sub Form_Load()
        Me.ScaleMode = vbPixels
        picClient.ScaleMode = vbPixels
        picClient.AutoRedraw = True
        
        picMap.Visible = False
        With picMap
            .ScaleMode = vbPixels
            .AutoSize = True
            .AutoRedraw = True
            .BorderStyle = 0
            .Picture = LoadPicture(App.Path & "\sample.jpg") ' try with different images
            .Move 0, 0
            TileWidth = .Width \ ColumnsCount
            TileHeight = TileWidth
    '        TileHeight = .Height \ ColumnsCount ' uncomment if you don't want square tiles
        End With
        
        With picClient
            .BorderStyle = 0
            .Width = picMap.Width
            .Height = 600
        End With
        
        VScroll1.Min = 0
        VScroll1.Max = 10000
        VScroll1.LargeChange = 32
        VScroll1.Move picClient.left + picClient.Width, picClient.top, 17, picClient.Height
        
        Text1.Move VScroll1.left + VScroll1.Width, picClient.top, picClient.Width, picClient.Height
        
        ReDim aMap(ColumnsCount * (picMap.Height \ TileHeight))
        DrawData
        ShowData
    End Sub
    
    Private Sub mnuOpen_Click()
    Dim Token As Long
     Token = InitGDIPlus
    CommonDialog1.Filter = "Graphic Files (*.png)|*.png"
     CommonDialog1.ShowOpen
     picMap.AutoSize = True
     picMap.top = -1
    Form1.picMap.Picture = LoadPictureGDIPlus(CommonDialog1.FileName)
    
    FreeGDIPlus Token
    
        ' Update TileWidth, TileHeight and aMap array size
        TileWidth = picMap.Width \ ColumnsCount
        TileHeight = TileWidth
        Erase aMap
        ReDim aMap(ColumnsCount * (picMap.Height \ TileHeight))
        DrawData
        ShowData
        picMap.AutoSize = False
    End Sub
    
    Private Sub picClient_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim tx As Long
        Dim ty As Long
        tx = x \ TileWidth
        ty = (y + picTop) \ TileHeight
        Me.Caption = tx & ", " & ty & " has been clicked"
        
        aMap(tx + (ty * ColumnsCount)) = (aMap(tx + (ty * ColumnsCount)) + 1) Mod 3
        
        DrawData
        ShowData
    End Sub
    
    Private Sub VScroll1_Change()
        ScrollPicture
    End Sub
    
    Private Sub VScroll1_Scroll()
        ScrollPicture
    End Sub
    
    Private Sub ScrollPicture()
        picTop = ((17152 - picClient.Height) * VScroll1.Value) / VScroll1.Max
        picClient.Cls
        picClient.PaintPicture picMap.Image, 0, 0, picClient.Width, picClient.Height, 0, picTop, picClient.Width, picClient.Height
        picClient.Refresh
    End Sub
    
    Private Sub ShowData()
        Dim t As String
        Dim j As Long
        Dim k As Long
        
        For j = 0 To UBound(aMap) - ColumnsCount Step ColumnsCount
            For k = 0 To ColumnsCount - 1
                If aMap(j + k) = 0 Then
                    t = t & ". "
                ElseIf aMap(j + k) = 1 Then
                    t = t & "O "
                Else
                    t = t & "X "
                End If
            Next
            t = t & vbNewLine
        Next
        
        Text1.Text = t
    End Sub
    
    Private Sub DrawData()
        Dim j As Long
        Dim k As Long
        Dim x As Long
        Dim y As Long
        
        picMap.Cls
        picMap.DrawWidth = 3
        
        For j = 0 To UBound(aMap) - ColumnsCount Step ColumnsCount
            For k = 0 To ColumnsCount - 1
                If aMap(j + k) = 0 Then
                    picMap.Line (x + (TileWidth \ 4), y + (TileHeight \ 4))-Step(TileWidth \ 2, TileHeight \ 2), vbBlack, B
                ElseIf aMap(j + k) = 1 Then
                    picMap.Circle (x + (TileWidth \ 2), y + (TileHeight \ 2)), TileWidth \ 4, vbBlack
                Else
                    picMap.Line (x + (TileWidth \ 4), y + (TileHeight \ 4))-Step(TileWidth \ 2, TileHeight \ 2), vbBlack
                    picMap.Line (x + (TileWidth \ 4) + (TileWidth \ 2), y + (TileHeight \ 4))-Step(-(TileWidth \ 2), TileHeight \ 2), vbBlack
                End If
                x = x + TileWidth
            Next
            x = 0
            y = y + TileHeight
        Next
        ScrollPicture
    End Sub
    p.s. As for the textbox issue, a quick patch that would keep the textbox "in the neighborhood" of where you're scrolling the image would be to add a line like this at the bottom of the picClient_MouseUp sub:

    Text1.SelStart = Len(Text1.Text) * VScroll1.Value / VScroll1.Max + 300

    But a better solution might be to use a picturebox and draw the characters for the current scroll window in that picturebox so you can easily space them and keep them in sync with the image while scrolling.
    Another option, depending on what the text is actually suppose to look like, is to not have all the characters in the string in the textbox, but just show the substring that corresponds to the portion of the image that is showing. In that case you wouldn't have a scrollbar on the textbox, you would just update the textbox with the relevant part of the string (the rows) currently showing from the image.

    As an example, of just printing a subset of the characters to the textbox for portion of the image showing, you can try these updated subs.
    Code:
    Private Sub ScrollPicture()
        picTop = ((17152 - picClient.Height) * VScroll1.Value) / VScroll1.Max
        picClient.Cls
        picClient.PaintPicture picMap.Image, 0, 0, picClient.Width, picClient.Height, 0, picTop, picClient.Width, picClient.Height
        picClient.Refresh
        ShowData
    End Sub
    
    Private Sub ShowData()
        Dim t As String
        Dim j As Long
        Dim k As Long
        
        Dim firstRow As Long
        Dim firstChar As Long
        Dim lastChar As Long
        firstRow = picTop \ TileHeight
        firstChar = firstRow * ColumnsCount
        lastChar = firstChar + 19 * ColumnsCount '19 is max number of rows shown (assuming 32 pixels)
        If lastChar > UBound(aMap) Then lastChar = UBound(aMap)
    '    For j = 0 To UBound(aMap) - ColumnsCount Step ColumnsCount
        For j = firstChar To lastChar - ColumnsCount Step ColumnsCount
            For k = 0 To ColumnsCount - 1
                If aMap(j + k) = 0 Then
                    t = t & ". "
                ElseIf aMap(j + k) = 1 Then
                    t = t & "O "
                Else
                    t = t & "X "
                End If
            Next
            t = t & vbNewLine
        Next
        
        Text1.Text = t
    End Sub
    Last edited by passel; Dec 11th, 2017 at 10:42 PM.

  27. #27

    Thread Starter
    Lively Member
    Join Date
    May 2014
    Posts
    91

    Re: tileset help...

    i work in a kitchen as a chef, i am pulling doubles all this week - but i will look at this in more detail at some point this week. thank you btw

    i'm really looking to get this project done as i am sure everyone else here is lol - ty all for helping.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width