Results 1 to 10 of 10

Thread: "Snapped" form resize like in Delphi 7 Object Inspector

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Oh, sorry, forgot to update the ColumnWidth and ColumnHeight variables. One had 64 and another 20.
    I will try the drawgrid now.
    Like in example above, i dont want half rows or half columns, only full rows and full columns.


    i will try to make it.
    If i cant,i will let you know.
    EDIT: your grid itself works fine. it has 64x64 cells and form snaps to them.

    Dunno how the drawgrid thingy will work.
    Last edited by hwnd; 08-09-2013 at 10:34 PM.

  2. #2
    It should work OK.
    You might only need to figure out the size of the DrawGrid component border.

  3. #3
    Everything looks almost perfect, now i need a bit help with some math.
    I have 992 tiles, tiles are all 64x64 pixels, and lets say i have grid on form which has 12 columns and 8 rows visible.

    12 * 8 = 96 tiles are currently visible.

    How can i calculate how many columns (and rows) are needed for the rest of the tiles?
    I mean calculate the needed rows / columns for all of the tiles by also counting in current col- and rowcount?

    Whats the proper math?

    I tried something like:
    Code:
    kgrid1.ColCount:=992 div kgrid1.rowCount;
    But it doesnt work very well. Last tiles are not drawn sometimes and sometimes they are.

    Column count can change and same with row count. Because user can resize grid (actually the form).


    Thanks for any tip.

  4. #4
    I don't understand why you need to count that in the first place. When you have a tilemap, you should already know how many rows and columns it has. I'll take a guess it's 31x32 because that makes 992 And yes, 992 div 31 = 32, or 992 div 32 = 31, working in both ways. The problem with rendering does certainly not come down to this math, but other code error.

  5. #5
    Thanks. You are right.

    I just had to initialize colcount / rowcount.

    And remove that, because its useless now:

    kgrid1.ColCount:=992 div kgrid1.rowCount

    It works fine. I still have few things to make, but its too late atm, gtg to sleep.
    And yesterday i also added a "nice feature" that moves scrollbars away from tiles.
    Otherwise the grid scrollbars would hide some of the tiles. But i just made the form bigger, by getting scrollbar width/height from windows and passing it to my code.
    I later will show it.

    Btw just one more question:
    I have currently dynamic 2D array, called tilesheet of integers, i set its length according to numcols and numrows. And then i do:
    Code:
    KGrid1.CellPainter.Canvas.Draw(R.Left, R.Top, sty.getTile( TileSheet[ARow , ACol ]));
    sty.getTile just waits for the tile_id (integer).

    Is it possible to draw all these tiles (992) without that "tilesheet" array?
    Last edited by hwnd; 14-09-2013 at 12:57 AM.

Bookmarks

Posting Permissions

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