Jump to content

Tiled map not displaying

Karl G

Recommended Posts

I believe I've figured out how I can easily generate images in the correct format from my Mac. However, I seem to be having issues with displaying a map imported with Tiled. There are no errors, but I also see no output on the screen after compiling. I'm posting the source inline, and attaching a zip of my test project here.  Any ideas what I'm doing wrong here?


	set zoneheight 16
	set doublewide on
	displaymode 160A
    set romsize 48k
    set screenheight 192
    set pauseroutine on
    set basepath gfx
    dim TaxiX = a
    dim PlayerWidth = b
    dim TaxiInc = c
    dim Boolean = d
    dim FireButtonPressedBit0 = d
    dim Clock = e
    const screen_right = 159
    const screen_left = 0
    const offscreen = 200
    const taxi_y = 176
    P0C3=$AF: P0C1=$1A: P0C2=$0F
    P1C1=$0C: P1C2=$06: P1C3=$88
    P2C1=$78: P2C2=$75: P2C3=$69
    incgraphic taxi.png
    incmapfile skyscrapers.tmx
    TaxiX = 80
    PlayerWidth = 16
    TaxiInc = 2


	plotmap skyscrapers 1 0 0 20 12


    if joy0right then TaxiX = TaxiX + TaxiInc
    if joy0left then TaxiX = TaxiX - TaxiInc
    if TaxiX >= offscreen then TaxiX = screen_left
    if TaxiX > screen_right - PlayerWidth then TaxiX = screen_right - PlayerWidth
    if !joy0fire then FireButtonPressedBit0{0} = 0 : goto ____skip_joystick_button
    if FireButtonPressedBit0{0} then goto ____skip_joystick_button
    playsfx sfx_shoot
    FireButtonPressedBit0{0} = 1
    plotsprite taxi 0 TaxiX 176
    goto Main

    data sfx_shoot
    16, 4, 1
    $3, $1, $D
    $2, $1, $F
    $2, $1, $D
    $3, $1, $C
    $4, $1, $B
    $5, $1, $A
    $6, $1, $8
    $7, $1, $8
    $7, $1, $6
    0, 0, 0


Link to comment
Share on other sites

Well, I've cut it down to a minimal example of the issue and I can't figure it out. It looks like nothing gets drawn on any line the map would appear on, even if it's only a 1 by 1 character map.

    P0C3=$AF: P0C1=$1A: P0C2=$0F
	incgraphic gfx/skyscraperstiles.png 160A 0 1 2 3 1
    incgraphic gfx/taxi.png 160A 0 1 2 3
	plotmap test 0 0 0 1 1
	plotsprite skyscraperstiles 0 24 12
    plotsprite taxi 0 80 100
    goto Main
	data test



Link to comment
Share on other sites

For one, you haven't set your characterset.  After I just added "characterset taxi" I got the taxi being drawn along with a horribly corrupted map that's obviously not correct.


However you're also using plotmap instead of plotmapfile - plotmapfile is the command that generally displays imported tmx maps from tiled.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

To resolve you'll need to add the below lines somewhere.

characterset skyscraperstiles
incgraphic skyscraperstiles.png

Then on your tilemap you have to embed the tileset (there's a button in tiled to do that) otherwise it doesn't work properly, and the name of the tileset has to match the name of the graphics to use within you code so I had to change it to 'skyscraperstiles' so as to not conflict with the tilemap name. If you compare them both in a text editor you'll see what I mean.


  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Well, my screen had been working nicely thanks to help from people here, but I managed to break it again.


Specifically, I needed to switch from 16 height tiles to 8 height, so I created a new map in Tiled with a new tileset with the correct height, and included it in my program.  I also changed my zoneheight to 8, and my plotmap command to output 24 rows instead of 12.


Here's what I expected to see based on my Tiled map:





Here is what I actually saw in the emulator window:




Obviously it is pulling from the wrong graphics data, but I don't understand why.  Any ideas?  I'm attaching a zip if my source and dependencies. 


Thanks in advance for any advice!




Link to comment
Share on other sites

Best I can tell, something got messed up within the tiled tmx file itself. If you open it in a text editor, you can see these are the tilesets the map file is working with...

 <tileset firstgid="1" name="skyscraperstiles" tilewidth="8" tileheight="16" tilecount="0" columns="24">
  <image source="skyscraperstiles.png" width="192" height="8"/>
 <tileset firstgid="1" name="skyscrapers" tilewidth="8" tileheight="8" tilecount="24" columns="24">

...notice that the tile count of the skyscraperstiles png tileset is "0". Then there's another "skyscrapers" tileset it references, but there is no "skyscrapers" png tileset - it's a map file, which is why you're getting gibberish.


If I manually change the tilecount for the first tileset to 16, and change the "firstgid" of the second tileset to 16, then I see the first 16 characters as expected.


So how did it get corrupted? I think at some point you must have accidentally imported a wrong file (possibly the tmx file itself or maybe a "skyscrapers.png" file you later renamed) into the tmx. 


  • Thanks 1
Link to comment
Share on other sites

Okay; thank you.  I'm sure it got messed up my me as I was shuffling things around to switch over to the new map file. I did my own editing to get rid of the bogus tileset reference, and changed the tile count to include all of the files, and Tiled loads it fine.  It almost displays correctly in the emulator now, except for two tiles. Looking at the tmx file, those two appear to be correct, and no different than neighboring tiles that are working fine.


Any ideas?  Thanks again for all of your help!






Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...