Author Topic: Tile Map Editor  (Read 9095 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Tile Map Editor prototype
« Reply #15 on: February 23, 2021, 04:36:56 pm »
My suggestion is to draw whatever size map you need, up to 65,535x65,536 pixels in size.  With a 64x64 sprite, you can have 1024x1024 squares on your grid...

Then simply _PUTIMAGE the segment you want onto the display screen.

:) maybe later

My screen is theoretically something around 768 pixel height but title bar takes 20 or so 740 is tight but doable, 700 much more comfortable.

Fellippe and Terry report 1024 max width is faster and I think so too but not definitively tested, go by the word of these people who should know.

This is what I am using in SB1 for a nice even max of 42 lines, giving 40 lines for printing and 41, 42 can scroll all they want.
Code: QB64: [Select]
  1. CONST Xmax = 1024, Ymax = 672 '16*42 lines  
  2. ' more declares
  3. SCREEN _NEWIMAGE(Xmax, Ymax, 32)
  4. _DELAY .25 '                     have to waits a bit for screen to load
  5. _SCREENMOVE _MIDDLE  ' centers
  6.  
« Last Edit: February 23, 2021, 05:34:26 pm by bplus »

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype version 0.4
« Reply #16 on: February 23, 2021, 04:46:38 pm »
Hi All

Latest version 

Added some error checking when loading maps
Nicer graphical user input and error messages
Added prompt for images folder to load tiles/sheets from
Increased the number tiles in the selection part to 100 tiles (5 columns of 20)
Changed screen size to 1366x768
Changed program name to "Tile map editor"
Added mode button for next feature which will allow you to assign codes to tile positions for indicating solid objects etc

Brian ...
 
Screenshot tile map editor 6.png
Brian ...

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype updated version 0.5
« Reply #17 on: February 24, 2021, 11:18:56 am »
Hi All

 
Now has the map codes feature added initially only 1 hard coded code "w", to put the map code on the map click the mode button to change to mode 1 then click the w button then click on the map, to clear a code click the X button then click on the map click the mode button again to switch back to tile mode.
When you save a map it creates an additional file containing the map codes prefixed with "MapCodes-". Load will look for a map codes file and load it automatically.
Will probably be the last update for a few days as I will be switching to creating a game (Using the tile map editor).

 
Screenshot tile map editor 7.png


Brian ...

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Tile Map Editor prototype
« Reply #18 on: February 24, 2021, 11:20:13 am »
That map looks awesome.
Shuwatch!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Tile Map Editor prototype
« Reply #19 on: February 24, 2021, 03:04:06 pm »
Version 0.5 required a bit of tweaking.... When I look at the sample images posted on QB64, I noticed that on my machine, only half of the tiles are displayed. Linux is a bit fiddly when it comes to filename. Some of the tile filenames include "tile" and others include "Tile". Once all the filenames included "tile" then all the 32x32 tiles were displayed.

I have also tested the editor using  "Wine" and it runs perfectly as is and unedited.

I have a tile-based platformer that I cobbled together, using another Basic that will not be named, which could benefit from this program. My program reads a text-based map file and converts it to tiles. It looks like the saved tile map is also text-based, but instead of converting a singe character, the tile path is saved. Interesting. This method has the advantage of eliminating squillions (number of tiles) of 'if...then's within the program but increases the size of the map file. Swings and roundabouts*

Bit of a challenge but sounds like fun!

As usual, very nicely done... I look forward to seeing your game... No pressure, right? lol

J

*British, informal. —used to say that two choices or situations are basically the same because they have an equal number of advantages and disadvantages It is a case of swings and roundabouts.
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Tile Map Editor prototype
« Reply #20 on: February 24, 2021, 03:30:05 pm »
I've also got a tile map editor here (https://www.qb64.org/forum/index.php?topic=490.msg3745#msg3745), in case you'd like to play around and take a look at it sometime.  It allows for up to 3 different layers (which my game uses basically for walking, swimming, or flying states) of movement, and allows usage of multiple tile sets with each map.  Even if it's not exactly what you're looking for, it might be something you'd be interested in taking a look at and playing around with for a bit.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype
« Reply #21 on: February 24, 2021, 03:54:45 pm »
Thank you SMcNeill will take a look.

I've also got a tile map editor here (https://www.qb64.org/forum/index.php?topic=490.msg3745#msg3745), in case you'd like to play around and take a look at it sometime.  It allows for up to 3 different layers (which my game uses basically for walking, swimming, or flying states) of movement, and allows usage of multiple tile sets with each map.  Even if it's not exactly what you're looking for, it might be something you'd be interested in taking a look at and playing around with for a bit.  :)
Brian ...

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype updated version 0.6
« Reply #22 on: February 24, 2021, 04:11:02 pm »
Hi All

Well having starting to use the map editor I realised I need more map codes so made a quick update to display 6 map code buttons, you can change the codes in the data statement in line 650 leaving the X at the end of the data statement as that is the button used to clear map codes.

Brian ...

 
 
Screenshot tile map editor 8.png
Brian ...

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype
« Reply #23 on: February 25, 2021, 02:58:20 am »
Hi Johno

I did briefly think about  tile cross ref to a character code but thought we already have a unique code in the file name. This way will make the code neater and save having to transfer the cross ref data. I didn't think the file size would be an issue but will see what they are like.
Could you share the mods need to make it work in Linux.

Brian...


Version 0.5 required a bit of tweaking.... When I look at the sample images posted on QB64, I noticed that on my machine, only half of the tiles are displayed. Linux is a bit fiddly when it comes to filename. Some of the tile filenames include "tile" and others include "Tile". Once all the filenames included "tile" then all the 32x32 tiles were displayed.

I have also tested the editor using  "Wine" and it runs perfectly as is and unedited.

I have a tile-based platformer that I cobbled together, using another Basic that will not be named, which could benefit from this program. My program reads a text-based map file and converts it to tiles. It looks like the saved tile map is also text-based, but instead of converting a singe character, the tile path is saved. Interesting. This method has the advantage of eliminating squillions (number of tiles) of 'if...then's within the program but increases the size of the map file. Swings and roundabouts*

Bit of a challenge but sounds like fun!

As usual, very nicely done... I look forward to seeing your game... No pressure, right? lol

J

*British, informal. —used to say that two choices or situations are basically the same because they have an equal number of advantages and disadvantages It is a case of swings and roundabouts.
Brian ...

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Tile Map Editor prototype
« Reply #24 on: February 25, 2021, 06:53:19 am »
This is the modified 'loadtiles' that I use. As stated earlier, after changing the tile filename case, the tiles loaded ok.

For some reason 'fPath' did not work. So I left is set to 'images' (just pressed Enter at program start)

But here is the strange part.... When loading a sample sheet via 'loadSheet' the sheetImage = ImageLoad(".\" + imageFolder + "\" + fileName) worked just fine.

SUB LoadTiles
    DIM fH AS LONG
    DIM fileName AS STRING
    DIM fPath AS STRING
    DIM tileImage AS LONG

    ZeroImagesArray
    fH = FREEFILE

    'SHELL _HIDE "cmd /c dir .\" + imageFolder + "\*tile*.png  /B > tiles.txt"
    SHELL _HIDE "ls images/*tile*.png > tiles.txt"

    IF _FILEEXISTS("tiles.txt") THEN
        OPEN "tiles.txt" FOR INPUT AS fH
        DO UNTIL EOF(fH)
            LINE INPUT #fH, fileName
            PRINT fileName
            'fPath = ".\" + imageFolder + "\" + fileName
            fPath = fileName
            tileImage = ImageLoad(fPath)
            AddTileImage tileImage, fileName
        LOOP
    END IF
    CLOSE #fH
END SUB


I think with future versions, I will run the editor using "Wine", that way I don't have to make any changes... Too much thinking involved... Stop laughing bplus...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Tile Map Editor prototype
« Reply #25 on: February 25, 2021, 10:26:11 am »
Quote
Too much thinking involved... Stop laughing bplus...

The need for caffeine is disguised as the need to think ;-))

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Tile Map Editor prototype
« Reply #26 on: February 25, 2021, 02:52:23 pm »
Another one of your amazing talents... Mind reading.... Cool...
Logic is the beginning of wisdom.

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor prototype updated version 0.7
« Reply #27 on: March 04, 2021, 03:26:32 pm »
During game dev (which is taking a lot longer than I thought it would) I had to fix a few things in the Tile Map Editor so here is an updated version with the following changes.
 
Fixed Load Sheet coordinate error
Added image files used list output - for transfer to game program - saving a map creates 3 files now map, map codes & file list
Fixed clear map codes function not working
Added change image folder button
Show current map & image folder in title bar
Debugged text input box function.
 
Screenshot tile map editor 9.png


Screen shot of game created using map files from the editor.
 
Screenshot ytb3.png


Brian ...

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Tile Map Editor Version 0.8
« Reply #28 on: March 20, 2021, 12:20:18 pm »
Latest version v0.8
Usable version published on itch.io https://191brian.itch.io/qb64-tile-map-editor
 

Usage
Put your tile & tile/sprite sheet images in a folder off the main program folder or use the supplied tiles run "tile map editor.exe" choose an image folder and auto load the tiles (for auto load tiles to work the tile images must have "tile" somewhere in their name).  Use the buttons across the top of the screen to set your map and tile size load any sheets. Use your mouse to select a tile from the list on the righthand side then click on the map to paint with that tile. To set map codes for walls and exit points click the mode button to put it in to mode 1 then pick a map code and click on the map to paint the code, to clear a code click the X then click on the map. To save your map click the save button and enter a map name.
Saving produces 3 comma delimited text files:
1. File with line 1 holding  the map width, height and tile size followed by table of tile image file names.
2. File with a table of map codes
3. File which lists all the tile image files used on the map

When loading an existing map ensure the correct folder for its images is selected and any sheets are load first, the program will list any missing files.

« Last Edit: March 21, 2021, 05:39:11 pm by 191Brian »
Brian ...